X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fscreen.c;h=4412027e0845bf80020c43f8b52b54f920fa5aca;hb=5c01dc651a220ad1ccce9502da577d81f1877388;hp=15b3c8d80ccaa69d3e5a4b1707a7680fee49f448;hpb=7ea56abf05b9e6cd4e806dbfa1146562378edc7b;p=chaz%2Fopenbox diff --git a/openbox/screen.c b/openbox/screen.c index 15b3c8d8..4412027e 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -409,7 +409,7 @@ void screen_startup(gboolean reconfig) arguments, you can use %1$d for the first one and %2$d for the second one. For example, "The current session has %2$d desktops, but Openbox is configured for %1$d ..." */ - g_warning(_("Openbox is configured for %d desktops, but the current session has %d. Overriding the Openbox configuration."), + g_warning(ngettext("Openbox is configured for %d desktop, but the current session has %d. Overriding the Openbox configuration.", "Openbox is configured for %d desktops, but the current session has %d. Overriding the Openbox configuration.", config_desktops_num), config_desktops_num, d); } screen_set_num_desktops(d); @@ -715,6 +715,15 @@ void screen_set_desktop(guint num, gboolean dofocus) if (WINDOW_IS_CLIENT(it->data)) { ObClient *c = it->data; client_hide(c); + if (c == focus_client) { + /* c was focused and we didn't do fallback clearly so make sure + openbox doesnt still consider the window focused. + this happens when using NextWindow with allDesktops, since + it doesnt want to move focus on desktop change, but the + focus is not going to stay with the current window, which + has now disappeared */ + focus_set_client(NULL); + } } } @@ -933,7 +942,7 @@ void screen_show_desktop_popup(guint d) /* 0 means don't show the popup */ if (!config_desktop_popup_time) return; - a = screen_physical_area_active(); + a = screen_physical_area_primary(); pager_popup_position(desktop_popup, CenterGravity, a->x + a->width / 2, a->y + a->height / 2); pager_popup_icon_size_multiplier(desktop_popup, @@ -1418,6 +1427,18 @@ void screen_update_areas(void) b = MAX(b, s->strut->bottom); } + /* if the monitor is not against the edge of the root window, + the struts will include the distance from the root window's edge + to the monitor, so add that back into the monitor's work area */ + if (l) l += RECT_LEFT (monitor_area[screen_num_monitors]) + - RECT_LEFT (monitor_area[i]); + if (t) t += RECT_TOP (monitor_area[screen_num_monitors]) + - RECT_TOP (monitor_area[i]); + if (r) r -= RECT_RIGHT (monitor_area[screen_num_monitors]) + - RECT_RIGHT (monitor_area[i]); + if (b) b -= RECT_BOTTOM(monitor_area[screen_num_monitors]) + - RECT_BOTTOM(monitor_area[i]); + /* based on these margins, set the work area for the monitor/desktop */ dims[(i * screen_num_desktops + j) * 4 + 0] += l; @@ -1558,28 +1579,32 @@ Rect* screen_area(guint desktop, guint head, Rect *search) if ((s->desktop == d || s->desktop == DESKTOP_ALL) && STRUT_LEFT_IN_SEARCH(s->strut, search) && !STRUT_LEFT_IGNORE(s->strut, us, search)) - l = MAX(l, al + s->strut->left); + l = MAX(l, RECT_LEFT(monitor_area[screen_num_monitors]) + + s->strut->left); } for (it = struts_top; it; it = g_slist_next(it)) { ObScreenStrut *s = it->data; if ((s->desktop == d || s->desktop == DESKTOP_ALL) && STRUT_TOP_IN_SEARCH(s->strut, search) && !STRUT_TOP_IGNORE(s->strut, us, search)) - t = MAX(t, at + s->strut->top); + t = MAX(t, RECT_TOP(monitor_area[screen_num_monitors]) + + s->strut->top); } for (it = struts_right; it; it = g_slist_next(it)) { ObScreenStrut *s = it->data; if ((s->desktop == d || s->desktop == DESKTOP_ALL) && STRUT_RIGHT_IN_SEARCH(s->strut, search) && !STRUT_RIGHT_IGNORE(s->strut, us, search)) - r = MIN(r, ar - s->strut->right); + r = MIN(r, RECT_RIGHT(monitor_area[screen_num_monitors]) + - s->strut->right); } for (it = struts_bottom; it; it = g_slist_next(it)) { ObScreenStrut *s = it->data; if ((s->desktop == d || s->desktop == DESKTOP_ALL) && STRUT_BOTTOM_IN_SEARCH(s->strut, search) && !STRUT_BOTTOM_IGNORE(s->strut, us, search)) - b = MIN(b, ab - s->strut->bottom); + b = MIN(b, RECT_BOTTOM(monitor_area[screen_num_monitors]) + - s->strut->bottom); } /* limit to this monitor */ @@ -1647,24 +1672,38 @@ gboolean screen_physical_area_monitor_contains(guint head, Rect *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(focus_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) @@ -1677,6 +1716,17 @@ 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;