<!-- 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>
gboolean config_place_center;
ObPlaceMonitor config_place_monitor;
+guint config_primary_monitor_index;
+ObPlaceMonitor config_primary_monitor;
+
StrutPartial config_margins;
gchar *config_theme;
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,
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);
STRUT_PARTIAL_SET(config_margins, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
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;
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);
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);
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);
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. */
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)
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)
{
Window w;
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 */
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