I have ported the under-mouse placement scheme to openbox3. Functionality is exactly duplicated from openbox2. To enable, one must add <placement><scheme>undermouse</scheme></placement> to the rc.xml configuration file. This allows room for future placement schema and configuration options. The patch follows against CVS. Files modified are config.h, config.c and place.c. Index: openbox/config.c =================================================================== RCS file: /cvs/cvsroot/openbox/openbox/config.c,v retrieving revision 1.44 diff -c -r1.44 config.c *** openbox/config.c 2003/09/04 02:36:05 1.44 --- openbox/config.c 2003/09/04 18:26:25 *************** *** 12,17 **** --- 12,19 ---- gboolean config_focus_last_on_desktop; guint config_focus_delay; + gboolean config_place_umouse; + char *config_theme; gchar *config_title_layout; *************** *** 355,360 **** --- 357,372 ---- config_resist_edge = parse_int(doc, n); } + static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, + void *d) + { + xmlNodePtr n; + node = node->xmlChildrenNode; + if ((n = parse_find_node("scheme", node))) + if (parse_contains("undermouse", doc, n)) + config_place_umouse = TRUE; + } + void config_startup(ObParseInst *i) { config_focus_new = TRUE; *************** *** 364,369 **** --- 376,385 ---- config_focus_delay = 0; parse_register(i, "focus", parse_focus, NULL); + + config_place_umouse = FALSE; + + parse_register(i, "placement", parse_placement, NULL); config_theme = NULL; Index: openbox/config.h =================================================================== RCS file: /cvs/cvsroot/openbox/openbox/config.h,v retrieving revision 1.29 diff -c -r1.29 config.h *** openbox/config.h 2003/09/03 08:12:07 1.29 --- openbox/config.h 2003/09/04 18:26:26 *************** *** 19,24 **** --- 19,27 ---- /*! Timeout for focusing windows on focus follows mouse, in microseconds */ extern guint config_focus_delay; + /*! Use undermouse placement */ + extern gboolean config_place_umouse; + /*! When true windows' contents are refreshed while they are resized; otherwise they are not updated until the resize is complete */ extern gboolean config_redraw_resize; Index: openbox/place.c =================================================================== RCS file: /cvs/cvsroot/openbox/openbox/place.c,v retrieving revision 1.1 diff -c -r1.1 place.c *** openbox/place.c 2003/08/29 06:40:35 1.1 --- openbox/place.c 2003/09/04 18:26:26 *************** *** 3,8 **** --- 3,10 ---- #include "screen.h" #include "frame.h" + extern gboolean config_place_umouse; + static Rect* pick_head(ObClient *c) { /* try direct parent first */ *************** *** 37,42 **** --- 39,79 ---- return NULL; } + /* Attempts to recreate the Ob2 Placement Under Mouse method. */ + static gboolean place_umouse(ObClient *c, gint *x, gint *y) + { + int px, py, width, height; + unsigned int i = 0; + Rect *area; + + screen_pointer_pos (&px, &py); + + for (i = 0; i < screen_num_monitors; i++) { + area = screen_area_monitor (c->desktop, i); + if (RECT_CONTAINS(*area, px, py)) break; + } + + if (c->frame != NULL) { + width = c->frame->area.width; + height = c->frame->area.height; + } else { + width = c->area.width; + height = c->area.height; + } + + *x = px - width / 2; + *y = py - height / 2; + + if (*x < area->x) *x = area->x; + if (*y < area->y) *y = area->y; + if (*x + width > area->x + area->width) + *x = area->x + area->width - width; + if (*y + height > area->y + area->height) + *y = area->y + area->height - height; + + return TRUE; + } + static gboolean place_random(ObClient *client, gint *x, gint *y) { int l, r, t, b; *************** *** 130,135 **** --- 167,174 ---- return; if (place_dialog(client, x, y)) return; + if (config_place_umouse && place_umouse(client, x, y)) + return; if (place_random(client, x, y)) return; g_assert_not_reached(); /* the last one better succeed */
Created attachment 102 [details] for 3.0-beta2
This has been added to CVS. Currently it is available as a fallback to smart placement, used when focus-follows-mouse is enabled.
This has been added in CVS.
Created attachment 102 [details] for 3.0-beta2