all repos — fluxbox @ 7cb7bfaa448003466315ccc21d08b71f5c77df70

custom fork of the fluxbox windowmanager

Support 'vertical' Workspace warping

'Vertical' Workspace warping is a variant of the existing Workspace
warping feature: When a user drags a window to the edge of the Screen,
the window is warped to the next / previous workspace.

'Vertical' Workspace warping detects a drag towards the upper / lower
border of the screen and warps the current workspace about an 'offset'.
Example given, lets say the user has 9 workspaces and considers them to
form a 3x3 grid:

  +-+-+-+
  |1|2|3|
  +-+-+-+
  |4|5|6|
  +-+-+-+
  |7|8|9|
  +-+-+-+

An 'offset' of 3 warps from workspaces 2 to workspace 5 (or 8), when a
window is dragged to the bottom / top border.

New configuration ressources:

    session.screenN.workspacewarpingvertical: true
    session.screenN.workspacewarpingverticaloffset: X
Mark Murawski markm@intellasoft.net
commit

7cb7bfaa448003466315ccc21d08b71f5c77df70

parent

0090dc8a6ba4b5c360ecda470b316e630b85c30c

4 files changed, 58 insertions(+), 16 deletions(-)

jump to
M src/Screen.hhsrc/Screen.hh

@@ -95,6 +95,8 @@

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; } + int getWorkspaceWarpingVerticalOffset() const { return *resource.workspace_warping_vertical_offset; } bool doAutoRaise() const { return *resource.auto_raise; } bool clickRaises() const { return *resource.click_raises; } bool doOpaqueMove() const { return *resource.opaque_move; }
M src/ScreenResource.ccsrc/ScreenResource.cc

@@ -88,6 +88,8 @@ max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"),

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_vertical(rm, true, scrname+".workspacewarpingvertical", altscrname+".WorkspaceWarpingVertical"), + 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"), click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"),
M src/ScreenResource.hhsrc/ScreenResource.hh

@@ -37,6 +37,7 @@ max_ignore_inc,

max_disable_move, max_disable_resize, workspace_warping, + workspace_warping_vertical, show_window_pos, auto_raise, click_raises;

@@ -53,7 +54,8 @@ unfocused_alpha,

menu_alpha, menu_delay, tab_width, - tooltip_delay; + tooltip_delay, + workspace_warping_vertical_offset; FbTk::Resource<bool> allow_remote_actions; FbTk::Resource<bool> clientmenu_use_pixmap; FbTk::Resource<bool> tabs_use_pixmap;
M src/Window.ccsrc/Window.cc

@@ -2539,6 +2539,10 @@ const bool xor_outline = m_attaching_tab || !screen().doOpaqueMove();

// Warp to next or previous workspace?, must have moved sideways some int moved_x = me.x_root - m_last_resize_x; + + // Warp to a workspace offset (if treating workspaces like a grid) + int moved_y = me.y_root - m_last_resize_y; + // save last event point m_last_resize_x = me.x_root; m_last_resize_y = me.y_root;

@@ -2554,25 +2558,57 @@ m_last_move_x, m_last_move_y, w, h);

} } - if (moved_x && screen().isWorkspaceWarping()) { + + // check for warping + // + // +--monitor-1--+--monitor-2---+ + // |w | w| + // |w | w| + // +-------------+--------------+ + // + // mouse-warping is enabled, the mouse needs to be in the "warp_pad" + // zone. + // + const int warp_pad = screen().getEdgeSnapThreshold(); + const int workspaces = screen().numberOfWorkspaces(); + const bool is_warping = screen().isWorkspaceWarping(); + const bool is_warping_vertical = screen().isWorkspaceWarpingVertical(); + + if ((moved_x || moved_y) && is_warping) { unsigned int cur_id = screen().currentWorkspaceID(); unsigned int new_id = cur_id; - const int warpPad = screen().getEdgeSnapThreshold(); - // 1) if we're inside the border threshold - // 2) if we moved in the right direction - if (me.x_root >= int(screen().width()) - warpPad - 1 && - moved_x > 0) { - //warp right - new_id = (cur_id + 1) % screen().numberOfWorkspaces(); - m_last_resize_x = 0; // move mouse back to x=0 - } else if (me.x_root <= warpPad && - moved_x < 0) { - //warp left - new_id = (cur_id + screen().numberOfWorkspaces() - 1) % screen().numberOfWorkspaces(); - m_last_resize_x = screen().width() - 1; // move mouse to screen width - 1 + + // border threshold + int bt_right = int(screen().width()) - warp_pad - 1; + int bt_left = warp_pad; + int bt_top = int(screen().height()) - warp_pad - 1; + int bt_bottom = warp_pad; + + if (moved_x) { + if (me.x_root >= bt_right && moved_x > 0) { //warp right + new_id = (cur_id + 1) % workspaces; + m_last_resize_x = 0; + } else if (me.x_root <= bt_left && moved_x < 0) { //warp left + new_id = (cur_id + -1) % workspaces; + m_last_resize_x = screen().width() - 1; + } + } + + if (moved_y && is_warping_vertical) { + + const int warp_offset = screen().getWorkspaceWarpingVerticalOffset(); + + if (me.y_root >= bt_top && moved_y > 0) { // warp down + new_id = (cur_id + warp_offset) % workspaces; + m_last_resize_y = 0; + } else if (me.y_root <= bt_bottom && moved_y < 0) { // warp up + new_id = (cur_id + workspaces - warp_offset) % workspaces; + m_last_resize_y = screen().height() - 1; + } } - if (new_id != cur_id) { + // if we are warping + if (new_id != cur_id) { // remove motion events from queue to avoid repeated warps while (XCheckTypedEvent(display, MotionNotify, &e)) { // might as well update the y-coordinate