From cb7cfbf152bd7538abc41956409498a23857b560 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 5 Jan 2003 22:20:46 +0000 Subject: huge commit, changed FluxboxWindow to a EventHandler and it now holds a FbWinFrame, added dieSig --- src/Window.hh | 332 +++++++++++++++++++++++++++------------------------------- 1 file changed, 156 insertions(+), 176 deletions(-) diff --git a/src/Window.hh b/src/Window.hh index 4c9829c..65cc2e6 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -1,5 +1,5 @@ // Window.hh for Fluxbox Window Manager -// Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen at users.sourceforge.net) +// Copyright (c) 2001-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) // // Window.hh for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) @@ -16,13 +16,13 @@ // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.39 2002/12/13 20:35:36 fluxgen Exp $ +// $Id: Window.hh,v 1.40 2003/01/05 22:20:46 fluxgen Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -31,6 +31,8 @@ #include "Timer.hh" #include "Windowmenu.hh" #include "Subject.hh" +#include "FbWinFrame.hh" +#include "EventHandler.hh" #include #include @@ -46,10 +48,11 @@ #define PropMwmHintsElements 3 class Tab; +class FbWinFrameTheme; /// Creates the window frame and handles any window event for it -class FluxboxWindow : public TimeoutHandler { +class FluxboxWindow : public TimeoutHandler, public FbTk::EventHandler { public: /// layer bits enum WinLayer { @@ -58,6 +61,7 @@ public: LAYER_NORMAL = 0x04, ///< normal layer LAYER_TOP = 0x08 ///< top layer }; + /// decoration bit enum Decoration { DECOR_NONE=0, ///< no decor at all @@ -81,6 +85,7 @@ public: MwmFuncMaximize = (1l << 4), ///< maximize MwmFuncClose = (1l << 5) ///< close }; + /// Motif wm decorations enum MwmDecor { MwmDecorAll = (1l << 0), /// all decorations @@ -91,16 +96,86 @@ public: MwmDecorIconify = (1l << 5), /// iconify MwmDecorMaximize = (1l << 6) /// maximize }; + /// create fluxbox window with parent win and screen connection - explicit FluxboxWindow(Window win, BScreen *scr = 0); + FluxboxWindow(Window win, BScreen *scr, int screen_num, BImageControl &imgctrl, FbWinFrameTheme &tm); virtual ~FluxboxWindow(); + + + void setWindowNumber(int n) { window_number = n; } + + bool validateClient(); + bool setInputFocus(); + void setTab(bool flag); + void setFocusFlag(bool flag); + void iconify(); + void deiconify(bool = true, bool = true); + /// destroy this window + void close(); + /// set the window in withdrawn state + void withdraw(); + /// toggel maximize + void maximize(); + /// maximizes the window horizontal + void maximizeHorizontal(); + /// maximizes the window vertical + void maximizeVertical(); + /// toggles shade + void shade(); + /// toggles sticky + void stick(); + void lower(); + void raise(); + + void reconfigure(); + void installColormap(bool); + void restore(bool remap); + /// move frame to x, y + void move(int x, int y); + /// resize frame to width, height + void resize(unsigned int width, unsigned int height); + /// move and resize frame to pox x,y and size width, height + void moveResize(int x, int y, unsigned int width, unsigned int height); + + void setWorkspace(int n); + void changeBlackboxHints(const BaseDisplay::BlackboxHints &bh); + void restoreAttributes(); + void showMenu(int mx, int my); + void pauseMoving(); + void resumeMoving(); + /** + @name event handlers + */ + //@{ + void handleEvent(XEvent &event); + void buttonPressEvent(XButtonEvent &be); + void buttonReleaseEvent(XButtonEvent &be); + void motionNotifyEvent(XMotionEvent &me); + void destroyNotifyEvent(XDestroyWindowEvent &dwe); + void mapRequestEvent(XMapRequestEvent &mre); + void mapNotifyEvent(XMapEvent &mapev); + void unmapNotifyEvent(XUnmapEvent &unmapev); + void exposeEvent(XExposeEvent &ee); + void configureRequestEvent(XConfigureRequestEvent &ce); + void propertyNotifyEvent(Atom a); + //@} + + void setDecoration(Decoration decoration); + void toggleDecoration(); + +#ifdef SHAPE + void shapeEvent(XShapeEvent *event); +#endif // SHAPE + + virtual void timeout(); + /** @name accessors */ //@{ bool isTransient() const { return ((client.transient_for) ? true : false); } bool hasTransient() const { return ((client.transients.size()) ? true : false); } - bool isManaged() const { return managed; } + bool isManaged() const { return m_managed; } bool isFocused() const { return focused; } bool isVisible() const { return visible; } bool isIconic() const { return iconic; } @@ -116,41 +191,50 @@ public: bool isMoving() const { return moving; } bool isResizing() const { return resizing; } bool isGroupable() const; + const BScreen *getScreen() const { return screen; } BScreen *getScreen() { return screen; } + const Tab *getTab() const { return tab; } Tab *getTab() { return tab; } + const std::list &getTransients() const { return client.transients; } std::list &getTransients() { return client.transients; } + const FluxboxWindow *getTransientFor() const { return client.transient_for; } FluxboxWindow *getTransientFor() { return client.transient_for; } - const Window &getFrameWindow() const { return frame.window; } - const Window &getClientWindow() const { return client.window; } + Window getFrameWindow() const { return m_frame.window().window(); } + Window getClientWindow() const { return client.window; } Windowmenu *getWindowmenu() { return m_windowmenu.get(); } const Windowmenu *getWindowmenu() const { return m_windowmenu.get(); } const std::string &getTitle() const { return client.title; } const std::string &getIconTitle() const { return client.icon_title; } - int getXFrame() const { return frame.x; } - int getYFrame() const { return frame.y; } + int getXFrame() const { return m_frame.x(); } + int getYFrame() const { return m_frame.y(); } int getXClient() const { return client.x; } int getYClient() const { return client.y; } unsigned int getWorkspaceNumber() const { return workspace_number; } int getWindowNumber() const { return window_number; } WinLayer getLayer() const { return m_layer; } - unsigned int getWidth() const { return frame.width; } - unsigned int getHeight() const { return frame.height; } + unsigned int getWidth() const { return m_frame.width(); } + unsigned int getHeight() const { return m_frame.height(); } unsigned int getClientHeight() const { return client.height; } unsigned int getClientWidth() const { return client.width; } - unsigned int getTitleHeight() const { return frame.title_h; } + unsigned int getTitleHeight() const { return m_frame.titleHeight(); } const std::string &className() const { return m_class_name; } const std::string &instanceName() const { return m_instance_name; } bool isLowerTab() const; + int initialState() const { return client.initial_state; } + + FbWinFrame &frame() { return m_frame; } + const FbWinFrame &frame() const { return m_frame; } + /** @name signals - @{ + @{ */ FbTk::Subject &stateSig() { return m_statesig; } const FbTk::Subject &stateSig() const { return m_statesig; } @@ -158,70 +242,14 @@ public: const FbTk::Subject &hintSig() const { return m_hintsig; } FbTk::Subject &workspaceSig() { return m_workspacesig; } const FbTk::Subject &workspaceSig() const { return m_workspacesig; } + FbTk::Subject &dieSig() { return m_diesig; } + const FbTk::Subject &dieSig() const { return m_diesig; } /** @} */ // end group signals - //@} - - void setWindowNumber(int n) { window_number = n; } - const timeval &getLastFocusTime() const {return lastFocusTime;} - bool validateClient(); - bool setInputFocus(); - void setTab(bool flag); - void setFocusFlag(bool flag); - void iconify(); - void deiconify(bool = true, bool = true); - void close(); - void withdraw(); - void maximize(unsigned int); - /// toggles shade - void shade(); - /// toggles sticky - void stick(); - void reconfigure(); - void installColormap(bool); - void restore(bool remap); - void configure(int dx, int dy, unsigned int dw, unsigned int dh); - void setWorkspace(int n); - void changeBlackboxHints(BaseDisplay::BlackboxHints *bh); - void restoreAttributes(); - void showMenu(int mx, int my); - void pauseMoving(); - void resumeMoving(); - /** - @name event handlers - */ - //@{ - void buttonPressEvent(XButtonEvent *be); - void buttonReleaseEvent(XButtonEvent *be); - void motionNotifyEvent(XMotionEvent *me); - bool destroyNotifyEvent(XDestroyWindowEvent *dwe); - void mapRequestEvent(XMapRequestEvent *mre); - void mapNotifyEvent(XMapEvent *mapev); - bool unmapNotifyEvent(XUnmapEvent *unmapev); - void propertyNotifyEvent(Atom a); - void exposeEvent(XExposeEvent *ee); - void configureRequestEvent(XConfigureRequestEvent *ce); //@} - - void setDecoration(Decoration decoration); - void toggleDecoration(); - -#ifdef SHAPE - void shapeEvent(XShapeEvent *); -#endif // SHAPE - - virtual void timeout(); - // this structure only contains 3 elements... the Motif 2.0 structure contains - // 5... we only need the first 3... so that is all we will define - typedef struct MwmHints { - unsigned long flags; // Motif wm flags - unsigned long functions; // Motif wm functions - unsigned long decorations; // Motif wm decorations - } MwmHints; - class WinSubject: public FbTk::Subject { public: WinSubject(FluxboxWindow &w):m_win(w) { } @@ -232,27 +260,73 @@ public: }; private: + // this structure only contains 3 elements... the Motif 2.0 structure contains + // 5... we only need the first 3... so that is all we will define + typedef struct MwmHints { + unsigned long flags; // Motif wm flags + unsigned long functions; // Motif wm functions + unsigned long decorations; // Motif wm decorations + } MwmHints; + + void grabButtons(); + + void startMoving(Window win); + void stopMoving(); + void startResizing(Window win, int x, int y, bool left); + void stopResizing(Window win=0); + void updateIcon(); + + void updateTransientInfo(); + + bool getState(); + /// gets title string from client window and updates frame's title + void updateTitleFromClient(); + /// gets icon name from client window + void updateIconNameFromClient(); + void getWMNormalHints(); + void getWMProtocols(); + void getWMHints(); + void getMWMHints(); + void getBlackboxHints(); + void setNetWMAttributes(); + void associateClientWindow(); + void createWinButtons(); + void decorateLabel(); + void positionWindows(); + + void restoreGravity(); + void setGravityOffsets(); + void setState(unsigned long stateval); + void upsize(); + void downsize(); + void right_fixsize(int *x = 0, int *y = 0); + void left_fixsize(int *x = 0, int *y = 0); + // state and hint signals - WinSubject m_hintsig, m_statesig, m_workspacesig; + WinSubject m_hintsig, m_statesig, m_workspacesig, m_diesig; - BImageControl *image_ctrl; /// image control for rendering + // BImageControl &image_ctrl; /// image control for rendering std::string m_instance_name; /// instance name from WM_CLASS std::string m_class_name; /// class name from WM_CLASS //Window state bool moving, resizing, shaded, maximized, visible, iconic, transient, - focused, stuck, modal, send_focus_message, managed; + focused, stuck, modal, send_focus_message, m_managed; BScreen *screen; /// screen on which this window exist BTimer timer; - Display *display; /// display connection (obsolete by BaseDisplay singleton) + Display *display; /// display connection (obsolete by FbTk) BaseDisplay::BlackboxAttributes blackbox_attrib; Time lastButtonPressTime; std::auto_ptr m_windowmenu; timeval lastFocusTime; + + int button_grab_x, button_grab_y; // handles last button press event for move + int last_resize_x, last_resize_y; // handles last button press event for resize + unsigned int last_resize_h, last_resize_w; // handles height/width for resize "window" int focus_mode, window_number; unsigned int workspace_number; @@ -291,109 +365,15 @@ private: Tab *tab; friend class Tab; //TODO: Don't like long distant friendship - typedef void (*ButtonDrawProc)(FluxboxWindow *, Window, bool); - typedef void (*ButtonEventProc)(FluxboxWindow *, XButtonEvent *); - - struct Button { - int type; - Window win; - bool used; - ButtonEventProc pressed; - ButtonEventProc released; - ButtonDrawProc draw; - }; - - std::vector