wmi

git clone git://oldgit.suckless.org/wmi/
Log | Files | Refs | LICENSE

slot.h (1865B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 #ifndef __SLOT_H
      5 #define __SLOT_H
      6 
      7 #include "wmi.h"
      8 
      9 #ifdef SLOT_SUPPORT
     10 
     11 extern "C" {
     12 #include <X11/Xlib.h>
     13 }
     14 
     15 #include <list>
     16 #include <string>
     17 #include "container.h"
     18 #include "widget.h"
     19 
     20 class Client;
     21 class Label;
     22 class Monitor;
     23 class Theme;
     24 
     25 typedef list<Client *> LClient;
     26 
     27 /**
     28  * Class for slot tabs.
     29  */
     30 class Tab {
     31 
     32 public:
     33 
     34     Tab(const string name);
     35     ~Tab();
     36 
     37     string name() const;
     38     LClient *clients();
     39     void addClient(Client *client);
     40     void removeClient(Client *client);
     41 
     42     void show();
     43     void hide();
     44     bool isVisible() const;
     45 
     46     Client *focused() const;
     47     void focus(Client *client);
     48 
     49 private:
     50 
     51     Client *focused_;
     52     bool isVisible_;
     53     string name_;
     54     LClient clients_;
     55 };
     56 
     57 typedef list<Tab *> LTab;
     58 
     59 /**
     60  * Base class of the slot which is capable to handle all kinds
     61  * of X clients in a dockapp manner.
     62  */
     63 class Slot : public Widget,
     64              public Container<Monitor, LTab, LTab::iterator, Tab>
     65 {
     66 
     67 public:
     68 
     69     Slot(Monitor *monitor, Rectangle *rect, Direction align);
     70 
     71     virtual ~Slot();
     72 
     73     Direction alignment() const;
     74 
     75     void show(string tabName);
     76     virtual void hide();
     77     bool hasClients();
     78     bool isGrabFocus() const;
     79     void setGrabFocus(bool grabFocus);
     80     void focusClient(Client *client);
     81 
     82     void attachClient(Client *client);
     83     void detachClient(Client *client);
     84     void manage();
     85 
     86     /** called on Expose by Kernel. */
     87     void illuminate();
     88 
     89     void handleButtonPress(XButtonEvent *event);
     90     void handleMotionNotify(XMotionEvent *event);
     91 
     92     string tabName();
     93 
     94 private:
     95 
     96     void initTabs();
     97     Tab *tabForName(string name);
     98 
     99     Direction align_;
    100     Label *label_;
    101     bool isSolid_;
    102     bool isGrabFocus_;
    103     Theme *theme_;
    104 };
    105 
    106 #endif // SLOT_SUPPORT
    107 #endif // __SLOT_H