diff --git a/src/Screen.hh b/src/Screen.hh index 30fbb4aa..15eb349d 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -95,6 +95,8 @@ 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; } + 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; } diff --git a/src/ScreenResource.cc b/src/ScreenResource.cc index dbf532b2..c1886480 100644 --- a/src/ScreenResource.cc +++ b/src/ScreenResource.cc @@ -88,6 +88,8 @@ 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_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"), diff --git a/src/ScreenResource.hh b/src/ScreenResource.hh index 7f1e6213..bc782e12 100644 --- a/src/ScreenResource.hh +++ b/src/ScreenResource.hh @@ -37,6 +37,7 @@ struct ScreenResource { max_disable_move, max_disable_resize, workspace_warping, + workspace_warping_vertical, show_window_pos, auto_raise, click_raises; @@ -53,7 +54,8 @@ struct ScreenResource { menu_alpha, menu_delay, tab_width, - tooltip_delay; + tooltip_delay, + 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 23c97897..6714d0af 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2539,6 +2539,10 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { // 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 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { } } - 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 - } - if (new_id != cur_id) { + // 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 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