news download themes documentation links










Screen.hh

00001 // Screen.hh for Fluxbox Window Manager
00002 // Copyright (c) 2001 - 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
00003 // 
00004 // Screen.hh for Blackbox - an X11 Window manager
00005 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
00006 //
00007 // Permission is hereby granted, free of charge, to any person obtaining a
00008 // copy of this software and associated documentation files (the "Software"),
00009 // to deal in the Software without restriction, including without limitation
00010 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011 // and/or sell copies of the Software, and to permit persons to whom the
00012 // Software is furnished to do so, subject to the following conditions:
00013 //
00014 // The above copyright notice and this permission notice shall be included in
00015 // all copies or substantial portions of the Software.
00016 //
00017 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00020 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00022 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00023 // DEALINGS IN THE SOFTWARE.
00024 
00025 // $Id: Screen.hh,v 1.132 2004/01/11 16:05:55 fluxgen Exp $
00026 
00027 #ifndef  SCREEN_HH
00028 #define  SCREEN_HH
00029 
00030 
00031 #include "FbRootWindow.hh"
00032 #include "MenuTheme.hh"
00033 
00034 #include "FbTk/Resource.hh"
00035 #include "FbTk/Subject.hh"
00036 #include "FbTk/MultLayers.hh"
00037 #include "FbTk/NotCopyable.hh"
00038 #include "FbTk/Observer.hh"
00039 
00040 #include <X11/Xlib.h>
00041 #include <X11/Xresource.h>
00042 
00043 #include <cstdio>
00044 #include <string>
00045 #include <list>
00046 #include <vector>
00047 #include <fstream>
00048 #include <memory>
00049 #include <map>
00050 
00051 class FluxboxWindow;
00052 class Netizen;
00053 class FbWinFrameTheme;
00054 class RootTheme;
00055 class WinButtonTheme;
00056 class WinClient;
00057 class Workspace;
00058 class Strut;
00059 class Slit;
00060 
00061 namespace FbTk {
00062 class Menu;
00063 class ImageControl;
00064 class XLayerItem;
00065 class FbWindow;
00066 class Subject;
00067 }
00068 
00070 
00073 class BScreen : public FbTk::Observer, private FbTk::NotCopyable {
00074 public:
00075     enum FocusModel { SLOPPYFOCUS=0, SEMISLOPPYFOCUS, CLICKTOFOCUS };
00076     enum FocusDir { FOCUSUP, FOCUSDOWN, FOCUSLEFT, FOCUSRIGHT };
00077     enum PlacementPolicy { ROWSMARTPLACEMENT, COLSMARTPLACEMENT, CASCADEPLACEMENT, UNDERMOUSEPLACEMENT};
00078     enum RowDirection { LEFTRIGHT, RIGHTLEFT};
00079     enum ColumnDirection { TOPBOTTOM, BOTTOMTOP};
00080 
00081     typedef std::vector<FluxboxWindow *> Icons;
00082     typedef std::list<WinClient *> FocusedWindows;
00083     typedef std::vector<Workspace *> Workspaces;
00084     typedef std::vector<std::string> WorkspaceNames;
00085 
00086     BScreen(FbTk::ResourceManager &rm,
00087             const std::string &screenname, const std::string &altscreenname,
00088             int scrn, int number_of_layers);
00089     ~BScreen();
00090 
00091     inline bool isSloppyFocus() const { return (*resource.focus_model == SLOPPYFOCUS); }
00092     inline bool isSemiSloppyFocus() const { return (*resource.focus_model == SEMISLOPPYFOCUS); }
00093     inline bool isRootColormapInstalled() const { return root_colormap_installed; }
00094     inline bool isScreenManaged() const { return managed; }
00095     inline bool isSloppyWindowGrouping() const { return *resource.sloppy_window_grouping; }
00096     inline bool isWorkspaceWarping() const { return *resource.workspace_warping; }
00097     inline bool isDesktopWheeling() const { return *resource.desktop_wheeling; }
00098     inline bool doAutoRaise() const { return *resource.auto_raise; }
00099     inline bool clickRaises() const { return *resource.click_raises; }
00100     inline bool doOpaqueMove() const { return *resource.opaque_move; }
00101     inline bool doFullMax() const { return *resource.full_max; }
00102     inline bool doFocusNew() const { return *resource.focus_new; }
00103     inline bool doFocusLast() const { return *resource.focus_last; }
00104     inline bool doShowWindowPos() const { return *resource.show_window_pos; }
00105     inline bool antialias() const { return *resource.antialias; }
00106 
00107     inline FbTk::ImageControl &imageControl() { return *m_image_control.get(); }
00108     const FbTk::Menu &getRootmenu() const { return *m_rootmenu.get(); }
00109     FbTk::Menu &getRootmenu() { return *m_rootmenu.get(); }
00110     
00111     inline const std::string &getRootCommand() const { return *resource.rootcommand; }
00112     inline const std::string &getResizeMode()  const { return *resource.resizemode; }
00113     inline FocusModel getFocusModel() const { return *resource.focus_model; }
00114 
00115     inline Slit *slit() { return m_slit.get(); }
00116     inline const Slit *slit() const { return m_slit.get(); }
00117 
00118     inline Workspace *getWorkspace(unsigned int w) { return ( w < m_workspaces_list.size() ? m_workspaces_list[w] : 0); }
00119     inline Workspace *currentWorkspace() { return m_current_workspace; }
00120     inline const Workspace *currentWorkspace() const { return m_current_workspace; }
00121 
00122     const FbTk::Menu &getWorkspacemenu() const { return *workspacemenu.get(); }
00123     FbTk::Menu &getWorkspacemenu() { return *workspacemenu.get(); }
00124 
00125 
00126 
00127     unsigned int currentWorkspaceID() const;
00128     Pixmap rootPixmap() const;
00129     /*
00130       maximum screen bounds for given window
00131     */
00132     unsigned int maxLeft(int head) const;
00133     unsigned int maxRight(int head) const;
00134     unsigned int maxTop(int head) const;
00135     unsigned int maxBottom(int head) const;
00136 
00137     inline unsigned int width() const { return rootWindow().width(); }
00138     inline unsigned int height() const { return rootWindow().height(); }
00139     inline unsigned int screenNumber() const { return rootWindow().screenNumber(); }
00140 
00142     inline unsigned int getCount() const { return m_workspaces_list.size(); }
00144     inline unsigned int getIconCount() const { return m_icon_list.size(); }
00145     inline const Icons &getIconList() const { return m_icon_list; }
00146     inline Icons &getIconList() { return m_icon_list; }
00147     inline const FocusedWindows &getFocusedList() const { return focused_list; }
00148     inline FocusedWindows &getFocusedList() { return focused_list; }
00149     WinClient *getLastFocusedWindow(int workspace = -1);
00150     const Workspaces &getWorkspacesList() const { return m_workspaces_list; }
00151     Workspaces &getWorkspacesList() { return m_workspaces_list; }
00152     const WorkspaceNames &getWorkspaceNames() const { return m_workspace_names; }
00157 
00158     FbTk::Subject &clientListSig() { return m_clientlist_sig; } 
00160     FbTk::Subject &iconListSig() { return m_iconlist_sig; }
00162     FbTk::Subject &workspaceCountSig() { return m_workspacecount_sig; }
00164     FbTk::Subject &workspaceNamesSig() { return m_workspacenames_sig; }
00166     FbTk::Subject &currentWorkspaceSig() { return m_currentworkspace_sig; }
00168     FbTk::Subject &reconfigureSig() { return m_reconfigure_sig; }
00169     FbTk::Subject &resizeSig() { return m_resize_sig; }
00171 
00172     void update(FbTk::Subject *subj);
00173 
00174     FbTk::Menu *createMenu(const std::string &label);
00175     void hideMenus();
00176 
00178     inline int getNumberOfWorkspaces() const { return *resource.workspaces; }   
00179 
00180     inline PlacementPolicy getPlacementPolicy() const { return *resource.placement_policy; }
00181     inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; }
00182     inline RowDirection getRowPlacementDirection() const { return *resource.row_direction; }
00183     inline ColumnDirection getColPlacementDirection() const { return *resource.col_direction; }
00184 
00185     inline void setRootColormapInstalled(bool r) { root_colormap_installed = r;  }
00186     inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd;  }
00187     inline void saveFocusModel(FocusModel model) { resource.focus_model = model; }
00188     inline void saveWorkspaces(int w) { *resource.workspaces = w;  }
00189 
00190 
00191     void setAntialias(bool value);
00192 
00193     inline FbWinFrameTheme &winFrameTheme() { return *m_windowtheme.get(); }
00194     inline const FbWinFrameTheme &winFrameTheme() const { return *m_windowtheme.get(); }
00195     inline MenuTheme &menuTheme() { return *m_menutheme.get(); }
00196     inline const MenuTheme &menuTheme() const { return *m_menutheme.get(); }
00197     inline const RootTheme &rootTheme() const { return *m_root_theme.get(); }
00198     inline WinButtonTheme &winButtonTheme() { return *m_winbutton_theme.get(); }
00199     inline const WinButtonTheme &winButtonTheme() const { return *m_winbutton_theme.get(); }
00200 
00201     inline FbRootWindow &rootWindow() { return m_root_window; }
00202     inline const FbRootWindow &rootWindow() const { return m_root_window; }
00203 
00204     inline FbTk::MultLayers &layerManager() { return m_layermanager; }
00205     inline const FbTk::MultLayers &layerManager() const { return m_layermanager; }
00206     inline FbTk::ResourceManager &resourceManager() { return m_resource_manager; }
00207     inline const FbTk::ResourceManager &resourceManager() const { return m_resource_manager; }
00208     inline const std::string &name() const { return m_name; }
00209     inline const std::string &altName() const { return m_altname; }
00210     inline bool isShuttingdown() const { return m_shutdown; }
00211 
00212 
00213     int addWorkspace();
00214     int removeLastWorkspace();
00215     // scroll workspaces
00216     inline void nextWorkspace() { nextWorkspace(1); }
00217     inline void prevWorkspace() { prevWorkspace(1); }
00218     void nextWorkspace(int delta);
00219     void prevWorkspace(int delta);
00220     void rightWorkspace(int delta);
00221     void leftWorkspace(int delta);
00222 
00223     void removeWorkspaceNames();
00224     void updateWorkspaceNamesAtom();
00225     
00226     void addWorkspaceName(const char *name);
00227     void addNetizen(Window win);
00228     void removeNetizen(Window win);
00229     void addIcon(FluxboxWindow *win);
00230     void removeIcon(FluxboxWindow *win);
00231     // remove window
00232     void removeWindow(FluxboxWindow *win);
00233     void removeClient(WinClient &client);
00234 
00235     std::string getNameOfWorkspace(unsigned int workspace) const;
00236     void changeWorkspaceID(unsigned int);
00237     void sendToWorkspace(unsigned int workspace, FluxboxWindow *win=0, 
00238                          bool changeworkspace=true);
00239     void reassociateWindow(FluxboxWindow *window, unsigned int workspace_id, 
00240                            bool ignore_sticky);
00241     inline void prevFocus() { prevFocus(0); }
00242     inline void nextFocus() { nextFocus(0); }
00243     void prevFocus(int options);
00244     void nextFocus(int options);
00245     void raiseFocus();
00246     void setFocusedWindow(WinClient &winclient);
00247 
00248 
00249     void dirFocus(FluxboxWindow &win, FocusDir dir);
00250 
00251     void reconfigure(); 
00252     void rereadMenu();
00253     void shutdown();
00255     void showPosition(int x, int y);
00257     void showGeometry(unsigned int width, unsigned int height);
00258     void hideGeometry();
00259 
00260     void notifyReleasedKeys(XKeyEvent &ke);
00261 
00262     void setLayer(FbTk::XLayerItem &item, int layernum);
00263     // remove? no, items are never removed from their layer until they die
00264 
00268     void updateSize();
00269 
00270     // Xinerama-related functions
00271     inline bool hasXinerama() const { return m_xinerama_avail; }
00272     inline int numHeads() const { return m_xinerama_num_heads; }
00273 
00274     void initXinerama();
00275 
00276     int getHead(int x, int y) const;
00277     int getHead(FbTk::FbWindow &win) const;
00278     int getCurrHead() const;
00279     int getHeadX(int head) const;
00280     int getHeadY(int head) const;
00281     int getHeadWidth(int head) const;
00282     int getHeadHeight(int head) const;
00283 
00284     // magic to allow us to have "on head" placement (menu) without
00285     // the object really knowing about it.
00286     template <typename OnHeadObject>
00287     int getOnHead(OnHeadObject &obj);
00288 
00289     template <typename OnHeadObject>
00290     void setOnHead(OnHeadObject &obj, int head);
00291 
00292     // grouping - we want ordering, so we can either search for a 
00293     // group to the left, or to the right (they'll be different if
00294     // they exist).
00295     FluxboxWindow *findGroupLeft(WinClient &winclient);
00296     FluxboxWindow *findGroupRight(WinClient &winclient);
00297 
00298     // notify netizens
00299     void updateNetizenCurrentWorkspace();
00300     void updateNetizenWorkspaceCount();
00301     void updateNetizenWindowFocus();
00302     void updateNetizenWindowAdd(Window, unsigned long);
00303     void updateNetizenWindowDel(Window);
00304     void updateNetizenConfigNotify(XEvent &ev);
00305     void updateNetizenWindowRaise(Window);
00306     void updateNetizenWindowLower(Window);
00307 
00309     FluxboxWindow *createWindow(Window clientwin);
00310     FluxboxWindow *createWindow(WinClient &client);
00311     void setupWindowActions(FluxboxWindow &win);
00313     Strut *requestStrut(int left, int right, int top, int bottom);
00315     void clearStrut(Strut *strut); 
00317     void updateAvailableWorkspaceArea();
00318 
00319     // for extras to add menus. These menus must be marked
00320     // internal for their safety, and __the extension__ must
00321     // delete and remove the menu itself (opposite to Window)
00322     void addConfigMenu(const char *label, FbTk::Menu &menu);
00323     void removeConfigMenu(FbTk::Menu &menu);
00324 
00325 
00326 
00327 
00328 
00329 
00330     // prevFocus/nextFocus option bits
00331     enum { CYCLEGROUPS = 0x01, CYCLESKIPSTUCK = 0x02, CYCLESKIPSHADED = 0x04,
00332            CYCLELINEAR = 0x08, CYCLEDEFAULT = 0x00 };
00333 
00334     class ScreenSubject:public FbTk::Subject {
00335     public:
00336         ScreenSubject(BScreen &scr):m_scr(scr) { }
00337         const BScreen &screen() const { return m_scr; }
00338         BScreen &screen() { return m_scr; }
00339     private:
00340         BScreen &m_scr;
00341     };
00342 
00343 private:
00344     void setupConfigmenu(FbTk::Menu &menu);
00345     void createStyleMenu(FbTk::Menu &menu, const char *label, const char *directory);
00346 
00347     bool parseMenuFile(std::ifstream &filestream, FbTk::Menu &menu, int &row);
00348 
00349     void initMenu();
00350 
00351     bool doSkipWindow(const WinClient &winclient, int options);
00352 
00353     void renderGeomWindow();
00354     void updateIconMenu();
00355 
00356     ScreenSubject 
00357     m_clientlist_sig,  
00358         m_iconlist_sig, 
00359         m_workspacecount_sig, 
00360         m_workspacenames_sig, 
00361         m_currentworkspace_sig, 
00362         m_reconfigure_sig, 
00363         m_resize_sig; 
00364         
00365     FbTk::MultLayers m_layermanager;
00366     
00367     bool root_colormap_installed, managed, geom_visible, cycling_focus;
00368     GC opGC;
00369     Pixmap geom_pixmap;
00370 
00371     FbTk::FbWindow m_geom_window;
00372 
00373     std::auto_ptr<FbTk::ImageControl> m_image_control;
00374     std::auto_ptr<FbTk::Menu> m_configmenu;
00375 
00376     std::auto_ptr<FbTk::Menu> m_rootmenu;
00377 
00378     typedef std::list<FbTk::Menu *> Rootmenus;
00379     typedef std::list<Netizen *> Netizens;
00380     typedef std::list<std::pair<const char *, FbTk::Menu *> > Configmenus;
00381 
00382 
00383     Rootmenus m_rootmenu_list;
00384     Netizens m_netizen_list;
00385     Configmenus m_configmenu_list;
00386     Icons m_icon_list;
00387 
00388     // This list keeps the order of window focusing for this screen
00389     // Screen global so it works for sticky windows too.
00390     FocusedWindows focused_list;
00391     FocusedWindows::iterator cycling_window;
00392     WinClient *cycling_last;
00393 
00394     std::auto_ptr<Slit> m_slit;
00395 
00396     Workspace *m_current_workspace;
00397     std::auto_ptr<FbTk::Menu> workspacemenu;
00398     std::auto_ptr<FbTk::Menu> m_iconmenu;
00399 
00400     WorkspaceNames m_workspace_names;
00401     Workspaces m_workspaces_list;
00402 
00403     std::auto_ptr<FbWinFrameTheme> m_windowtheme;
00404     std::auto_ptr<WinButtonTheme> m_winbutton_theme;
00405     std::auto_ptr<MenuTheme> m_menutheme;
00406     std::auto_ptr<RootTheme> m_root_theme;
00407 
00408     FbRootWindow m_root_window;
00409 
00410     struct ScreenResource {
00411         ScreenResource(FbTk::ResourceManager &rm, const std::string &scrname,
00412                        const std::string &altscrname);
00413 
00414         FbTk::Resource<bool> image_dither, opaque_move, full_max,
00415             sloppy_window_grouping, workspace_warping,
00416             desktop_wheeling, show_window_pos,
00417             focus_last, focus_new,
00418             antialias, auto_raise, click_raises;
00419         FbTk::Resource<std::string> rootcommand;        
00420         FbTk::Resource<std::string> resizemode;
00421         FbTk::Resource<FocusModel> focus_model;
00422         bool ordered_dither;
00423         FbTk::Resource<int> workspaces, edge_snap_threshold, menu_alpha, menu_delay, menu_delay_close;
00424         FbTk::Resource<FbTk::MenuTheme::MenuMode> menu_mode;
00425         FbTk::Resource<PlacementPolicy> placement_policy;
00426         FbTk::Resource<RowDirection> row_direction;
00427         FbTk::Resource<ColumnDirection> col_direction;
00428 
00429     } resource;
00430 
00431     // This is a map of windows to clients for clients that had a left
00432     // window set, but that window wasn't present at the time
00433     typedef std::map<Window, WinClient *> Groupables;
00434     Groupables m_expecting_groups;
00435 
00436     const std::string m_name, m_altname;
00437     FbTk::ResourceManager &m_resource_manager;
00438 
00439     bool m_xinerama_avail;
00440     int m_xinerama_num_heads;
00441 
00442     // Xinerama related private data
00443    
00444     int m_xinerama_center_x, m_xinerama_center_y;
00445 
00446     std::auto_ptr<Strut> m_available_workspace_area;
00447 
00448     struct XineramaHeadInfo {
00449         int x, y, width, height;        
00450     } *m_xinerama_headinfo;
00451 
00452     std::list<Strut *> m_strutlist;
00453     bool m_shutdown;
00454 };
00455 
00456 
00457 #endif // SCREEN_HH

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA