all repos — openbox @ aa329719b99792a624449b2448abee9e2c67ce94

openbox fork - make it a bit more like ryudo

Add a primaryMonitor config option, where the focus-cycle and keychain popups will appear
Dana Jansens danakj@orodu.net
commit

aa329719b99792a624449b2448abee9e2c67ce94

parent

10d99cc5e9efe40527c6ace3740b67890ea37729

M data/rc.xmldata/rc.xml

@@ -39,6 +39,12 @@ <monitor>Active</monitor>

<!-- with Smart placement on a multi-monitor system, try to place new windows on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where the active window is --> + <primaryMonitor>1</primaryMonitor> + <!-- The monitor where Openbox should place popup dialogs such as the + focus cycling popup, or the desktop switch popup. It can be an index + from 1, specifying a particular monitor. Or it can be one of the + following: 'Mouse' - where the mouse is, or + 'Active' - where the active window is --> </placement> <theme>
M openbox/config.copenbox/config.c

@@ -40,6 +40,9 @@ ObPlacePolicy config_place_policy;

gboolean config_place_center; ObPlaceMonitor config_place_monitor; +guint config_primary_monitor_index; +ObPlaceMonitor config_primary_monitor; + StrutPartial config_margins; gchar *config_theme;

@@ -529,6 +532,13 @@ config_place_monitor = OB_PLACE_MONITOR_ACTIVE;

else if (parse_contains("mouse", doc, n)) config_place_monitor = OB_PLACE_MONITOR_MOUSE; } + if ((n = parse_find_node("primaryMonitor", node))) { + config_primary_monitor_index = parse_int(doc, n); + if (!config_primary_monitor_index) { + if (parse_contains("mouse", doc, n)) + config_primary_monitor = OB_PLACE_MONITOR_MOUSE; + } + } } static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,

@@ -930,6 +940,9 @@

config_place_policy = OB_PLACE_POLICY_SMART; config_place_center = TRUE; config_place_monitor = OB_PLACE_MONITOR_ANY; + + config_primary_monitor_index = 1; + config_primary_monitor = OB_PLACE_MONITOR_ACTIVE; parse_register(i, "placement", parse_placement, NULL);
M openbox/config.hopenbox/config.h

@@ -83,6 +83,12 @@ /*! Place windows on the active monitor (unless they are part of an application

already on another monitor) */ extern ObPlaceMonitor config_place_monitor; +/*! Place dialogs and stuff on this monitor. Index starts at 1. If this is + 0, then use the config_primary_monitor instead. */ +extern guint config_primary_monitor_index; +/*! Where to place dialogs and stuff if it is not specified by index. */ +extern ObPlaceMonitor config_primary_monitor; + /*! User-specified margins around the edge of the screen(s) */ extern StrutPartial config_margins;
M openbox/focus_cycle_popup.copenbox/focus_cycle_popup.c

@@ -261,7 +261,7 @@ GList *it;

const ObFocusCyclePopupTarget *newtarget; gint newtargetx, newtargety; - screen_area = screen_physical_area_active(); + screen_area = screen_physical_area_primary(); /* get the outside margins */ RrMargins(p->a_bg, &ml, &mt, &mr, &mb);

@@ -515,7 +515,7 @@ dock_windows, desktop_windows);

g_assert(popup.targets == NULL); /* position the popup */ - a = screen_physical_area_active(); + a = screen_physical_area_primary(); icon_popup_position(single_popup, CenterGravity, a->x + a->width / 2, a->y + a->height / 2); icon_popup_height(single_popup, POPUP_HEIGHT);
M openbox/keyboard.copenbox/keyboard.c

@@ -91,7 +91,7 @@ text = g_strconcat(text, " - ", it->data, NULL);

g_free(oldtext); } - a = screen_physical_area_active(); + a = screen_physical_area_primary(); popup_position(popup, NorthWestGravity, a->x + 10, a->y + 10); /* 1 second delay for the popup to show */ popup_delay_show(popup, G_USEC_PER_SEC, text);
M openbox/place.copenbox/place.c

@@ -43,20 +43,7 @@ }

static Rect *pick_pointer_head(ObClient *c) { - guint i; - gint px, py; - - if (screen_pointer_pos(&px, &py)) { - for (i = 0; i < screen_num_monitors; ++i) { - Rect *monitor = screen_physical_area_monitor(i); - gboolean contain = RECT_CONTAINS(*monitor, px, py); - g_free(monitor); - if (contain) - return screen_area(c->desktop, i, NULL); - } - g_assert_not_reached(); - } else - return NULL; + return screen_area(c->desktop, screen_monitor_pointer(), NULL); } /*! Pick a monitor to place a window on. */
M openbox/screen.copenbox/screen.c

@@ -1723,24 +1723,38 @@ g_assert(search);

return RECT_INTERSECTS_RECT(monitor_area[head], *search); } -Rect* screen_physical_area_active(void) +guint screen_monitor_active(void) { - Rect *a; - gint x, y; - if (moveresize_client) - a = screen_physical_area_monitor(client_monitor(moveresize_client)); + return client_monitor(moveresize_client); else if (focus_client) - a = screen_physical_area_monitor(client_monitor(focus_client)); - else { - Rect mon; - if (screen_pointer_pos(&x, &y)) - RECT_SET(mon, x, y, 1, 1); + return client_monitor(focus_client); + else + return screen_monitor_pointer(); +} + +Rect* screen_physical_area_active(void) +{ + return screen_physical_area_monitor(screen_monitor_active()); +} + +guint screen_monitor_primary(void) +{ + if (config_primary_monitor_index > 0) { + if (config_primary_monitor_index-1 < screen_num_monitors) + return config_primary_monitor_index - 1; else - RECT_SET(mon, 0, 0, 1, 1); - a = screen_physical_area_monitor(screen_find_monitor(&mon)); + return 0; } - return a; + else if (config_primary_monitor == OB_PLACE_MONITOR_ACTIVE) + return screen_monitor_active(); + else /* config_primary_monitor == OB_PLACE_MONITOR_MOUSE */ + return screen_monitor_pointer(); +} + +Rect *screen_physical_area_primary(void) +{ + return screen_physical_area_monitor(screen_monitor_primary()); } void screen_set_root_cursor(void)

@@ -1751,6 +1765,17 @@ ob_cursor(OB_CURSOR_BUSYPOINTER));

else XDefineCursor(ob_display, RootWindow(ob_display, ob_screen), ob_cursor(OB_CURSOR_POINTER)); +} + +guint screen_monitor_pointer() +{ + Rect mon; + gint x, y; + if (screen_pointer_pos(&x, &y)) + RECT_SET(mon, x, y, 1, 1); + else + RECT_SET(mon, 0, 0, 1, 1); + return screen_find_monitor(&mon); } gboolean screen_pointer_pos(gint *x, gint *y)
M openbox/screen.hopenbox/screen.h

@@ -104,7 +104,16 @@ Rect *screen_physical_area_all_monitors();

Rect *screen_physical_area_monitor(guint head); -Rect *screen_physical_area_active(); +/*! Returns the monitor which contains the active window, or the one + containing the pointer otherwise. */ +guint screen_monitor_active(void); + +Rect *screen_physical_area_active(void); + +/*! Returns the primary monitor, as specified by the config */ +guint screen_monitor_primary(void); + +Rect *screen_physical_area_primary(void); /* doesn't include struts which the search area is already outside of when 'search' is not NULL */

@@ -132,5 +141,8 @@

/*! Gives back the pointer's position in x and y. Returns TRUE if the pointer is on this screen and FALSE if it is on another screen. */ gboolean screen_pointer_pos(gint *x, gint *y); + +/*! Returns the monitor which contains the pointer device */ +guint screen_monitor_pointer(void); #endif