From 363764db5b36dbffcc019cec8ffb405d357d7130 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 24 Jul 2007 12:12:45 +0000 Subject: fix ToggleDecor for fullscreen and decorationless windows, plus some other cleanup --- ChangeLog | 4 ++++ src/FbCommands.cc | 2 +- src/FbTk/ImageImlib2.cc | 4 ++-- src/FbTk/KeyUtil.cc | 2 +- src/MenuCreator.cc | 2 +- src/Window.cc | 44 +++++++++++++++++++++++--------------------- src/Window.hh | 1 - src/fluxbox.cc | 2 +- src/fluxbox.hh | 2 +- src/main.cc | 6 +++++- 10 files changed, 39 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index bfb668e..660f1c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 1.0.0: +*07/07/24: + * Don't allow ToggleDecor with fullscreen windows, and make it show + decorations for windows that don't have a titlebar by default (Mark) + Window.cc/hh *07/07/08: * Clean up state and workspace window properties on client close (Mark) Ewmh.cc Gnome.cc/hh diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 04f266e..2faa267 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -152,7 +152,7 @@ int ExecuteCmd::run() { // get shell path from the environment // this process exits immediately, so we don't have to worry about memleaks - char *shell = getenv("SHELL"); + const char *shell = getenv("SHELL"); if (!shell) shell = "/bin/sh"; diff --git a/src/FbTk/ImageImlib2.cc b/src/FbTk/ImageImlib2.cc index 2d3ff6c..b4ef415 100644 --- a/src/FbTk/ImageImlib2.cc +++ b/src/FbTk/ImageImlib2.cc @@ -52,7 +52,7 @@ ImageImlib2::ImageImlib2() { // TODO: this are the potential candidates, // choose only sane ones. open for discussion - static char* format_list[] = { + static const char* format_list[] = { "PNG", // pngloader "JPEG", "JPG", "JFI", "JFIF", // jpegloader // "TIFF", "TIF", // tiffloader @@ -67,7 +67,7 @@ ImageImlib2::ImageImlib2() { NULL }; - char** format = NULL; + const char** format = NULL; for(format = format_list; *format != NULL; format++) { Image::registerType(*format, *this); } diff --git a/src/FbTk/KeyUtil.cc b/src/FbTk/KeyUtil.cc index 1830dca..a6ca632 100644 --- a/src/FbTk/KeyUtil.cc +++ b/src/FbTk/KeyUtil.cc @@ -34,7 +34,7 @@ namespace { struct t_modlist{ - char *str; + const char *str; unsigned int mask; bool operator == (const char *modstr) const { return (strcasecmp(str, modstr) == 0 && mask !=0); diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 1aa8877..ef97b63 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -524,7 +524,7 @@ FbTk::Menu *MenuCreator::createMenuType(const string &type, int screen_num) { menu->disableTitle(); // not titlebar if (screen->windowMenuFilename().empty() || ! createWindowMenuFromFile(screen->windowMenuFilename(), *menu, true)) { - char *default_menu[] = { + const char *default_menu[] = { "shade", "stick", "maximize", diff --git a/src/Window.cc b/src/Window.cc index d8a3f46..a6f3194 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -262,7 +262,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, m_last_resize_h(1), m_last_resize_w(1), m_workspace_number(0), m_current_state(0), - m_old_decoration(DECOR_NORMAL), m_old_decoration_mask(0), m_client(&client), m_toggled_decos(false), @@ -1243,8 +1242,7 @@ void FluxboxWindow::updateBlackboxHintsFromClient(const WinClient &client) { m_workspace_number = hint->stack; if (hint->flags & ATTRIB_DECORATION) { - m_old_decoration = static_cast(hint->decoration); - setDecoration(m_old_decoration, false); + setDecoration(static_cast(hint->decoration), false); } } @@ -1577,8 +1575,10 @@ void FluxboxWindow::setFullscreen(bool flag) { frame().setUseShape(false); - m_old_decoration_mask = decorationMask(); - m_old_layernum =layerNum(); + if (!m_toggled_decos) + m_old_decoration_mask = decorationMask(); + + m_old_layernum = layerNum(); m_old_pos_x = frame().x(); m_old_pos_y = frame().y(); m_old_width = frame().width(); @@ -1609,8 +1609,14 @@ void FluxboxWindow::setFullscreen(bool flag) { fullscreen = false; - setDecorationMask(m_old_decoration_mask); frame().setUseShape(!m_shaped); + if (m_toggled_decos) { + if (m_old_decoration_mask & DECORM_TITLEBAR) + setDecoration(DECOR_NONE); + else + setDecoration(DECOR_NORMAL); + } else + setDecorationMask(m_old_decoration_mask); // ensure we apply the sizehints here, otherwise some // apps (eg xterm) end up a little bit .. crappy (visually) @@ -1624,7 +1630,6 @@ void FluxboxWindow::setFullscreen(bool flag) { moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h); moveToLayer(m_old_layernum); - m_old_decoration_mask = 0; m_old_layernum = ::Layer::NORMAL; stateSig().notify(); @@ -3205,22 +3210,20 @@ void FluxboxWindow::applyDecorations(bool initial) { void FluxboxWindow::toggleDecoration() { //don't toggle decor if the window is shaded - if (isShaded()) + if (isShaded() || isFullscreen()) return; - m_toggled_decos= true; + m_toggled_decos = !m_toggled_decos; - if (decorations.enabled) { //remove decorations - decorations.enabled = false; - setDecoration(DECOR_NONE); - } else { //revert back to old decoration - decorations.enabled = true; - if (m_old_decoration == DECOR_NONE) { // make sure something happens + if (m_toggled_decos) { + m_old_decoration_mask = decorationMask(); + if (decorations.titlebar) + setDecoration(DECOR_NONE); + else setDecoration(DECOR_NORMAL); - } else { - setDecoration(m_old_decoration); - } - } + } else + setDecorationMask(m_old_decoration_mask); + } unsigned int FluxboxWindow::decorationMask() const { @@ -3866,8 +3869,7 @@ void FluxboxWindow::changeBlackboxHints(const BlackboxHints &net) { } if (net.flags & ATTRIB_DECORATION) { - m_old_decoration = static_cast(net.decoration); - setDecoration(m_old_decoration); + setDecoration(static_cast(net.decoration)); } } diff --git a/src/Window.hh b/src/Window.hh index 340df7b..15de2bb 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -538,7 +538,6 @@ private: unsigned int m_workspace_number; unsigned long m_current_state; // NormalState | IconicState | Withdrawn - Decoration m_old_decoration; unsigned int m_old_decoration_mask; ClientList m_clientlist; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 7745a89..d739944 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -1448,7 +1448,7 @@ string Fluxbox::getRcFilename() { } /// Provides default filename of data file -void Fluxbox::getDefaultDataFilename(char *name, string &filename) { +void Fluxbox::getDefaultDataFilename(const char *name, string &filename) { filename = string(getenv("HOME") + string("/.") + m_RC_PATH + string("/") + name); } diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 51ecc06..0418901 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -196,7 +196,7 @@ public: bool menuTimestampsChanged() const; bool haveShape() const { return m_have_shape; } int shapeEventbase() const { return m_shape_eventbase; } - void getDefaultDataFilename(char *name, std::string &); + void getDefaultDataFilename(const char *name, std::string &); // 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 diff --git a/src/main.cc b/src/main.cc index 643c6a4..2d1ff0d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -321,9 +321,13 @@ int main(int argc, char **argv) { FbTk::FbStringUtil::shutdown(); if (restarting) { + const char *shell = getenv("SHELL"); + if (!shell) + shell = "/bin/sh"; + const char *arg = restart_argument.c_str(); if (arg) { - execlp(arg, arg, (char *) NULL); + execlp(shell, shell, "-c", arg, (char *) NULL); perror(arg); } -- cgit v0.11.2