diff -ur openbox-3.1/openbox/action.c openbox-3.1.new/openbox/action.c --- openbox-3.1/openbox/action.c 2003-12-22 13:29:27.000000000 -0500 +++ openbox-3.1.new/openbox/action.c 2004-01-10 09:02:40.000000000 -0500 @@ -31,6 +31,7 @@ #include "event.h" #include "config.h" #include "mainloop.h" +#include "extensions.h" #include @@ -792,6 +793,21 @@ setup_action_growtoedge_east }, { + "snapfocustopointer", + action_snapfocustopointer, + NULL + }, + { + "snappointertofocus", + action_snappointertofocus, + NULL + }, + { + "centerviewonfocus", + action_centerviewonfocus, + NULL + }, + { NULL, NULL, NULL @@ -1550,3 +1566,66 @@ { screen_show_desktop(FALSE); } + +void action_snapfocustopointer(union ActionData *data) +{ + focus_fallback(OB_FOCUS_FALLBACK_REFOCUSING); +} + +/* FIXME: This function does not belong here, but I don't have a damn clue + * where to shove it. */ + +/* Credit goes to Tore Anderson for helping me figure out how to do this + * better. And all of the blame now goes to me. */ +void myGetGeometry(ObClient *c, + int *rx, int *ry, unsigned int *rw, unsigned int *rh) +{ + *rx = c->frame->area.x + c->frame->size.left; + *ry = c->frame->area.y + c->frame->size.top; + *rw = c->frame->area.width - c->frame->size.left - c->frame->size.right; + *rh = c->frame->area.height - c->frame->size.top - c->frame->size.bottom; +} + +void action_snappointertofocus(union ActionData *data) +{ + unsigned int x, y, w, h; + + if (!focus_client) + return; + + myGetGeometry(focus_client, &x, &y, &w, &h); + + XWarpPointer(ob_display, None, focus_client->window, 0, 0, 0, 0, w/2, h/2); +} + +void action_centerviewonfocus(union ActionData *data) +{ +#ifdef VIDMODE + unsigned int x, y, w, h, vx, vy, vw, vh; + gint dot; + XF86VidModeModeLine mode; + + if (!focus_client) + return; + + if (extensions_vidmode && + XF86VidModeGetViewPort(ob_display, ob_screen, &vx, &vy) && + /* get the mode last so the mode.privsize isnt freed incorrectly */ + XF86VidModeGetModeLine(ob_display, ob_screen, &dot, &mode)) { + vw = mode.hdisplay; + vh = mode.vdisplay; + if (mode.privsize) XFree(mode.private); + + myGetGeometry(focus_client, &x, &y, &w, &h); + x += w/2; + y += h/2; + x -= vw/2; + y -= vh/2; + if (x < 0) + x = 0; + if (y < 0) + y = 0; + XF86VidModeSetViewPort(ob_display, ob_screen, x, y); + } +#endif +} diff -ur openbox-3.1/openbox/action.h openbox-3.1.new/openbox/action.h --- openbox-3.1/openbox/action.h 2003-10-14 23:59:35.000000000 -0400 +++ openbox-3.1.new/openbox/action.h 2004-01-09 15:57:47.000000000 -0500 @@ -311,5 +311,11 @@ void action_show_desktop(union ActionData *data); /* Any */ void action_unshow_desktop(union ActionData *data); +/* Any */ +void action_snapfocustopointer(union ActionData *data); +/* Any */ +void action_snappointertofocus(union ActionData *data); +/* Any */ +void action_centerviewonfocus(union ActionData *data); #endif diff -ur openbox-3.1/openbox/focus.h openbox-3.1.new/openbox/focus.h --- openbox-3.1/openbox/focus.h 2003-10-09 15:17:51.000000000 -0400 +++ openbox-3.1.new/openbox/focus.h 2004-01-08 08:31:28.000000000 -0500 @@ -46,6 +46,8 @@ void focus_set_client(struct _ObClient *client); typedef enum { + OB_FOCUS_FALLBACK_REFOCUSING, /*!< forcefully check to see who should have + focus (may be current window) */ OB_FOCUS_FALLBACK_UNFOCUSING, /*!< forcefully remove focus from the current window */ OB_FOCUS_FALLBACK_NOFOCUS /*!< nothing has focus for some reason */