From 0279936d835d7d88537bcf1208035787c02ced59 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Tue, 6 Jul 2021 16:31:49 -0700 Subject: Patch from Thomas Luebking Adds (secret) opaque resize mode. It sure would be nice if it was documented.... The relevant init file resources and their default values are: session.screen0.opaqueResize: False session.screen0.opaqueResizeDelay: 40 --- src/Screen.hh | 2 ++ src/ScreenResource.cc | 4 ++- src/ScreenResource.hh | 2 ++ src/Window.cc | 79 ++++++++++++++++++++++++++++++--------------------- src/Window.hh | 3 ++ 5 files changed, 57 insertions(+), 33 deletions(-) diff --git a/src/Screen.hh b/src/Screen.hh index 15eb349..83c5cb5 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -100,6 +100,8 @@ public: bool doAutoRaise() const { return *resource.auto_raise; } bool clickRaises() const { return *resource.click_raises; } bool doOpaqueMove() const { return *resource.opaque_move; } + bool doOpaqueResize() const { return *resource.opaque_resize; } + unsigned int opaqueResizeDelay() const { return *resource.opaque_resize_delay; } bool doFullMax() const { return *resource.full_max; } bool getMaxIgnoreIncrement() const { return *resource.max_ignore_inc; } bool getMaxDisableMove() const { return *resource.max_disable_move; } diff --git a/src/ScreenResource.cc b/src/ScreenResource.cc index c188648..c5e0027 100644 --- a/src/ScreenResource.cc +++ b/src/ScreenResource.cc @@ -83,6 +83,7 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm, const std::string& scrname, const std::string& altscrname): opaque_move(rm, true, scrname + ".opaqueMove", altscrname+".OpaqueMove"), + opaque_resize(rm, false, scrname + ".opaqueResize", altscrname+".OpaqueResize"), full_max(rm, false, scrname+".fullMaximization", altscrname+".FullMaximization"), max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"), max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), @@ -110,6 +111,7 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm, clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"), tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), - default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { + default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar"), + opaque_resize_delay(rm, 50, scrname + ".opaqueResizeDelay", altscrname+".OpaqueResizeDelay") { } diff --git a/src/ScreenResource.hh b/src/ScreenResource.hh index bc782e1..120ecf9 100644 --- a/src/ScreenResource.hh +++ b/src/ScreenResource.hh @@ -32,6 +32,7 @@ struct ScreenResource { const std::string &scrname, const std::string &altscrname); FbTk::Resource opaque_move, + opaque_resize, full_max, max_ignore_inc, max_disable_move, @@ -61,6 +62,7 @@ struct ScreenResource { FbTk::Resource tabs_use_pixmap; FbTk::Resource max_over_tabs; FbTk::Resource default_internal_tabs; + FbTk::Resource opaque_resize_delay; }; #endif diff --git a/src/Window.cc b/src/Window.cc index 6714d0a..1f2d184 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -449,6 +449,12 @@ void FluxboxWindow::init() { m_tabActivationTimer.setCommand(activate_tab_cmd); m_tabActivationTimer.fireOnce(true); + m_resizeTimer.setTimeout(screen().opaqueResizeDelay() * FbTk::FbTime::IN_MILLISECONDS); + FbTk::RefCount > resize_cmd(new FbTk::SimpleCommand(*this, + &FluxboxWindow::updateResize)); + m_resizeTimer.setCommand(resize_cmd); + m_resizeTimer.fireOnce(true); + m_reposLabels_timer.setTimeout(IconButton::updateLaziness()); m_reposLabels_timer.fireOnce(true); FbTk::RefCount > elrs(new FbTk::SimpleCommand(*this, &FluxboxWindow::emitLabelReposSig)); @@ -2663,36 +2669,36 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { int old_resize_w = m_last_resize_w; int old_resize_h = m_last_resize_h; - int dx = me.x - m_button_grab_x; - int dy = me.y - m_button_grab_y; + int dx = me.x_root - m_button_grab_x; + int dy = me.y_root - m_button_grab_y; if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || m_resize_corner == LEFT) { - m_last_resize_w = frame().width() - dx; - m_last_resize_x = frame().x() + dx; + m_last_resize_w = resize_base_w - dx; + m_last_resize_x = resize_base_x + dx; } if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP || m_resize_corner == TOP) { - m_last_resize_h = frame().height() - dy; - m_last_resize_y = frame().y() + dy; + m_last_resize_h = resize_base_h - dy; + m_last_resize_y = resize_base_y + dy; } if (m_resize_corner == LEFTBOTTOM || m_resize_corner == BOTTOM || m_resize_corner == RIGHTBOTTOM) - m_last_resize_h = frame().height() + dy; + m_last_resize_h = resize_base_h + dy; if (m_resize_corner == RIGHTBOTTOM || m_resize_corner == RIGHTTOP || m_resize_corner == RIGHT) - m_last_resize_w = frame().width() + dx; + m_last_resize_w = resize_base_w + dx; if (m_resize_corner == CENTER) { // dx or dy must be at least 2 if (abs(dx) >= 2 || abs(dy) >= 2) { // take max and make it even int diff = 2 * (max(dx, dy) / 2); - m_last_resize_h = frame().height() + diff; + m_last_resize_h = resize_base_h + diff; - m_last_resize_w = frame().width() + diff; - m_last_resize_x = frame().x() - diff/2; - m_last_resize_y = frame().y() - diff/2; + m_last_resize_w = resize_base_w + diff; + m_last_resize_x = resize_base_x - diff/2; + m_last_resize_y = resize_base_y - diff/2; } } @@ -2780,18 +2786,23 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { } } - // draw over old rect - parent().drawRectangle(screen().rootTheme()->opGC(), - old_resize_x, old_resize_y, - old_resize_w - 1 + 2 * frame().window().borderWidth(), - old_resize_h - 1 + 2 * frame().window().borderWidth()); - - // draw resize rectangle - parent().drawRectangle(screen().rootTheme()->opGC(), - m_last_resize_x, m_last_resize_y, - m_last_resize_w - 1 + 2 * frame().window().borderWidth(), - m_last_resize_h - 1 + 2 * frame().window().borderWidth()); - + if (m_last_resize_w != old_resize_w || m_last_resize_h != old_resize_h) { + if (screen().doOpaqueResize()) { + m_resizeTimer.start(); + } else { + // draw over old rect + parent().drawRectangle(screen().rootTheme()->opGC(), + old_resize_x, old_resize_y, + old_resize_w - 1 + 2 * frame().window().borderWidth(), + old_resize_h - 1 + 2 * frame().window().borderWidth()); + + // draw resize rectangle + parent().drawRectangle(screen().rootTheme()->opGC(), + m_last_resize_x, m_last_resize_y, + m_last_resize_w - 1 + 2 * frame().window().borderWidth(), + m_last_resize_h - 1 + 2 * frame().window().borderWidth()); + } + } } } } @@ -3320,29 +3331,33 @@ void FluxboxWindow::startResizing(int x, int y, ReferenceCorner dir) { false, ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); - m_button_grab_x = x; - m_button_grab_y = y; - m_last_resize_x = frame().x(); - m_last_resize_y = frame().y(); - m_last_resize_w = frame().width(); - m_last_resize_h = frame().height(); + m_button_grab_x = x + frame().x(); + m_button_grab_y = y + frame().y(); + resize_base_x = m_last_resize_x = frame().x(); + resize_base_y = m_last_resize_y = frame().y(); + resize_base_w = m_last_resize_w = frame().width(); + resize_base_h = m_last_resize_h = frame().height(); fixSize(); frame().displaySize(m_last_resize_w, m_last_resize_h); - parent().drawRectangle(screen().rootTheme()->opGC(), + if (!screen().doOpaqueResize()) { + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_resize_x, m_last_resize_y, m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_h - 1 + 2 * frame().window().borderWidth()); + } } void FluxboxWindow::stopResizing(bool interrupted) { resizing = false; - parent().drawRectangle(screen().rootTheme()->opGC(), + if (!screen().doOpaqueResize()) { + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_resize_x, m_last_resize_y, m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_h - 1 + 2 * frame().window().borderWidth()); + } screen().hideGeometry(); diff --git a/src/Window.hh b/src/Window.hh index 407d51b..c6e3ce4 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -528,6 +528,7 @@ private: void moveResizeClient(WinClient &client); /// sends configurenotify to all clients void sendConfigureNotify(); + void updateResize() { moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h); } static void grabPointer(Window grab_window, Bool owner_events, @@ -553,6 +554,7 @@ private: uint64_t m_last_keypress_time; FbTk::Timer m_timer; FbTk::Timer m_tabActivationTimer; + FbTk::Timer m_resizeTimer; // Window states bool moving, resizing, m_initialized; @@ -565,6 +567,7 @@ private: int m_last_resize_x, m_last_resize_y; // handles last button press event for resize int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" + int resize_base_x, resize_base_y, resize_base_w, resize_base_h; // opaque and transparent resize alignment int m_last_pressed_button; unsigned int m_workspace_number; -- cgit v0.11.2