X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=util%2Fepist%2Fscreen.cc;h=fd65db4c5e6796f8a1ac9a688ee50a486b5819d9;hb=c517f511000c8ec775f7413527b9e276b7995806;hp=ad2b17721ea39183fa257d35ee63b262613e67e6;hpb=24a1e215d1f8d2ff1674847278a15336d4b671b6;p=chaz%2Fopenbox diff --git a/util/epist/screen.cc b/util/epist/screen.cc index ad2b1772..fd65db4c 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -1,5 +1,5 @@ // -*- mode: C++; indent-tabs-mode: nil; -*- -// screen.cc for Epistory - a key handler for NETWM/EWMH window managers. +// screen.cc for Epistophy - a key handler for NETWM/EWMH window managers. // Copyright (c) 2002 - 2002 Ben Jansens // // Permission is hereby granted, free of charge, to any person obtaining a @@ -137,10 +137,40 @@ void screen::processEvent(const XEvent &e) { } break; case KeyPress: + handleKeypress(e); break; } } +void screen::handleKeypress(const XEvent &e) { + ActionList::const_iterator it = _epist->actions().begin(); + ActionList::const_iterator end = _epist->actions().end(); + cout << "key press\n"; + for (; it != end; ++it) { + if (e.xkey.keycode == it->keycode() && + e.xkey.state == it->modifierMask()) { + switch (it->type()) { + case Action::nextWorkspace: + cycleWorkspace(true); + break; + + case Action::prevWorkspace: + cycleWorkspace(false); + break; + + case Action::changeWorkspace: + changeWorkspace(it->number()); + break; + + case Action::shade: + (*_active)->shade(! (*_active)->shaded()); + break; + } + + break; + } + } +} // do we want to add this window to our list? bool screen::doAddWindow(Window window) const { @@ -190,7 +220,8 @@ void screen::updateClientList() { if (it == end) { // didn't already exist if (doAddWindow(rootclients[i])) { cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; - _clients.insert(insert_point, new XWindow(_epist, rootclients[i])); + _clients.insert(insert_point, new XWindow(_epist, this, + rootclients[i])); } } } @@ -238,3 +269,30 @@ void screen::updateActiveWindow() { perror("putenv()"); } */ + +void screen::cycleWorkspace(const bool forward) const { + unsigned long currentDesktop = 0; + unsigned long numDesktops = 0; + + if (_xatom->getValue(_root, XAtom::net_current_desktop, XAtom::cardinal, + currentDesktop)) { + if (forward) + ++currentDesktop; + else + --currentDesktop; + + _xatom->getValue(_root, XAtom::net_number_of_desktops, XAtom::cardinal, + numDesktops); + + if ( ( (signed)currentDesktop) == -1) + currentDesktop = numDesktops - 1; + else if (currentDesktop >= numDesktops) + currentDesktop = 0; + + changeWorkspace(currentDesktop); + } +} + +void screen::changeWorkspace(const int num) const { + _xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root, num); +}