wmi

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

workspace.h (4423B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 #ifndef __WORKSPACE_H
      5 #define __WORKSPACE_H
      6 
      7 #include <string>
      8 #include <list>
      9 
     10 #include "rectangle.h"
     11 #include "container.h"
     12 #include "client.h"
     13 
     14 // forward declaration
     15 class Frame;
     16 class Monitor;
     17 class Settings;
     18 class Thing;
     19 class Tree;
     20 class Workspace;
     21 class XCore;
     22 
     23 typedef list<Client *> LClient;
     24 typedef list<Frame *> LFrame;
     25 typedef Container<Monitor, LClient, LClient::iterator, Client> CClient;
     26 typedef Container<Monitor, LFrame, LFrame::iterator, Frame> CFrame;
     27 
     28 /**
     29  * Represents a workspace of WMI.
     30  */
     31 class Workspace :
     32       public Rectangle
     33 {
     34 
     35 public:
     36 
     37     Workspace(Monitor *monitor, unsigned int id, Rectangle *rect);
     38 
     39     ~Workspace();
     40 
     41     unsigned int id() const;
     42 
     43     /** Hides this workspace. */
     44     void hide();
     45 
     46     /** Shows this workspace. */
     47     void show();
     48 
     49     void illuminate();
     50 
     51     void setName(string name);
     52 
     53     string name() const;
     54 
     55     string prefix() const;
     56 
     57     Tree* root() const;
     58 
     59     bool isFrameMode() const;
     60 
     61     void toggleMode();
     62     void raiseFrames();
     63 
     64     /**
     65      * Attaches client to this workspace, if client->mode() is
     66      * <code>Client::MAX</code> and isChangeMode is <code>true</code>
     67      * this method will try to attach the client to the frame where the
     68      * center point of the client is located.
     69      */
     70     void attachClient(Client *client, bool isChangeMode = false);
     71     void detachClient(Client *client);
     72 
     73     /**
     74      * Splits the focused frame, if it has more than two clients
     75      * and attaches the focused client to it.
     76      */
     77     void splitFrame(Direction dir);
     78     void joinFrame(Direction dir);
     79     void sendClient(Direction dir);
     80 
     81     /**
     82      * Resize behavior for the focused frame.
     83      */
     84     void resizeFrame(Direction dir, bool grow);
     85 
     86     void resizeClient(Direction dir, bool grow);
     87 
     88     /** Focused client resize methods. */
     89     void moveClient(Direction dir);
     90 
     91     void selectFrame(Direction dir);
     92     void swapFrame(Direction dir);
     93     void swapClient(Direction dir);
     94 
     95     Thing *focusedThing();
     96     Frame *frameForPoint(unsigned int x, unsigned int y);
     97 
     98     void focus(Thing *thing, bool raise = true);
     99 
    100     Thing *thingWindow(Window window);
    101 
    102     void matchBarNeighbors(Direction dir);
    103 
    104     void raise();
    105     void lower();
    106 
    107     void toggleClientMode();
    108     void toggleClientSticky();
    109     void changeClientMode(Client *client, Client::Mode mode);
    110 
    111     void serialize();
    112 
    113     Tree *neighborTree(Direction dir);
    114 
    115     void toggleBars(bool visible);
    116     void toggleBorders(bool visible);
    117 
    118     void cycleClientNext();
    119     void cycleClientPrev();
    120 
    121     void removeClient(Client *client);
    122 
    123     /**
    124      * Used for differentiation of multiframes, each client has an
    125      * unique id.
    126      */
    127     unsigned int nextFrameId();
    128 
    129     void setClientBarVisible(bool visible);
    130     void setStatusBarVisible(bool visible);
    131 #ifdef SLOT_SUPPORT
    132     void setSlotVisible(bool visible);
    133     bool isSlotVisible() const;
    134     string slotTabName() const;
    135 #endif // SLOT_SUPPORT
    136 
    137     void resize(Thing *thing, Direction dir, bool grow);
    138 
    139     Client *topClient();
    140     void removePushClient(Client *client);
    141 
    142     void fitClient();
    143 
    144     bool isClientBarVisible() const;
    145     bool isStatusBarVisible() const;
    146 
    147     Frame *focusedFrame() const;
    148     Monitor *attached() const;
    149 
    150     LClient *clients();
    151     CClient *floatingClients();
    152     CFrame *frames();
    153 
    154     bool requestsFocus() const;
    155     void setRequestsFocus(bool requestsFocus);
    156     void destroyFrame(Frame *frame);
    157 
    158 private:
    159 
    160     Monitor *monitor_;
    161     void pushClient(Client *client);
    162     bool stackContainsClient(Client *client);
    163 
    164     Frame *nextFrame(Direction dir, bool isResize = true);
    165 
    166     /** Returns the recently visited frame in the given direction.  */
    167     Frame *recentVisitedFrame(Direction dir);
    168 
    169     /** Helper for resizing clients. */
    170 
    171     void attachFrame(Frame *frame, Direction dir = DOWN);
    172 
    173     /** Creates empty attached frame and returns it. */
    174     Frame *newFrame();
    175 
    176     LClient globalClientStack_;
    177     CClient floatingClients_;
    178     CFrame frames_;
    179     bool isFrameMode_;
    180     bool requestsFocus_;
    181     unsigned int id_;
    182     string name_;
    183     string prefix_;
    184 
    185     Tree *root_;
    186     unsigned int frameIds_;
    187 
    188     bool isClientBarVisible_;
    189     bool isStatusBarVisible_;
    190 #ifdef SLOT_SUPPORT
    191     string slotTabName_; // "" means not slot visible
    192 #endif // SLOT_SUPPORT
    193 };
    194 
    195 #endif // __WORKSPACE_H