From 1a54fbc67d5ca8ef22deed2fffe749b9f99739b4 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Thu, 19 Jun 2008 20:48:26 -0700 Subject: move default window menu to ~/.fluxbox/windowmenu --- ChangeLog | 3 +++ configure.in | 8 ++++++++ data/Makefile.am | 8 ++++++-- src/Makefile.am | 2 ++ src/Screen.cc | 28 +++++++--------------------- src/Screen.hh | 2 +- src/Window.cc | 8 ++++---- src/Window.hh | 6 +++--- src/fluxbox.cc | 37 ++++++++++++++++++------------------- src/fluxbox.hh | 2 +- 10 files changed, 53 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index d754d00..32138a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1 +*08/06/20: + * Move default window menu to ~/.fluxbox/windowmenu (Mark) + configure.in data/Makefile.am data/windowmenu Screen.cc *08/06/08: * Add (urgent=yes|no) option to client patterns (Mark) ClientPattern.cc/hh diff --git a/configure.in b/configure.in index 90f020f..c778ab1 100644 --- a/configure.in +++ b/configure.in @@ -538,6 +538,14 @@ AC_ARG_WITH( AC_SUBST(DEFAULT_MENU) AC_ARG_WITH( + windowmenu, + [ --with-windowmenu=path location windowmenu file (PREFIX/share/fluxbox/windowmenu)], + DEFAULT_WINDOWMENU=$with_windowmenu, + DEFAULT_WINDOWMENU=\$\(prefix\)/share/fluxbox/windowmenu +) +AC_SUBST(DEFAULT_WINDOWMENU) + +AC_ARG_WITH( style, [ --with-style=path style by default (PREFIX/share/fluxbox/styles/bloe)], DEFAULT_STYLE=$with_style, diff --git a/data/Makefile.am b/data/Makefile.am index 4dde80c..e921afa 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -9,6 +9,7 @@ DEFAULT_KEYS = @DEFAULT_KEYS@ DEFAULT_APPS = @DEFAULT_APPS@ DEFAULT_OVERLAY = @DEFAULT_OVERLAY@ DEFAULT_INIT = @DEFAULT_INIT@ +DEFAULT_WINDOWMENU = @DEFAULT_WINDOWMENU@ SUBDIRS= styles CLEANFILES= menu menu.in menu.pre menu.bak init apps @@ -19,7 +20,7 @@ all-local: menu init apps install-pkgdataDATA: @echo "Installing menu file in $(DESTDIR)$(DEFAULT_MENU)" $(mkinstalldirs) $(DESTDIR)$(dir $(DEFAULT_MENU)) - $(INSTALL_DATA) menu $(DESTDIR)$(DEFAULT_MENU) + $(INSTALL_DATA) $(srcdir)/menu $(DESTDIR)$(DEFAULT_MENU) @echo "Installing keys file in $(DESTDIR)$(DEFAULT_KEYS)" $(mkinstalldirs) $(DESTDIR)$(dir $(DEFAULT_KEYS)) $(INSTALL_DATA) $(srcdir)/keys $(DESTDIR)$(DEFAULT_KEYS) @@ -31,7 +32,10 @@ install-pkgdataDATA: $(INSTALL_DATA) $(srcdir)/overlay $(DESTDIR)$(DEFAULT_OVERLAY) @echo "Installing init file in $(DESTDIR)$(DEFAULT_INIT)" $(mkinstalldirs) $(DESTDIR)$(dir $(DEFAULT_INIT)) - $(INSTALL_DATA) init $(DESTDIR)$(DEFAULT_INIT) + $(INSTALL_DATA) $(srcdir)/init $(DESTDIR)$(DEFAULT_INIT) + @echo "Installing windowmenu file in $(DESTDIR)$(DEFAULT_WINDOWMENU)" + $(mkinstalldirs) $(DESTDIR)$(dir $(DEFAULT_WINDOWMENU)) + $(INSTALL_DATA) $(srcdir)/windowmenu $(DESTDIR)$(DEFAULT_WINDOWMENU) distclean-local: rm -f *\~ diff --git a/src/Makefile.am b/src/Makefile.am index 337b99c..b53af38 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,7 @@ DEFAULT_KEYSFILE=@DEFAULT_KEYS@ DEFAULT_APPSFILE=@DEFAULT_APPS@ DEFAULT_OVERLAY=@DEFAULT_OVERLAY@ DEFAULT_INITFILE=@DEFAULT_INIT@ +DEFAULT_WINDOWMENU=@DEFAULT_WINDOWMENU@ PROGRAM_PREFIX=@program_prefix@ PROGRAM_SUFFIX=@program_suffix@ @@ -49,6 +50,7 @@ defaults.hh: Makefile echo '#define DEFAULT_APPSFILE "$(DEFAULT_APPSFILE)"'; \ echo '#define DEFAULT_OVERLAY "$(DEFAULT_OVERLAY)"'; \ echo '#define DEFAULT_INITFILE "$(DEFAULT_INITFILE)"'; \ + echo '#define DEFAULT_WINDOWMENU "$(DEFAULT_WINDOWMENU)"'; \ echo '#define PROGRAM_PREFIX "$(PROGRAM_PREFIX:NONE=)"'; \ echo '#define PROGRAM_SUFFIX "$(PROGRAM_SUFFIX:NONE=)"'; \ echo 'std::string realProgramName(std::string name);'; \ diff --git a/src/Screen.cc b/src/Screen.cc index 1525db6..869fb30 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -278,7 +278,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"), rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"), - windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"), + windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu"), scrname+".windowMenu", altscrname+".WindowMenu"), typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"), follow_model(rm, IGNORE_OTHER_WORKSPACES, scrname+".followModel", altscrname+".followModel"), user_follow_model(rm, FOLLOW_ACTIVE_WINDOW, scrname+".userFollowModel", altscrname+".UserFollowModel"), @@ -1523,6 +1523,12 @@ void BScreen::rereadMenu() { } +const std::string BScreen::windowMenuFilename() const { + if ((*resource.windowmenufile).empty()) + return Fluxbox::instance()->getDefaultDataFilename("windowmenu"); + return *resource.windowmenufile; +} + void BScreen::rereadWindowMenu() { m_windowmenu->removeAll(); @@ -1530,26 +1536,6 @@ void BScreen::rereadWindowMenu() { MenuCreator::createFromFile(windowMenuFilename(), *m_windowmenu, m_windowmenu->reloadHelper()); - if (m_windowmenu->numberOfItems() == 0) { - const char *defaults[] = { - "shade", - "stick", - "maximize", - "iconify", - "raise", - "lower", - "sendto", - "layer", - "alpha", - "extramenus", - "separator", - "close", - 0 - }; - for (unsigned int i=0; defaults[i]; ++i) - MenuCreator::createWindowMenuItem(defaults[i], "", *m_windowmenu); - } - } void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) { diff --git a/src/Screen.hh b/src/Screen.hh index 57c41b6..3283710 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -120,7 +120,7 @@ public: bool doShowWindowPos() const { return *resource.show_window_pos; } bool decorateTransient() const { return *resource.decorate_transient; } const std::string &defaultDeco() const { return *resource.default_deco; } - const std::string &windowMenuFilename() const { return *resource.windowmenufile; } + const std::string windowMenuFilename() const; FbTk::ImageControl &imageControl() { return *m_image_control.get(); } // menus const FbMenu &rootMenu() const { return *m_rootmenu.get(); } diff --git a/src/Window.cc b/src/Window.cc index 56c6f95..2f06603 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2154,11 +2154,11 @@ void FluxboxWindow::restoreAttributes() { Show the window menu at pos mx, my */ void FluxboxWindow::showMenu(int menu_x, int menu_y) { - // move menu directly under titlebar + menu().reloadHelper()->checkReload(); int head = screen().getHead(menu_x, menu_y); - // but not off the screen + // move menu directly under titlebar but not off the screen if (menu_y < static_cast(screen().maxTop(head))) menu_y = screen().maxTop(head); else if (menu_y + menu().height() >= screen().maxBottom(head)) @@ -3648,7 +3648,7 @@ const FbTk::FbWindow &FluxboxWindow::fbWindow() const { return frame().window(); } -FbTk::Menu &FluxboxWindow::menu() { +FbMenu &FluxboxWindow::menu() { return screen().windowMenu(); } @@ -3660,7 +3660,7 @@ const FbTk::PixmapWithMask &FluxboxWindow::icon() const { return (m_client ? m_client->icon() : m_icon); } -const FbTk::Menu &FluxboxWindow::menu() const { +const FbMenu &FluxboxWindow::menu() const { return screen().windowMenu(); } diff --git a/src/Window.hh b/src/Window.hh index 3da2fb1..e7d2270 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -47,13 +47,13 @@ class FbWinFrameTheme; class BScreen; class FbWinFrame; class FocusControl; +class FbMenu; namespace FbTk { class TextButton; class MenuTheme; class ImageControl; class XLayer; -class Menu; } /// Creates the window frame and handles any window event for it @@ -439,8 +439,8 @@ public: FbTk::FbWindow &fbWindow(); const FbTk::FbWindow &fbWindow() const; - FbTk::Menu &menu(); - const FbTk::Menu &menu() const; + FbMenu &menu(); + const FbMenu &menu() const; const FbTk::FbWindow &parent() const { return m_parent; } FbTk::FbWindow &parent() { return m_parent; } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index ec8537c..ae27828 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -522,16 +522,15 @@ void Fluxbox::ungrab() { void Fluxbox::setupConfigFiles() { bool create_init = false, create_keys = false, create_menu = false, - create_apps = false, create_overlay = false; + create_apps = false, create_overlay = false, create_windowmenu = false; - string dirname = getenv("HOME") + string("/.") + m_RC_PATH + "/"; - string init_file, keys_file, menu_file, slitlist_file, apps_file, - overlay_file; - init_file = dirname + m_RC_INIT_FILE; - keys_file = dirname + "keys"; - menu_file = dirname + "menu"; - apps_file = dirname + "apps"; - overlay_file = dirname + "overlay"; + string dirname = getDefaultDataFilename(""); + string init_file = getDefaultDataFilename(m_RC_INIT_FILE); + string keys_file = getDefaultDataFilename("keys"); + string menu_file = getDefaultDataFilename("menu"); + string apps_file = getDefaultDataFilename("apps"); + string overlay_file = getDefaultDataFilename("overlay"); + string windowmenu_file = getDefaultDataFilename("windowmenu"); struct stat buf; @@ -549,6 +548,8 @@ void Fluxbox::setupConfigFiles() { create_apps = true; if (stat(overlay_file.c_str(), &buf)) create_overlay = true; + if (stat(windowmenu_file.c_str(), &buf)) + create_windowmenu = true; } else { #ifdef DEBUG @@ -590,6 +591,9 @@ void Fluxbox::setupConfigFiles() { if (create_init) FbTk::FileUtil::copyFile(DEFAULT_INITFILE, init_file.c_str()); + if (create_windowmenu) + FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str()); + #define CONFIG_VERSION 8 FbTk::Resource config_version(m_resourcemanager, 0, "session.configVersion", "Session.ConfigVersion"); @@ -1319,18 +1323,14 @@ void Fluxbox::save_rc() { /// @return filename of resource file string Fluxbox::getRcFilename() { - - if (m_rc_file.empty()) { // set default filename - string defaultfile(getenv("HOME") + string("/.") + m_RC_PATH + string("/") + m_RC_INIT_FILE); - return defaultfile; - } - + if (m_rc_file.empty()) + return getDefaultDataFilename(m_RC_INIT_FILE); return m_rc_file; } /// Provides default filename of data file -void Fluxbox::getDefaultDataFilename(const char *name, string &filename) const { - filename = string(getenv("HOME") + string("/.") + m_RC_PATH + string("/") + name); +string Fluxbox::getDefaultDataFilename(const char *name) const { + return (getenv("HOME") + string("/.") + m_RC_PATH + string("/") + name); } /// loads resources @@ -1359,8 +1359,7 @@ void Fluxbox::load_rc() { if (!m_rc_slitlistfile->empty()) { *m_rc_slitlistfile = StringUtil::expandFilename(*m_rc_slitlistfile); } else { - string filename; - getDefaultDataFilename("slitlist", filename); + string filename = getDefaultDataFilename("slitlist"); m_rc_slitlistfile.setFromString(filename.c_str()); } diff --git a/src/fluxbox.hh b/src/fluxbox.hh index fc86125..fcbd368 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -175,7 +175,7 @@ public: bool haveShape() const { return m_have_shape; } int shapeEventbase() const { return m_shape_eventbase; } - void getDefaultDataFilename(const char *name, std::string &) const; + std::string getDefaultDataFilename(const char *name) const; // screen mouse was in at last key event BScreen *mouseScreen() { return m_mousescreen; } // screen of window that last key event (i.e. focused window) went to -- cgit v0.11.2