summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2010-04-16 18:55:33 -0400
committerDana Jansens <danakj@orodu.net>2010-04-16 21:32:38 -0400
commit77ee361f5cedb415c1189b0a75bde83a1a275f35 (patch)
tree40f07ac06f38478cfa0767ccad1e4ea79234c80b
parentb05ac359b8a5a91cd2a115ba4612e8acfdf1d8d6 (diff)
allow warping the mouse pointer when switching desktops by bumping into the edge of the monitor with a window
based on a patch by Nathaniel Gephart <computinchuck@gmail.com>
-rw-r--r--data/rc.xml3
-rw-r--r--data/rc.xsd1
-rw-r--r--openbox/config.c10
-rw-r--r--openbox/config.h3
-rw-r--r--openbox/moveresize.c33
5 files changed, 46 insertions, 4 deletions
diff --git a/data/rc.xml b/data/rc.xml
index d1b387a1..e4376a4b 100644
--- a/data/rc.xml
+++ b/data/rc.xml
@@ -318,6 +318,9 @@
<!-- Time before changing desktops when the pointer touches the edge of the
screen while moving a window, in milliseconds (1000 = 1 second).
Set this to 0 to disable warping -->
+ <screenEdgeWarpMouse>false</screenEdgeWarpMouse>
+ <!-- Set this to TRUE to move the mouse pointer across the desktop when
+ switching due to hitting the edge of the screen -->
<context name="Frame">
<mousebind button="A-Left" action="Press">
diff --git a/data/rc.xsd b/data/rc.xsd
index 2fed1f48..3a1d654a 100644
--- a/data/rc.xsd
+++ b/data/rc.xsd
@@ -210,6 +210,7 @@
<xsd:element minOccurs="0" name="dragThreshold" type="xsd:integer"/>
<xsd:element minOccurs="0" name="doubleClickTime" type="xsd:integer"/>
<xsd:element minOccurs="0" name="screenEdgeWarpTime" type="xsd:integer"/>
+ <xsd:element minOccurs="0" name="screenEdgeWarpMouse" type="ob:bool"/>
<xsd:element maxOccurs="unbounded" name="context" type="ob:context"/>
</xsd:sequence>
</xsd:complexType>
diff --git a/openbox/config.c b/openbox/config.c
index bf0facda..573ce4c2 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -86,9 +86,10 @@ guint config_dock_app_move_modifiers;
guint config_keyboard_reset_keycode;
guint config_keyboard_reset_state;
-gint config_mouse_threshold;
-gint config_mouse_dclicktime;
-gint config_mouse_screenedgetime;
+gint config_mouse_threshold;
+gint config_mouse_dclicktime;
+gint config_mouse_screenedgetime;
+gboolean config_mouse_screenedgewarp;
guint config_menu_hide_delay;
gboolean config_menu_middle;
@@ -465,6 +466,8 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
if (config_mouse_screenedgetime && config_mouse_screenedgetime < 25)
config_mouse_screenedgetime = 25;
}
+ if ((n = obt_xml_find_node(node, "screenEdgeWarpMouse")))
+ config_mouse_screenedgewarp = obt_xml_node_bool(n);
n = obt_xml_find_node(node, "context");
while (n) {
@@ -1030,6 +1033,7 @@ void config_startup(ObtXmlInst *i)
config_mouse_threshold = 8;
config_mouse_dclicktime = 200;
config_mouse_screenedgetime = 400;
+ config_mouse_screenedgewarp = FALSE;
bind_default_mouse();
diff --git a/openbox/config.h b/openbox/config.h
index 818dcc76..90b6581a 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -180,6 +180,9 @@ extern gint config_mouse_dclicktime;
/*! Number of milliseconds that the mouse has to be on the screen edge before
a screen edge event is triggered */
extern gint config_mouse_screenedgetime;
+/*! When TRUE, the mouse is warped to the other side of the desktop after
+ switching desktops from bumping the screen edge */
+extern gboolean config_mouse_screenedgewarp;
/*! Number of pixels to resist while crossing another window's edge */
extern gint config_resist_win;
diff --git a/openbox/moveresize.c b/openbox/moveresize.c
index 8609d3be..aa1957af 100644
--- a/openbox/moveresize.c
+++ b/openbox/moveresize.c
@@ -529,6 +529,34 @@ static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
*dh = nh - oh;
}
+static void edge_warp_move_ptr(void)
+{
+ gint x, y;
+ const Rect* a;
+
+ screen_pointer_pos(&x, &y);
+ a = screen_physical_area_all_monitors();
+
+ switch (edge_warp_dir) {
+ case OB_DIRECTION_NORTH:
+ y = a->height - 1;
+ break;
+ case OB_DIRECTION_EAST:
+ x = a->x;
+ break;
+ case OB_DIRECTION_SOUTH:
+ y = a->y;
+ break;
+ case OB_DIRECTION_WEST:
+ x = a->width - 1;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ XWarpPointer(obt_display, 0, obt_root(ob_screen), 0, 0, 0, 0, x, y);
+}
+
static gboolean edge_warp_delay_func(gpointer data)
{
guint d;
@@ -537,7 +565,10 @@ static gboolean edge_warp_delay_func(gpointer data)
after that */
if (edge_warp_odd) {
d = screen_find_desktop(screen_desktop, edge_warp_dir, TRUE, FALSE);
- if (d != screen_desktop) screen_set_desktop(d, TRUE);
+ if (d != screen_desktop) {
+ if (config_mouse_screenedgewarp) edge_warp_move_ptr();
+ screen_set_desktop(d, TRUE);
+ }
}
edge_warp_odd = !edge_warp_odd;