"Fossies" - the Fresh Open Source Software Archive

Member "bbkeys-0.9.1/src/window.hh" (6 Dec 2007, 5197 Bytes) of package /linux/privat/old/bbkeys-0.9.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "window.hh" see the Fossies "Dox" file reference documentation.

    1 // -*- mode: C++; indent-tabs-mode: nil; -*-
    2 // window.hh for Epistrophy - a key handler for NETWM/EWMH window managers.
    3 // Copyright (c) 2002 - 2002 Ben Jansens <ben at orodu.net>
    4 //
    5 // Modified for use and inclusion in bbkeys by Jason 'vanRijn' Kasper
    6 //
    7 // Permission is hereby granted, free of charge, to any person obtaining a
    8 // copy of this software and associated documentation files (the "Software"),
    9 // to deal in the Software without restriction, including without limitation
   10 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
   11 // and/or sell copies of the Software, and to permit persons to whom the
   12 // Software is furnished to do so, subject to the following conditions:
   13 //
   14 // The above copyright notice and this permission notice shall be included in
   15 // all copies or substantial portions of the Software.
   16 //
   17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   23 // DEALINGS IN THE SOFTWARE.
   24 
   25 #ifndef   __window_hh
   26 #define   __window_hh
   27 
   28 extern "C" {
   29 #include <X11/Xlib.h>
   30 #include <X11/Xutil.h>
   31 }
   32 
   33 #include <list>
   34 #include <string>
   35 
   36 // blackbox lib....
   37 #include "Application.hh"
   38 #include "Util.hh"
   39 #include "Display.hh"
   40 #include "EventHandler.hh"
   41 
   42 #include "Netclient.h"
   43 #include "version.h"
   44 
   45 class XWindow : public bt::EventHandler {
   46 public:
   47   enum Max {
   48     Max_None,
   49     Max_Horz,
   50     Max_Vert,
   51     Max_Full
   52   };
   53 
   54 private:
   55   // defined by black/openbox
   56   static const unsigned long PropBlackboxAttributesElements = 9;
   57   static const unsigned long AttribDecoration = 1 << 6;
   58   static const unsigned long DecorNone = 0;
   59   static const unsigned long DecorNormal = 2;
   60 
   61   Window _window;
   62   Display * _display;
   63   Window _root;
   64   Netclient * _netclient;
   65   const bt::ScreenInfo & _screenInfo;
   66   bt::Application & _app;
   67 
   68   unsigned int _desktop;
   69   bt::ustring _title;
   70   std::string _app_name;
   71   std::string _app_class;
   72   bt::Rect _rect;
   73   int _inc_x, _inc_y; // resize increments
   74   int _base_x, _base_y; // base size
   75   int _gravity;
   76   bool _can_focus;
   77 
   78   // states
   79   bool _shaded;
   80   bool _iconic;
   81   bool _skip_pager;
   82   bool _max_vert;
   83   bool _max_horz;
   84   bool _decorated;
   85 
   86   bool _unmapped;
   87 
   88   void updateDimensions();
   89   void updateDimensions(const XConfigureEvent * const e);
   90   void updateBlackboxAttributes();
   91   void updateNormalHints();
   92   void updateWMHints();
   93   void updateState();
   94   void updateDesktop();
   95   void updateTitle();
   96   void updateClass();
   97   void updateMotifHints();
   98 
   99   // EventHandler methods....
  100   
  101   // Window configure (size, position, stacking, etc.).
  102   void configureNotifyEvent(const XConfigureEvent * const e);
  103 
  104   // Window property changed/added/deleted.
  105   void propertyNotifyEvent(const XPropertyEvent * const e);
  106 
  107   // Window hidden.
  108   void unmapNotifyEvent(const XUnmapEvent * const e);
  109 
  110   // Window destroyed.
  111   void destroyNotifyEvent(const XDestroyWindowEvent * const e);
  112 
  113 public:
  114   XWindow(Window window, Netclient * netclient, 
  115           const bt::ScreenInfo & screenInfo, bt::Application & app);
  116   virtual ~XWindow();
  117 
  118   inline unsigned int getScreenNumber() const { return _screenInfo.screenNumber(); }
  119   inline Window window() const { return _window; }
  120   
  121   inline unsigned int desktop() const { return _desktop; }
  122   inline const bt::ustring &title() const { return _title; }
  123   inline const std::string &appName() const { return _app_name; }
  124   inline const std::string &appClass() const { return _app_class; }
  125   inline bool canFocus() const { return _can_focus; }
  126   inline bool isSticky() const { return 0xFFFFFFFF == _desktop; }
  127   
  128   inline bool shaded() const { return _shaded; }
  129   inline bool iconic() const { return _iconic; }
  130   inline bool skipPager() const { return _skip_pager; }
  131   inline bool maxVert() const { return _max_vert; }
  132   inline bool maxHorz() const { return _max_horz; }
  133   inline bool decorated() const { return _decorated; }
  134   inline const bt::Rect &area() const { return _rect; }
  135   inline unsigned int x() const { return _rect.x(); }
  136   inline unsigned int y() const { return _rect.y(); }
  137   inline unsigned int width() const { return _rect.width(); }
  138   inline unsigned int height() const { return _rect.height(); }
  139 
  140   void shade(const bool sh) const;
  141   void close() const;
  142   void raise() const;
  143   void lower() const;
  144   void iconify() const;
  145   void focus(bool raise = true) const;
  146   void decorate(bool d) const;
  147   void sendTo(unsigned int dest) const;
  148   void move(int x, int y) const;
  149   void resizeRel(int dwidth, int dheight) const;
  150   void resizeAbs(unsigned int width, unsigned int height) const;
  151   void toggleMaximize(Max max) const; // i hate toggle functions
  152   void maximize(Max max) const;
  153 
  154   bool operator == (const XWindow &w) const { return w._window == _window; }
  155   bool operator == (const Window &w) const { return w == _window; }
  156 };
  157 
  158 typedef std::list<XWindow *> WindowList;
  159 
  160 #endif // __window_hh