--- /dev/null
+// -*- mode: C++; indent-tabs-mode: nil; -*-
+// Basemenu.hh for Blackbox - an X11 Window manager
+// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
+// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// 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
+// 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.
+
+#ifndef __Basemenu_hh
+#define __Basemenu_hh
+
+extern "C" {
+#include <X11/Xlib.h>
+}
+
+#include <string>
+#include <deque>
+
+class Blackbox;
+class BImageControl;
+class BScreen;
+class Basemenu;
+class BasemenuItem;
+
+
+class Basemenu {
+private:
+ typedef std::deque<BasemenuItem*> MenuItems;
+ MenuItems menuitems;
+ Blackbox *blackbox;
+ Basemenu *parent;
+ BImageControl *image_ctrl;
+ BScreen *screen;
+
+ bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
+ hide_tree;
+ Display *display;
+ int which_sub, which_press, which_sbl, alignment;
+
+ struct _menu {
+ Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
+ Window window, frame, title;
+
+ std::string label;
+ int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
+ grab_x, grab_y;
+ unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w,
+ bevel_h;
+ } menu;
+
+ Basemenu(const Basemenu&);
+ Basemenu& operator=(const Basemenu&);
+
+protected:
+ BasemenuItem *find(int index);
+ inline void setTitleVisibility(bool b) { title_vis = b; }
+ inline void setMovable(bool b) { movable = b; }
+ inline void setHideTree(bool h) { hide_tree = h; }
+ inline void setMinimumSublevels(int m) { menu.minsub = m; }
+
+ virtual void itemSelected(int button, unsigned int index) = 0;
+ virtual void drawItem(int index, bool highlight = False, bool clear = False,
+ int x = -1, int y = -1,
+ unsigned int w = 0, unsigned int h = 0);
+ virtual void redrawTitle(void);
+ virtual void internal_hide(void);
+
+
+public:
+ Basemenu(BScreen *scrn);
+ virtual ~Basemenu(void);
+
+ inline bool isTorn(void) const { return torn; }
+ inline bool isVisible(void) const { return visible; }
+
+ inline BScreen *getScreen(void) { return screen; }
+
+ inline Window getWindowID(void) const { return menu.window; }
+
+ inline const char *getLabel(void) const { return menu.label.c_str(); }
+
+ int insert(BasemenuItem *item, int pos);
+ int insert(const std::string& label, int function = 0,
+ const std::string& exec = "", int pos = -1);
+ int insert(const std::string &label, Basemenu *submenu, int pos = -1);
+ int remove(int index);
+
+ void changeItemLabel(unsigned int index, const std::string& label);
+
+ inline int getX(void) const { return menu.x; }
+ inline int getY(void) const { return menu.y; }
+ inline unsigned int getCount(void) { return menuitems.size(); }
+ inline int getCurrentSubmenu(void) const { return which_sub; }
+
+ inline unsigned int getWidth(void) const { return menu.width; }
+ inline unsigned int getHeight(void) const { return menu.height; }
+ inline unsigned int getTitleHeight(void) const
+ { return menu.title_h; }
+
+ inline void setInternalMenu(void) { internal_menu = True; }
+ inline void setAlignment(int a) { alignment = a; }
+ inline void setTorn(void) { torn = True; }
+ inline void removeParent(void)
+ { if (internal_menu) parent = (Basemenu *) 0; }
+
+ bool hasSubmenu(int index);
+ bool isItemSelected(int index);
+ bool isItemEnabled(int index);
+
+ void buttonPressEvent(XButtonEvent *be);
+ void buttonReleaseEvent(XButtonEvent *be);
+ void motionNotifyEvent(XMotionEvent *me);
+ void enterNotifyEvent(XCrossingEvent *ce);
+ void leaveNotifyEvent(XCrossingEvent *ce);
+ void exposeEvent(XExposeEvent *ee);
+ void reconfigure(void);
+ void setLabel(const std::string& label);
+ void move(int x, int y);
+ void update(void);
+ void setItemSelected(int index, bool sel);
+ void setItemEnabled(int index, bool enable);
+
+ virtual void drawSubmenu(int index);
+ virtual void show(void);
+ virtual void hide(void);
+
+ enum { AlignDontCare = 1, AlignTop, AlignBottom };
+ enum { Right = 1, Left };
+ enum { Empty = 0, Square, Triangle, Diamond };
+};
+
+
+class BasemenuItem {
+private:
+ Basemenu *sub;
+ std::string l, e;
+ int f, enabled, selected;
+
+ friend class Basemenu;
+
+protected:
+
+public:
+ BasemenuItem(const std::string& lp, int fp = 0, const std::string& ep = ""):
+ sub(0), l(lp), e(ep), f(fp), enabled(1), selected(0) {}
+
+ BasemenuItem(const std::string& lp, Basemenu *mp): sub(mp), l(lp),
+ f(0), enabled(1),
+ selected(0) {}
+
+ ~BasemenuItem(void);
+
+ inline const char *exec(void) const { return e.c_str(); }
+ inline const char *label(void) const { return l.c_str(); }
+ inline int function(void) const { return f; }
+ inline Basemenu *submenu(void) { return sub; }
+
+ inline void newLabel(const std::string& label) { l = label; }
+
+ inline int isEnabled(void) const { return enabled; }
+ inline void setEnabled(int e) { enabled = e; }
+ inline int isSelected(void) const { return selected; }
+ inline void setSelected(int s) { selected = s; }
+};
+
+
+#endif // __Basemenu_hh
--- /dev/null
+// -*- mode: C++; indent-tabs-mode: nil; -*-
+// Icon.hh for Blackbox - an X11 Window manager
+// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
+// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// 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
+// 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.
+
+#ifndef __Icon_hh
+#define __Icon_hh
+
+#include "Basemenu.hh"
+
+// forward declaration
+class Iconmenu;
+class BScreen;
+
+class Iconmenu : public Basemenu {
+private:
+ Iconmenu(const Iconmenu&);
+ Iconmenu& operator=(const Iconmenu&);
+
+protected:
+ virtual void itemSelected(int button, unsigned int index);
+
+public:
+ Iconmenu(BScreen *scrn);
+};
+
+
+#endif // __Icon_hh
--- /dev/null
+// -*- mode: C++; indent-tabs-mode: nil; -*-
+// Slit.hh for Blackbox - an X11 Window manager
+// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
+// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// 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
+// 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.
+
+#ifndef __Slit_hh
+#define __Slit_hh
+
+extern "C" {
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+}
+
+#include <list>
+
+#include "Screen.hh"
+#include "Basemenu.hh"
+
+// forward declaration
+class Slit;
+class Slitmenu;
+
+class Slitmenu : public Basemenu {
+private:
+ class Directionmenu : public Basemenu {
+ private:
+ Directionmenu(const Directionmenu&);
+ Directionmenu& operator=(const Directionmenu&);
+
+ protected:
+ virtual void itemSelected(int button, unsigned int index);
+
+ public:
+ Directionmenu(Slitmenu *sm);
+ };
+
+ class Placementmenu : public Basemenu {
+ private:
+ Placementmenu(const Placementmenu&);
+ Placementmenu& operator=(const Placementmenu&);
+
+ protected:
+ virtual void itemSelected(int buton, unsigned int index);
+
+ public:
+ Placementmenu(Slitmenu *sm);
+ };
+
+ Directionmenu *directionmenu;
+ Placementmenu *placementmenu;
+
+ Slit *slit;
+
+ friend class Directionmenu;
+ friend class Placementmenu;
+ friend class Slit;
+
+ Slitmenu(const Slitmenu&);
+ Slitmenu& operator=(const Slitmenu&);
+
+protected:
+ virtual void itemSelected(int button, unsigned int index);
+ virtual void internal_hide(void);
+
+public:
+ Slitmenu(Slit *sl);
+ virtual ~Slitmenu(void);
+
+ inline Basemenu *getDirectionmenu(void) { return directionmenu; }
+ inline Basemenu *getPlacementmenu(void) { return placementmenu; }
+
+ void reconfigure(void);
+};
+
+
+class Slit : public TimeoutHandler {
+public:
+ struct SlitClient {
+ Window window, client_window, icon_window;
+
+ Rect rect;
+ };
+
+private:
+ typedef std::list<SlitClient*> SlitClientList;
+
+ bool on_top, hidden, do_auto_hide;
+ Display *display;
+
+ Blackbox *blackbox;
+ BScreen *screen;
+ BTimer *timer;
+ Strut strut;
+
+ SlitClientList clientList;
+ Slitmenu *slitmenu;
+
+ struct SlitFrame {
+ Pixmap pixmap;
+ Window window;
+
+ int x_hidden, y_hidden;
+ Rect rect;
+ } frame;
+
+ void updateStrut(void);
+
+ friend class Slitmenu;
+ friend class Slitmenu::Directionmenu;
+ friend class Slitmenu::Placementmenu;
+
+ Slit(const Slit&);
+ Slit& operator=(const Slit&);
+
+public:
+ Slit(BScreen *scr);
+ virtual ~Slit(void);
+
+ inline bool isOnTop(void) const { return on_top; }
+ inline bool isHidden(void) const { return hidden; }
+ inline bool doAutoHide(void) const { return do_auto_hide; }
+
+ inline Slitmenu *getMenu(void) { return slitmenu; }
+
+ inline Window getWindowID(void) const { return frame.window; }
+
+ inline int getX(void) const
+ { return ((hidden) ? frame.x_hidden : frame.rect.x()); }
+ inline int getY(void) const
+ { return ((hidden) ? frame.y_hidden : frame.rect.y()); }
+
+ inline unsigned int getWidth(void) const { return frame.rect.width(); }
+ inline unsigned int getExposedWidth(void) const {
+ if (screen->getSlitDirection() == Vertical && do_auto_hide)
+ return screen->getBevelWidth();
+ return frame.rect.width();
+ }
+ inline unsigned int getHeight(void) const { return frame.rect.height(); }
+ inline unsigned int getExposedHeight(void) const {
+ if (screen->getSlitDirection() == Horizontal && do_auto_hide)
+ return screen->getBevelWidth();
+ return frame.rect.height();
+ }
+
+ void addClient(Window w);
+ void removeClient(SlitClient *client, bool remap = True);
+ void removeClient(Window w, bool remap = True);
+ void reconfigure(void);
+ void updateSlit(void);
+ void reposition(void);
+ void shutdown(void);
+ void toggleAutoHide(void);
+
+ void buttonPressEvent(XButtonEvent *e);
+ void enterNotifyEvent(XCrossingEvent * /*unused*/);
+ void leaveNotifyEvent(XCrossingEvent * /*unused*/);
+ void configureRequestEvent(XConfigureRequestEvent *e);
+ void unmapNotifyEvent(XUnmapEvent *e);
+
+ virtual void timeout(void);
+
+ enum { Vertical = 1, Horizontal };
+ enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter,
+ TopRight, CenterRight, BottomRight };
+};
+
+
+#endif // __Slit_hh
--- /dev/null
+// Windowmenu.hh for Blackbox - an X11 Window manager
+// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
+// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// 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
+// 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.
+
+#ifndef __Windowmenu_hh
+#define __Windowmenu_hh
+
+#include "Basemenu.hh"
+
+// forward declaration
+class Windowmenu;
+class SendtoWorkspaceMenu;
+
+class BlackboxWindow;
+
+class Windowmenu : public Basemenu {
+private:
+ BlackboxWindow *window;
+
+ class SendtoWorkspacemenu : public Basemenu {
+ private:
+ BlackboxWindow *window;
+ SendtoWorkspacemenu(const SendtoWorkspacemenu&);
+ SendtoWorkspacemenu& operator=(const SendtoWorkspacemenu&);
+
+ protected:
+ virtual void itemSelected(int button, unsigned int index);
+
+ public:
+ SendtoWorkspacemenu(Windowmenu *w);
+
+ void update(void);
+
+ virtual void show(void);
+ };
+
+ SendtoWorkspacemenu *sendToMenu;
+
+ friend class SendtoWorkspacemenu;
+
+ Windowmenu(const Windowmenu&);
+ Windowmenu& operator=(const Windowmenu&);
+
+protected:
+ virtual void itemSelected(int button, unsigned int index);
+
+
+public:
+ Windowmenu(BlackboxWindow *win);
+ virtual ~Windowmenu(void);
+
+ inline Basemenu *getSendToMenu(void) { return (Basemenu *) sendToMenu; }
+
+ void reconfigure(void);
+ void setClosable(void);
+
+ virtual void show(void);
+};
+
+
+#endif // __Windowmenu_hh