From b4ffe4fe21699c7123728aeeb99576a540b3694e Mon Sep 17 00:00:00 2001 From: rathnor Date: Tue, 18 Feb 2003 15:11:12 +0000 Subject: Added layer menus for windows, toolbar, and slit, plus associated resources. Cleaned up some cruft from the previous layering setup. --- ChangeLog | 7 +++++ src/FbTk/Menu.hh | 4 ++- src/Gnome.cc | 8 +++-- src/Screen.cc | 96 ++++++++------------------------------------------------ src/Screen.hh | 17 +++++----- src/Slit.cc | 47 ++++++++++++++------------- src/Slit.hh | 16 +++++++--- src/Tab.cc | 4 ++- src/Toolbar.cc | 30 +++++++++++------- src/Toolbar.hh | 23 +++++++++----- src/Window.cc | 17 +++++++--- src/Window.hh | 19 ++++++++--- src/Workspace.hh | 1 - src/fluxbox.cc | 52 +++++++++++++++++++++++++++++- src/fluxbox.hh | 31 ++++++++++++------ 15 files changed, 210 insertions(+), 162 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43701d6..87e5f97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ (Format: Year/Month/Day) Changes for 0.1.15: *03/02/17: + * Added layer menus for windows, toolbar, and slit, plus associated + resources. Cleaned up some cruft from the previous layering setup. + Gnome.cc LayerMenu.hh Screen.hh/cc Slit.hh/cc Tab.cc Toolbar.hh/cc Window.hh/cc Workspace.hh fluxbox.hh/cc + * Renamed LayeredMenu to FbMenu + LayeredMenu.hh FbMenu.hh + * Changed XLayerItem to hold FbWindows instead of Windows + XLayerItem.hh/cc XLayer.cc MultLayers.cc Window.cc * Added shade option for button config (Henrik) Screen.cc * Fixed antialias toggle for menus (Henrik) diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 1ae9b8f..1326d1e 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.hh,v 1.8 2003/02/15 01:47:43 fluxgen Exp $ +// $Id: Menu.hh,v 1.9 2003/02/18 15:11:12 rathnor Exp $ #ifndef FBTK_MENU_HH #define FBTK_MENU_HH @@ -121,6 +121,8 @@ public: bool isVisible() const { return visible; } int screenNumber() const { return m_screen_num; } Window window() const { return menu.window.window(); } + FbTk::FbWindow &fbwindow() { return menu.window; } + const FbTk::FbWindow &fbwindow() const { return menu.window; } const std::string &label() const { return menu.label; } int x() const { return menu.x; } int y() const { return menu.y; } diff --git a/src/Gnome.cc b/src/Gnome.cc index b79d535..54e7d45 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Gnome.cc,v 1.10 2003/02/16 17:57:54 rathnor Exp $ +// $Id: Gnome.cc,v 1.11 2003/02/18 15:11:07 rathnor Exp $ #include "Gnome.hh" @@ -366,9 +366,11 @@ void Gnome::setLayer(FluxboxWindow *win, int layer) { layer = Fluxbox::instance()->getTopLayer(); break; case WIN_LAYER_DOCK: - layer = Fluxbox::instance()->getSlitLayer(); + layer = Fluxbox::instance()->getDockLayer(); + break; + case WIN_LAYER_ABOVE_DOCK: + layer = Fluxbox::instance()->getAboveDockLayer(); break; - //case WIN_LAYER_ABOVE_DOCK: case WIN_LAYER_MENU: layer = Fluxbox::instance()->getMenuLayer(); break; diff --git a/src/Screen.cc b/src/Screen.cc index 178b2a4..9f0bfe7 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.110 2003/02/17 12:35:59 fluxgen Exp $ +// $Id: Screen.cc,v 1.111 2003/02/18 15:11:07 rathnor Exp $ #include "Screen.hh" @@ -45,7 +45,8 @@ #include "MacroCommand.hh" #include "XLayerItem.hh" #include "MultLayers.hh" -#include "LayeredMenu.hh" +#include "FbMenu.hh" +#include "LayerMenu.hh" //use GNU extensions #ifndef _GNU_SOURCE @@ -131,13 +132,14 @@ int anotherWMRunning(Display *display, XErrorEvent *) { } FbTk::Menu *createMenuFromScreen(BScreen &screen) { - FbTk::Menu *menu = new LayeredMenu(*screen.menuTheme(), + FbTk::Menu *menu = new FbMenu(*screen.menuTheme(), screen.getScreenNumber(), *screen.getImageControl(), *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())); return menu; } +/* class WindowLayerMenuItem : public FbTk::MenuItem { public: WindowLayerMenuItem(const char *label, FluxboxWindow &win, int layernum): @@ -152,6 +154,8 @@ private: FluxboxWindow &m_window; int m_layernum; }; +*/ + }; // End anonymous namespace @@ -345,7 +349,6 @@ void FbTk::ThemeItem::setFromString(const char *str) { BScreen::ScreenResource::ScreenResource(ResourceManager &rm, const std::string &scrname, const std::string &altscrname): - toolbar_on_top(rm, false, scrname+".toolbar.onTop", altscrname+".Toolbar.OnTop"), toolbar_auto_hide(rm, false, scrname+".toolbar.autoHide", altscrname+".Toolbar.AutoHide"), image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"), opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"), @@ -365,6 +368,8 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm, edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), tab_width(rm, 64, scrname+".tab.width", altscrname+".Tab.Width"), tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"), + slit_layernum(rm, Fluxbox::instance()->getDockLayer(), scrname+".slit.layer", altscrname+".Slit.Layer"), + toolbar_layernum(rm, Fluxbox::instance()->getDesktopLayer(), scrname+".toolbar.layer", altscrname+".Toolbar.Layer"), tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead") @@ -515,10 +520,10 @@ BScreen::BScreen(ResourceManager &rm, current_workspace = workspacesList.front(); #ifdef SLIT - m_slit.reset(new Slit(*this)); + m_slit.reset(new Slit(*this, *layerManager().getLayer(getSlitLayerNum()))); #endif // SLIT - m_toolbar.reset(new Toolbar(*this)); + m_toolbar.reset(new Toolbar(*this, *layerManager().getLayer(getToolbarLayerNum()))); // setup toolbar width menu item FbTk::MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent", resource.toolbar_width_percent, @@ -536,6 +541,7 @@ BScreen::BScreen(ResourceManager &rm, FbTk::RefCount reconfig_toolbar_and_save_resource(toolbar_menuitem_macro); toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource); + m_toolbar->menu().insert(toolbar_menuitem); setupWorkspacemenu(*this, *workspacemenu); @@ -549,8 +555,6 @@ BScreen::BScreen(ResourceManager &rm, initMenu(); // create and initiate rootmenu - raiseWindows(Workspace::Stack()); - //update menus m_rootmenu->update(); m_configmenu->update(); @@ -749,7 +753,6 @@ void BScreen::reconfigure() { m_configmenu->reconfigure(); initMenu(); - raiseWindows(Workspace::Stack()); m_rootmenu->reconfigure(); @@ -784,7 +787,6 @@ void BScreen::reconfigure() { void BScreen::rereadMenu() { initMenu(); - raiseWindows(Workspace::Stack()); m_rootmenu->reconfigure(); } @@ -1253,35 +1255,6 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { menu.removeAll(); // clear old items menu.disableTitle(); // not titlebar - // check and setup layer menu as a submenu windowmenu - FbTk::Menu &layer_menu = win.getLayermenu(); - layer_menu.disableTitle(); // no titlebar - // if it hasn't already been setup (no need to reset it) - if (layer_menu.numberOfItems() == 0) { - Fluxbox *fluxbox = Fluxbox::instance(); - struct { - int set; - int base; - const char *default_str; - int layernum; - } layer_menuitems[] = { - //TODO: nls - {0, 0, "Above Slit", fluxbox->getAboveSlitLayer()}, - {0, 0, "Slit", fluxbox->getSlitLayer()}, - {0, 0, "Top", fluxbox->getTopLayer()}, - {0, 0, "Normal", fluxbox->getNormalLayer()}, - {0, 0, "Bottom", fluxbox->getBottomLayer()}, - {0, 0, "Desktop", fluxbox->getDesktopLayer()}, - }; - - for (size_t i=0; i < 6; ++i) { - // TODO: fetch nls string - layer_menu.insert(new WindowLayerMenuItem(layer_menuitems[i].default_str, - win, layer_menuitems[i].layernum)); - }; - layer_menu.update(); - } - // set new menu items menu.insert("Shade", shade_cmd); menu.insert("Stick", stick_cmd); @@ -1291,57 +1264,14 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { menu.insert("Iconify", iconify_cmd); menu.insert("Raise", raise_cmd); menu.insert("Lower", lower_cmd); - menu.insert("Layer...", &layer_menu); + menu.insert("Layer...", win.getLayermenu()); menu.insert("ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ"); menu.insert("Close", close_cmd); menu.reconfigure(); // update graphics } -void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { - - // TODO: I don't think we need this... -#ifdef DEBUG - cerr<<"BScreen::raiseWindows() called"<menu().windowID(); - } - - session_stack[i++] = workspacemenu->windowID(); - - Rootmenus::iterator rit = rootmenuList.begin(); - Rootmenus::iterator rit_end = rootmenuList.end(); - for (; rit != rit_end; ++rit) { - session_stack[i++] = (*rit)->windowID(); - } - session_stack[i++] = m_rootmenu->windowID(); - if (m_toolbar->isOnTop()) - session_stack[i++] = m_toolbar->getWindowID(); - -#ifdef SLIT - if (m_slit->isOnTop()) - session_stack[i++] = m_slit->getWindowID(); -#endif // SLIT - if (!workspace_stack.empty()) { - Workspace::Stack::const_reverse_iterator it = workspace_stack.rbegin(); - Workspace::Stack::const_reverse_iterator it_end = workspace_stack.rend(); - for (; it != it_end; ++it) - session_stack[i++] = (*it); - } - - XRestackWindows(getBaseDisplay()->getXDisplay(), session_stack, i); - */ -} void BScreen::saveStrftimeFormat(const char *format) { //make sure std::string don't get 0 string diff --git a/src/Screen.hh b/src/Screen.hh index a68bd32..3135b9c 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.67 2003/02/16 00:36:17 fluxgen Exp $ +// $Id: Screen.hh,v 1.68 2003/02/18 15:11:08 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -36,6 +36,7 @@ #include "FbWinFrameTheme.hh" #include "MultLayers.hh" #include "XLayerItem.hh" +#include "fluxbox.hh" #include #include @@ -77,7 +78,6 @@ public: int scrn, int number_of_layers); ~BScreen(); - inline bool isToolbarOnTop() const { return *resource.toolbar_on_top; } inline bool doToolbarAutoHide() const { return *resource.toolbar_auto_hide; } inline bool isSloppyFocus() const { return resource.sloppy_focus; } inline bool isSemiSloppyFocus() const { return resource.semi_sloppy_focus; } @@ -105,7 +105,6 @@ public: inline const std::string &getRootCommand() const { return *resource.rootcommand; } - inline bool isSlitOnTop() const { return resource.slit_on_top; } inline bool doSlitAutoHide() const { return resource.slit_auto_hide; } #ifdef SLIT inline Slit *getSlit() { return m_slit.get(); } @@ -115,7 +114,6 @@ public: inline int getSlitDirection() const { return resource.slit_direction; } inline void saveSlitPlacement(int p) { resource.slit_placement = p; } inline void saveSlitDirection(int d) { resource.slit_direction = d; } - inline void saveSlitOnTop(bool t) { resource.slit_on_top = t; } inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; } inline unsigned int getSlitOnHead() const { return resource.slit_on_head; } @@ -181,6 +179,10 @@ public: inline int getColPlacementDirection() const { return resource.col_direction; } inline unsigned int getTabWidth() const { return *resource.tab_width; } inline unsigned int getTabHeight() const { return *resource.tab_height; } + + inline int getSlitLayerNum() const { return (*resource.slit_layernum).getNum(); } + inline int getToolbarLayerNum() const { return (*resource.toolbar_layernum).getNum(); } + inline Tab::Placement getTabPlacement() const { return *resource.tab_placement; } inline Tab::Alignment getTabAlignment() const { return *resource.tab_alignment; } @@ -190,7 +192,6 @@ public: inline void saveSemiSloppyFocus(bool s) { resource.semi_sloppy_focus = s; } inline void saveAutoRaise(bool a) { resource.auto_raise = a; } inline void saveWorkspaces(int w) { *resource.workspaces = w; } - inline void saveToolbarOnTop(bool r) { *resource.toolbar_on_top = r; } inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; } inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; } @@ -262,7 +263,6 @@ public: std::string getNameOfWorkspace(unsigned int workspace) const; void changeWorkspaceID(unsigned int); void sendToWorkspace(unsigned int workspace, FluxboxWindow *win=0, bool changeworkspace=true); - void raiseWindows(const Workspace::Stack &workspace_stack); void reassociateGroup(FluxboxWindow *window, unsigned int workspace_id, bool ignore_sticky); void reassociateWindow(FluxboxWindow *window, unsigned int workspace_id, bool ignore_sticky); void prevFocus() { prevFocus(0); } @@ -375,7 +375,7 @@ private: ScreenResource(ResourceManager &rm, const std::string &scrname, const std::string &altscrname); - Resource toolbar_on_top, toolbar_auto_hide, + Resource toolbar_auto_hide, image_dither, opaque_move, full_max, max_over_slit, tab_rotate_vertical, sloppy_window_grouping, workspace_warping, @@ -387,13 +387,14 @@ private: ordered_dither; Resource workspaces, toolbar_width_percent, edge_snap_threshold, tab_width, tab_height; + Resource slit_layernum, toolbar_layernum; int placement_policy, row_direction, col_direction; Resource tab_placement; Resource tab_alignment; Resource toolbar_on_head; - bool slit_on_top, slit_auto_hide; + bool slit_auto_hide; int slit_placement, slit_direction; unsigned int slit_on_head; diff --git a/src/Slit.cc b/src/Slit.cc index c565867..65e1b63 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.34 2003/02/17 12:53:21 fluxgen Exp $ +// $Id: Slit.cc,v 1.35 2003/02/18 15:11:08 rathnor Exp $ #include "Slit.hh" @@ -43,6 +43,9 @@ #include "BoolMenuItem.hh" #include "EventManager.hh" #include "MacroCommand.hh" +#include "LayerMenu.hh" +#include "fluxbox.hh" +#include "XLayer.hh" #include #include @@ -104,6 +107,7 @@ void getWMName(BScreen *screen, Window window, std::string& name) { } }; + /// holds slit client info class SlitClient { public: @@ -226,8 +230,8 @@ private: }; // End anonymous namespace -Slit::Slit(BScreen &scr, const char *filename): - m_screen(&scr), timer(this), +Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) + : m_screen(&scr), timer(this), slitmenu(*scr.menuTheme(), scr.getScreenNumber(), *scr.getImageControl()), @@ -236,12 +240,20 @@ Slit::Slit(BScreen &scr, const char *filename): *scr.getImageControl()), clientlist_menu(*scr.menuTheme(), scr.getScreenNumber(), - *scr.getImageControl()) { + *scr.getImageControl()), + slit_layermenu(0), + m_layeritem(0) +{ + + slit_layermenu = new LayerMenu(*scr.menuTheme(), + scr.getScreenNumber(), + *scr.getImageControl(), + *scr.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), + this); // default placement and direction m_direction = HORIZONTAL; m_placement = TOPLEFT; - on_top = false; hidden = do_auto_hide = false; frame.pixmap = None; @@ -270,6 +282,7 @@ Slit::Slit(BScreen &scr, const char *filename): create_mask, &attrib); FbTk::EventManager::instance()->add(*this, frame.window); + m_layeritem = new FbTk::XLayerItem(frame.window, layer); //For KDE dock applets kwm1_dockwindow = XInternAtom(disp, "KWM_DOCKWINDOW", False); //KDE v1.x @@ -287,6 +300,8 @@ Slit::Slit(BScreen &scr, const char *filename): Slit::~Slit() { if (frame.pixmap != 0) screen()->getImageControl()->removeImage(frame.pixmap); + if (m_layeritem) delete m_layeritem; + if (slit_layermenu) delete slit_layermenu; } @@ -904,13 +919,7 @@ void Slit::buttonPressEvent(XButtonEvent &e) { if (e.window != frame.window.window()) return; - if (e.button == Button1 && (! on_top)) { - Workspace::Stack st; - st.push_back(frame.window.window()); - screen()->raiseWindows(st); - } else if (e.button == Button2 && (! on_top)) { - frame.window.lower(); - } else if (e.button == Button3) { + if (e.button == Button3) { if (! slitmenu.isVisible()) { int x = e.x_root - (slitmenu.width() / 2), y = e.y_root - (slitmenu.height() / 2); @@ -1068,13 +1077,6 @@ void Slit::saveClientList() { } } -void Slit::setOnTop(bool val) { - if (isOnTop()) - screen()->raiseWindows(Workspace::Stack()); - -} - - void Slit::setAutoHide(bool val) { do_auto_hide = val; } @@ -1091,11 +1093,8 @@ void Slit::setupMenu() { CommonSet, CommonPlacementTitle, "Placement"), &placement_menu); - slitmenu.insert(new BoolMenuItem(i18n->getMessage( - CommonSet, CommonAlwaysOnTop, - "Always on top"), - on_top, - menu_cmd)); + + slitmenu.insert("Layer...", slit_layermenu); slitmenu.insert(new BoolMenuItem(i18n->getMessage( CommonSet, CommonAutoHide, diff --git a/src/Slit.hh b/src/Slit.hh index 3a7c437..f39642f 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// $Id: Slit.hh,v 1.18 2003/01/12 17:53:10 fluxgen Exp $ +/// $Id: Slit.hh,v 1.19 2003/02/18 15:11:08 rathnor Exp $ #ifndef SLIT_HH #define SLIT_HH @@ -30,6 +30,8 @@ #include "Menu.hh" #include "FbWindow.hh" #include "Timer.hh" +#include "XLayerItem.hh" +#include "LayerMenu.hh" #include #include @@ -54,10 +56,9 @@ public: enum Placement { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT }; - explicit Slit(BScreen &screen, const char *filename = 0); + explicit Slit(BScreen &screen, FbTk::XLayer &layer, const char *filename = 0); virtual ~Slit(); - inline bool isOnTop() const { return on_top; } inline bool isHidden() const { return hidden; } inline bool doAutoHide() const { return do_auto_hide; } inline Direction direction() const { return m_direction; } @@ -74,7 +75,6 @@ public: void setDirection(Direction dir); void setPlacement(Placement place); - void setOnTop(bool val); void setAutoHide(bool val); void addClient(Window clientwin); void removeClient(Window clientwin, bool = true); @@ -101,6 +101,9 @@ public: void configureRequestEvent(XConfigureRequestEvent &event); //@} + void moveToLayer(int layernum) { m_layeritem->moveToLayer(layernum); } + FbTk::XLayerItem &getLayerItem() { return *m_layeritem; } + virtual void timeout(); @@ -111,7 +114,7 @@ private: void loadClientList(const char *filename); void updateClientmenu(); - bool on_top, hidden, do_auto_hide; + bool hidden, do_auto_hide; Direction m_direction; Placement m_placement; @@ -122,6 +125,7 @@ private: SlitClients clientList; FbTk::Menu slitmenu, placement_menu, clientlist_menu; + LayerMenu *slit_layermenu; std::string clientListPath; std::string m_filename; @@ -134,6 +138,8 @@ private: } frame; // for KDE Atom kwm1_dockwindow, kwm2_dockwindow; + + FbTk::XLayerItem *m_layeritem; }; diff --git a/src/Tab.cc b/src/Tab.cc index 7d3609e..986bbd8 100644 --- a/src/Tab.cc +++ b/src/Tab.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.cc,v 1.54 2003/02/09 14:11:12 rathnor Exp $ +// $Id: Tab.cc,v 1.55 2003/02/18 15:11:09 rathnor Exp $ #include "Tab.hh" @@ -152,6 +152,7 @@ void Tab::focus() { //----------------------------------------- void Tab::raise() { //get first tab + /* Tab *tab = 0; //raise tabs Workspace::Stack st; @@ -159,6 +160,7 @@ void Tab::raise() { st.push_back(tab->m_tabwin); } m_win->getScreen()->raiseWindows(st); + */ } //-------------- lower -------------------- diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 15613ba..101900a 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.58 2003/02/17 12:32:21 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.59 2003/02/18 15:11:09 rathnor Exp $ #include "Toolbar.hh" @@ -92,6 +92,8 @@ void setupMenus(Toolbar &tbar) { "Toolbar")); menu.setInternalMenu(); + menu.insert("Layer...", tbar.layermenu()); + using namespace FbTk; RefCount start_edit(new SimpleCommand(tbar, &Toolbar::edit)); menu.insert(i18n->getMessage( @@ -166,8 +168,7 @@ Toolbar::Frame::~Frame() { evm.remove(clock); } -Toolbar::Toolbar(BScreen &scrn, size_t width): - on_top(scrn.isToolbarOnTop()), +Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): editing(false), hidden(scrn.doToolbarAutoHide()), do_auto_hide(scrn.doToolbarAutoHide()), @@ -177,10 +178,20 @@ Toolbar::Toolbar(BScreen &scrn, size_t width): clock_timer(this), // get the clock updating every minute hide_timer(&hide_handler), m_toolbarmenu(*scrn.menuTheme(), scrn.getScreenNumber(), *scrn.getImageControl()), + m_layermenu(0), m_theme(scrn.getScreenNumber()), m_place(BOTTOMCENTER), - m_themelistener(*this) { + m_themelistener(*this), + m_layeritem(0) +{ + m_layermenu = new LayerMenu( + *scrn.menuTheme(), + scrn.getScreenNumber(), + *scrn.getImageControl(), + *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), + this); + // we need to get notified when the theme is reloaded m_theme.addListener(m_themelistener); @@ -194,6 +205,8 @@ Toolbar::Toolbar(BScreen &scrn, size_t width): frame.button_w = 20; frame.bevel_w = 1; + m_layeritem = new FbTk::XLayerItem(frame.window, layer); + timeval delay; delay.tv_sec = 1; delay.tv_usec = 0; @@ -247,6 +260,8 @@ Toolbar::~Toolbar() { if (frame.clk) image_ctrl.removeImage(frame.clk); if (frame.button) image_ctrl.removeImage(frame.button); if (frame.pbutton) image_ctrl.removeImage(frame.pbutton); + if (m_layeritem) delete m_layeritem; + if (m_layermenu) delete m_layermenu; } @@ -748,13 +763,6 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) { checkClock(true, true); } #endif // HAVE_STRFTIME - else if (! on_top) { - Workspace::Stack st; - st.push_back(frame.window.window()); - screen().raiseWindows(st); - } - } else if (be.button == 2 && (! on_top)) { - frame.window.lower(); } else if (be.button == 3) { FluxboxWindow *fluxboxwin = 0; // if we clicked on a icon then show window menu diff --git a/src/Toolbar.hh b/src/Toolbar.hh index cfebedd..21faadb 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.hh,v 1.23 2003/02/16 00:08:29 fluxgen Exp $ +// $Id: Toolbar.hh,v 1.24 2003/02/18 15:11:10 rathnor Exp $ #ifndef TOOLBAR_HH #define TOOLBAR_HH @@ -34,11 +34,12 @@ #include "FbWindow.hh" #include "ArrowButton.hh" #include "Observer.hh" +#include "XLayer.hh" +#include "XLayerItem.hh" +#include "LayerMenu.hh" #include -class Toolbar; - namespace FbTk { class ImageControl; }; @@ -61,7 +62,7 @@ public: }; /// create a toolbar on the screen with specific width - explicit Toolbar(BScreen &screen, size_t width = 200); + explicit Toolbar(BScreen &screen, FbTk::XLayer &layer, size_t width = 200); /// destructor virtual ~Toolbar(); @@ -73,10 +74,15 @@ public: inline const FbTk::Menu &menu() const { return m_toolbarmenu; } inline FbTk::Menu &menu() { return m_toolbarmenu; } + inline FbTk::Menu *layermenu() { return m_layermenu; } + inline const FbTk::Menu *layermenu() const { return m_layermenu; } + + void moveToLayer(int layernum) { m_layeritem->moveToLayer(layernum); } + + FbTk::XLayerItem &getLayerItem() { return *m_layeritem; } + /// are we in workspacename editing? inline bool isEditing() const { return editing; } - /// always on top? - inline bool isOnTop() const { return on_top; } /// are we hidden? inline bool isHidden() const { return hidden; } /// do we auto hide the toolbar? @@ -120,7 +126,6 @@ public: private: - bool on_top; ///< always on top bool editing; ///< edit workspace label mode bool hidden; ///< hidden state bool do_auto_hide; ///< do we auto hide @@ -130,6 +135,7 @@ private: struct Frame { Frame(FbTk::EventHandler &evh, int screen_num); ~Frame(); + Pixmap base, label, wlabel, clk, button, pbutton; FbTk::FbWindow window, workspace_label, window_label, clock; ArrowButton psbutton, nsbutton, pwbutton, nwbutton; @@ -152,6 +158,7 @@ private: FbTk::Timer clock_timer; ///< timer to update clock FbTk::Timer hide_timer; ///< timer to for auto hide toolbar FbTk::Menu m_toolbarmenu; + LayerMenu *m_layermenu; std::auto_ptr m_iconbar; std::string new_workspace_name; ///< temp variable in edit workspace name mode @@ -170,6 +177,8 @@ private: }; ThemeListener m_themelistener; + + FbTk::XLayerItem *m_layeritem; }; diff --git a/src/Window.cc b/src/Window.cc index fab5d53..b7a28fa 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.119 2003/02/17 22:42:52 fluxgen Exp $ +// $Id: Window.cc,v 1.120 2003/02/18 15:11:10 rathnor Exp $ #include "Window.hh" @@ -112,13 +112,20 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, display(0), lastButtonPressTime(0), m_windowmenu(menutheme, screen_num, imgctrl), - m_layermenu(menutheme, screen_num, imgctrl), + m_layermenu(0), old_decoration(DECOR_NORMAL), tab(0), m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100), - m_layeritem(getFrameWindow(), layer), - m_layernum(layer.getLayerNum()) { + m_layeritem(m_frame.window(), layer), + m_layernum(layer.getLayerNum()) +{ + m_layermenu = new LayerMenu( + menutheme, + screen_num, + imgctrl, + *s->layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), + this); // redirect events from frame to us @@ -354,6 +361,8 @@ FluxboxWindow::~FluxboxWindow() { client.window_group = 0; } + if (m_layermenu) delete m_layermenu; + if (client.window) fluxbox->removeWindowSearch(client.window); diff --git a/src/Window.hh b/src/Window.hh index 0f6c75b..f55b307 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.49 2003/02/17 22:41:24 fluxgen Exp $ +// $Id: Window.hh,v 1.50 2003/02/18 15:11:11 rathnor Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -34,6 +34,7 @@ #include "FbWinFrame.hh" #include "EventHandler.hh" #include "XLayerItem.hh" +#include "LayerMenu.hh" #include #include @@ -58,6 +59,7 @@ class ImageControl; class XLayer; }; + /// Creates the window frame and handles any window event for it class FluxboxWindow : public FbTk::TimeoutHandler, public FbTk::EventHandler { public: @@ -223,11 +225,14 @@ public: Window getFrameWindow() const { return m_frame.window().window(); } Window getClientWindow() const { return client.window; } + FbTk::FbWindow &getFbWindow() { return m_frame.window(); } + const FbTk::FbWindow &getFbWindow() const { return m_frame.window(); } + FbTk::Menu &getWindowmenu() { return m_windowmenu; } const FbTk::Menu &getWindowmenu() const { return m_windowmenu; } - FbTk::Menu &getLayermenu() { return m_layermenu; } - const FbTk::Menu &getLayermenu() const { return m_layermenu; } + FbTk::Menu *getLayermenu() { return m_layermenu; } + const FbTk::Menu *getLayermenu() const { return m_layermenu; } const std::string &getTitle() const { return client.title; } const std::string &getIconTitle() const { return client.icon_title; } @@ -341,7 +346,8 @@ private: BaseDisplay::BlackboxAttributes blackbox_attrib; Time lastButtonPressTime; - FbTk::Menu m_windowmenu, m_layermenu; + FbTk::Menu m_windowmenu; + LayerMenu *m_layermenu; timeval lastFocusTime; @@ -403,5 +409,10 @@ private: }; +template <> +void LayerMenuItem::click(int button, int time) { + m_object->moveToLayer(m_layernum); +} + #endif // WINDOW_HH diff --git a/src/Workspace.hh b/src/Workspace.hh index fe10eec..34b4c9f 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh @@ -45,7 +45,6 @@ class FluxboxWindow; class Workspace:private FbTk::NotCopyable { public: typedef std::vector Windows; - typedef std::vector Stack; Workspace(BScreen &screen, FbTk::MultLayers &layermanager, unsigned int workspaceid = 0); diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 19ee556..be41df1 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.96 2003/02/17 12:31:17 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.97 2003/02/18 15:11:12 rathnor Exp $ #include "fluxbox.hh" @@ -283,6 +283,56 @@ getString() { return string(tmpstr); } +template<> +void Resource:: +setFromString(const char *strval) { + int tempnum = 0; + if (sscanf(strval, "%d", &tempnum) == 1) + m_value = tempnum; + else if (strcasecmp(strval, "Menu") == 0) + m_value = Fluxbox::instance()->getMenuLayer(); + else if (strcasecmp(strval, "AboveDock") == 0) + m_value = Fluxbox::instance()->getAboveDockLayer(); + else if (strcasecmp(strval, "Dock") == 0) + m_value = Fluxbox::instance()->getDockLayer(); + else if (strcasecmp(strval, "Top") == 0) + m_value = Fluxbox::instance()->getTopLayer(); + else if (strcasecmp(strval, "Normal") == 0) + m_value = Fluxbox::instance()->getNormalLayer(); + else if (strcasecmp(strval, "Bottom") == 0) + m_value = Fluxbox::instance()->getBottomLayer(); + else if (strcasecmp(strval, "Desktop") == 0) + m_value = Fluxbox::instance()->getDesktopLayer(); + else + setDefaultValue(); +} + + +template<> +string Resource:: +getString() { + + if (m_value.getNum() == Fluxbox::instance()->getMenuLayer()) + return string("Menu"); + else if (m_value.getNum() == Fluxbox::instance()->getAboveDockLayer()) + return string("AboveDock"); + else if (m_value.getNum() == Fluxbox::instance()->getDockLayer()) + return string("Dock"); + else if (m_value.getNum() == Fluxbox::instance()->getTopLayer()) + return string("Top"); + else if (m_value.getNum() == Fluxbox::instance()->getNormalLayer()) + return string("Normal"); + else if (m_value.getNum() == Fluxbox::instance()->getBottomLayer()) + return string("Bottom"); + else if (m_value.getNum() == Fluxbox::instance()->getDesktopLayer()) + return string("Desktop"); + else { + char tmpstr[128]; + sprintf(tmpstr, "%d", m_value.getNum()); + return string(tmpstr); + } +} + //static singleton var Fluxbox *Fluxbox::singleton=0; diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 827d869..84aac80 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.hh,v 1.42 2003/02/17 12:29:35 fluxgen Exp $ +// $Id: fluxbox.hh,v 1.43 2003/02/18 15:11:12 rathnor Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH @@ -103,7 +103,7 @@ public: /// obsolete enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY}; - + inline const std::vector& getTitlebarRight() { return *m_rc_titlebar_right; } inline const std::vector& getTitlebarLeft() { return *m_rc_titlebar_left; } inline const std::string &getStyleFilename() const { return *m_rc_stylefile; } @@ -113,14 +113,26 @@ public: inline int colorsPerChannel() const { return *m_rc_colors_per_channel; } inline int getNumberOfLayers() const { return *m_rc_numlayers; } - // TODO there probably should be configurable - inline int getDesktopLayer() const { return 12; } - inline int getBottomLayer() const { return 10; } - inline int getNormalLayer() const { return 8; } - inline int getTopLayer() const { return 6; } - inline int getSlitLayer() const { return 4; } - inline int getAboveSlitLayer() const { return 2; } + // class to store layer numbers (special Resource type) + class Layer { + public: + Layer(int i) : m_num(i) {}; + const int getNum() const { return m_num; } + + Layer &operator=(int num) { m_num = num; return *this; } + + private: + int m_num; + }; + + // TODO these probably should be configurable inline int getMenuLayer() const { return 0; } + inline int getAboveDockLayer() const { return 2; } + inline int getDockLayer() const { return 4; } + inline int getTopLayer() const { return 6; } + inline int getNormalLayer() const { return 8; } + inline int getBottomLayer() const { return 10; } + inline int getDesktopLayer() const { return 12; } inline const timeval &getAutoRaiseDelay() const { return resource.auto_raise_delay; } @@ -216,6 +228,7 @@ private: Resource m_rc_stylefile, m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, m_rc_groupfile; + Resource m_rc_titlebar_left, m_rc_titlebar_right; Resource m_rc_cache_life, m_rc_cache_max; -- cgit v0.11.2