wmi

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

client.h (2967B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 #ifndef __CLIENT_H
      5 #define __CLIENT_H
      6 
      7 extern "C" {
      8 #include <X11/Xlib.h>
      9 #include <X11/Xutil.h>
     10 }
     11 
     12 #include <list>
     13 #include <string>
     14 #include "thing.h"
     15 #include "wmi.h"
     16 
     17 // forward declaration
     18 class Client;
     19 class Monitor;
     20 class Workspace;
     21 
     22 typedef list<Client *> LClient;
     23 
     24 /**
     25  * Representates an X client window.
     26  */
     27 class Client : public Thing
     28 {
     29 
     30 public:
     31 
     32     enum Mode {FLOAT, MAX, STICKY
     33 #ifdef SLOT_SUPPORT
     34         , SLOT
     35 #endif // SLOT_SUPPORT
     36         };
     37 
     38     Client(Monitor *monitor, Window window, XWindowAttributes *attr);
     39     ~Client();
     40 
     41     /** Returns if this client is transient. */
     42     void setTransient(Client *client);
     43     Client *transient() const;
     44 
     45     long eventMask() const;
     46 
     47     string className() const;
     48 
     49     string instanceName() const;
     50 
     51     string iconName() const;
     52 
     53     void sendConfiguration();
     54 
     55     virtual void resize();
     56 
     57     /** event handler. */
     58     void handleConfigureRequest(XConfigureRequestEvent *event);
     59     void handleMapNotify(XMapEvent *event);
     60     void handlePropertyNotify(XPropertyEvent *event);
     61     void handleUnmapNotify(XUnmapEvent *event);
     62 
     63     virtual void show();
     64     virtual void hide();
     65 
     66     int protocols() const;
     67 
     68     bool isCentered() const;
     69 
     70     void initICCCM();
     71 
     72     void setMode(Mode mode);
     73 
     74     Mode mode() const;
     75 
     76     int state() const;
     77 
     78     /** Illuminates this frame. */
     79     virtual void illuminate();
     80 
     81     virtual bool isFocused();
     82 
     83     virtual void handleButtonPress(XButtonEvent *event);
     84     virtual void handleButtonRelease(XButtonEvent *event);
     85 
     86     virtual Cursor cursorForXY(int pointerX, int pointerY);
     87 
     88     virtual Window window();
     89     Window frameWindow() const;
     90     Window clientWindow() const;
     91 
     92     void setDestroyed(bool isDestroyed);
     93     bool isDestroyed() const;
     94 
     95     void createFrame();
     96 
     97     void reparent(Window parentWindow, int x, int y);
     98 
     99     string id();
    100 
    101     Frame *frame() const;
    102     void setFrame(Frame *frame);
    103 
    104     Workspace *attached() const;
    105     void setAttached(Workspace *workspace);
    106 
    107     bool requestsFocus() const;
    108     void setRequestsFocus(bool requestsFocus);
    109 
    110     /**
    111      * Defines where this client prefers to be attached to.
    112      * Must be a valid workspace or slot tab name.
    113      */
    114     string hooked() const;
    115     void setHooked(string hooked);
    116 
    117 private:
    118 
    119     void gravitate(bool invert);
    120 
    121     /** Updates the size of this client. */
    122     void updateSize();
    123 
    124     /** Updates transient for this client. */
    125     void updateTransient();
    126 
    127     Window clientWindow_;
    128 
    129     string className_;
    130     string instanceName_;
    131     string iconName_;
    132     string hooked_;
    133 
    134     Workspace *workspace_;
    135     Client *transient_;
    136     Frame *frame_;
    137 
    138     unsigned int clientBorderWidth_;
    139 
    140     int protocols_;
    141     int state_;
    142     long eventMask_;
    143 
    144     bool isCentered_;
    145     bool hasFrame_;
    146     bool requestsFocus_;
    147     bool isDestroyed_;
    148 
    149     Mode mode_;
    150     string id_;
    151 };
    152 
    153 #endif // __CLIENT_H