From 8bc11006a5ac8c10a539e5a38cdf62205ff386ad Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Tue, 6 Jul 2021 16:56:20 -0700 Subject: Patch from Glen Whitney A priori, there is no reason why the workspace warping functionality should treat the horizontal and vertical directions at all differently. Even if traditionally horizontal warping was more common, for some in recent times as aspect ratios tend to become larger, stacking virtual workspaces vertically may make more sense. Similarly, some might want to traverse an array of workspaces in column-major, rather than row-major, order. Prior to this commit, there were extra parameters for vertical warping (a controlling flag and an offset for how many workspaces to jump) as opposed to horizontal warping. Also it was impossible to allow vertical warping while disallowing vertical warping. This commit makes all of the parameters and behavior for horizontal and vertical warping equivalent. For backwards compatibility, there is an overarching flag controlling whether warping occurs at all, as well as a separate control flag and offset for each of horizontal and vertical warping. The relevant init file resources and default values are: session.screen0.workspaceWarping: true session.screen0.workspaceWarpingHorizontal: true session.screen0.workspaceWarpingVertical: true session.screen0.workspaceWarpingHorizontalOffset: 1 session.screen0.workspaceWarpingVerticalOffset: 1 --- doc/asciidoc/fluxbox.txt | 8 ++++++-- doc/fluxbox.1.in | 7 ++++++- src/Screen.hh | 4 +++- src/ScreenResource.cc | 2 ++ src/ScreenResource.hh | 4 +++- src/Window.cc | 8 +++++--- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/doc/asciidoc/fluxbox.txt b/doc/asciidoc/fluxbox.txt index de96791..a646a66 100644 --- a/doc/asciidoc/fluxbox.txt +++ b/doc/asciidoc/fluxbox.txt @@ -415,8 +415,12 @@ titlebars, not window contents. only an outline of the window will be shown. *Workspace Warping*::: - If enabled, you can drag windows from one workspace to another. The previous - workspace is to the left, the next workspace is to the right. + If enabled, you can drag windows from one workspace to another. There are + parameters to set independently whether this warping happens horizontally + and/or vertically, and in each direction you can set the number of + workspaces to jump when warping (to allow for a virtual rectangular grid + of workspaces). When warping, lower-numbered workspaces are above/to the + left, and higher-numbered workspaces below/to the right. Window Menu ~~~~~~~~~~~ diff --git a/doc/fluxbox.1.in b/doc/fluxbox.1.in index 8d0c1b8..b86ef41 100644 --- a/doc/fluxbox.1.in +++ b/doc/fluxbox.1.in @@ -828,7 +828,12 @@ If enabled, you will see the window content while dragging it\&. Otherwise only .PP \fBWorkspace Warping\fR .RS 4 -If enabled, you can drag windows from one workspace to another\&. The previous workspace is to the left, the next workspace is to the right\&. +If enabled, you can drag windows from one workspace to another\&. There are +parameters to set independently whether this warping happens horizontally +and/or vertically, and in each direction you can set the number of workspaces +to jump when warping (to allow for a virtual rectangular grid of +workspaces)\&. When warping, lower-numbered workspaces are above/to the left, and +higher-numbered workspaces below/to the right\&. .RE .SS "Window Menu" .sp diff --git a/src/Screen.hh b/src/Screen.hh index 83c5cb5..1e03b78 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -95,7 +95,9 @@ public: bool isRootColormapInstalled() const { return root_colormap_installed; } bool isScreenManaged() const { return m_state.managed; } bool isWorkspaceWarping() const { return (m_workspaces_list.size() > 1) && *resource.workspace_warping; } - bool isWorkspaceWarpingVertical() const { return *resource.workspace_warping_vertical; } + bool isWorkspaceWarpingHorizontal() const { return isWorkspaceWarping() && *resource.workspace_warping_horizontal; } + bool isWorkspaceWarpingVertical() const { return isWorkspaceWarping() && *resource.workspace_warping_vertical; } + int getWorkspaceWarpingHorizontalOffset() const { return *resource.workspace_warping_horizontal_offset; } int getWorkspaceWarpingVerticalOffset() const { return *resource.workspace_warping_vertical_offset; } bool doAutoRaise() const { return *resource.auto_raise; } bool clickRaises() const { return *resource.click_raises; } diff --git a/src/ScreenResource.cc b/src/ScreenResource.cc index c5e0027..08a2df1 100644 --- a/src/ScreenResource.cc +++ b/src/ScreenResource.cc @@ -89,7 +89,9 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm, max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), max_disable_resize(rm, false, scrname+".maxDisableResize", altscrname+".MaxDisableResize"), workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"), + workspace_warping_horizontal(rm, true, scrname+".workspacewarpinghorizontal", altscrname+".WorkspaceWarpingHorizontal"), workspace_warping_vertical(rm, true, scrname+".workspacewarpingvertical", altscrname+".WorkspaceWarpingVertical"), + workspace_warping_horizontal_offset(rm, 1, scrname+".workspacewarpinghorizontaloffset", altscrname+".WorkspaceWarpingHorizontalOffset"), workspace_warping_vertical_offset(rm, 1, scrname+".workspacewarpingverticaloffset", altscrname+".WorkspaceWarpingVerticalOffset"), show_window_pos(rm, false, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"), diff --git a/src/ScreenResource.hh b/src/ScreenResource.hh index 120ecf9..5aac6dd 100644 --- a/src/ScreenResource.hh +++ b/src/ScreenResource.hh @@ -38,6 +38,7 @@ struct ScreenResource { max_disable_move, max_disable_resize, workspace_warping, + workspace_warping_horizontal, workspace_warping_vertical, show_window_pos, auto_raise, @@ -56,7 +57,8 @@ struct ScreenResource { menu_delay, tab_width, tooltip_delay, - workspace_warping_vertical_offset; + workspace_warping_horizontal_offset, + workspace_warping_vertical_offset; FbTk::Resource allow_remote_actions; FbTk::Resource clientmenu_use_pixmap; FbTk::Resource tabs_use_pixmap; diff --git a/src/Window.cc b/src/Window.cc index 1f2d184..d761016 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2578,6 +2578,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { const int warp_pad = screen().getEdgeSnapThreshold(); const int workspaces = screen().numberOfWorkspaces(); const bool is_warping = screen().isWorkspaceWarping(); + const bool is_warping_horzntal = screen().isWorkspaceWarpingHorizontal(); const bool is_warping_vertical = screen().isWorkspaceWarpingVertical(); if ((moved_x || moved_y) && is_warping) { @@ -2590,12 +2591,13 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { int bt_top = int(screen().height()) - warp_pad - 1; int bt_bottom = warp_pad; - if (moved_x) { + if (moved_x && is_warping_horzntal) { + const int warp_offset = screen().getWorkspaceWarpingHorizontalOffset(); if (me.x_root >= bt_right && moved_x > 0) { //warp right - new_id = (cur_id + 1) % workspaces; + new_id = (cur_id + warp_offset) % workspaces; m_last_resize_x = 0; } else if (me.x_root <= bt_left && moved_x < 0) { //warp left - new_id = (cur_id + -1) % workspaces; + new_id = (cur_id + workspaces - warp_offset) % workspaces; m_last_resize_x = screen().width() - 1; } } -- cgit v0.11.2