X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fscreen.c;h=330cb0a2e9c804917bc6b9477761f9c50355fc2a;hb=bfb0c916718cd6f68ef100841a625b06602f616b;hp=d5a5194183688c81c3cea835a6bee44d0a7c8024;hpb=85c15cf7b6f66729695609339b21b16649ee92c8;p=chaz%2Fopenbox diff --git a/openbox/screen.c b/openbox/screen.c index d5a51941..330cb0a2 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -48,7 +48,7 @@ #define ROOT_EVENTMASK (StructureNotifyMask | PropertyChangeMask | \ EnterWindowMask | LeaveWindowMask | \ SubstructureRedirectMask | FocusChangeMask | \ - ButtonPressMask | ButtonReleaseMask | ButtonMotionMask) + ButtonPressMask | ButtonReleaseMask) static gboolean screen_validate_layout(ObDesktopLayout *l); static gboolean replace_wm(); @@ -364,13 +364,6 @@ void screen_startup(gboolean reconfig) return; } -#ifdef USE_XCOMPOSITE - /* Redirect window contents to offscreen pixmaps */ - XCompositeRedirectSubwindows(ob_display, - RootWindow(ob_display, ob_screen), - CompositeRedirectAutomatic); -#endif - /* get the initial size */ screen_resize(); @@ -536,10 +529,10 @@ void screen_set_num_desktops(guint num) else if (screen_desktop == num - 1 && (c->desktop == DESKTOP_ALL || c->desktop == screen_desktop)) - stacking_raise(WINDOW_AS_CLIENT(c)); + stacking_raise(CLIENT_AS_WINDOW(c)); } } - + /* change our struts/area to match (after moving windows) */ screen_update_areas(); @@ -559,7 +552,7 @@ void screen_set_desktop(guint num, gboolean dofocus) guint old; gulong ignore_start; gboolean allow_omni; - + g_assert(num < screen_num_desktops); old = screen_desktop; @@ -638,6 +631,82 @@ void screen_set_desktop(guint num, gboolean dofocus) screen_desktop_user_time = event_curtime; } +void screen_add_desktop(gboolean current) +{ + screen_set_num_desktops(screen_num_desktops+1); + + /* move all the clients over */ + if (current) { + GList *it; + + for (it = client_list; it; it = g_list_next(it)) { + ObClient *c = it->data; + if (c->desktop != DESKTOP_ALL && c->desktop >= screen_desktop && + /* don't move direct children, they'll be moved with their + parent - which will have to be on the same desktop */ + !client_direct_parent(c)) + { + ob_debug("moving window %s\n", c->title); + client_set_desktop(c, c->desktop+1, FALSE, TRUE); + } + } + } +} + +void screen_remove_desktop(gboolean current) +{ + guint rmdesktop, movedesktop; + GList *it, *stacking_copy; + + if (screen_num_desktops <= 1) return; + + /* what desktop are we removing and moving to? */ + if (current) + rmdesktop = screen_desktop; + else + rmdesktop = screen_num_desktops - 1; + if (rmdesktop < screen_num_desktops - 1) + movedesktop = rmdesktop + 1; + else + movedesktop = rmdesktop; + + /* make a copy of the list cuz we're changing it */ + stacking_copy = g_list_copy(stacking_list); + for (it = g_list_last(stacking_copy); it; it = g_list_previous(it)) { + if (WINDOW_IS_CLIENT(it->data)) { + ObClient *c = it->data; + guint d = c->desktop; + if (d != DESKTOP_ALL && d >= movedesktop && + /* don't move direct children, they'll be moved with their + parent - which will have to be on the same desktop */ + !client_direct_parent(c)) + { + ob_debug("moving window %s\n", c->title); + client_set_desktop(c, c->desktop - 1, TRUE, TRUE); + } + /* raise all the windows that are on the current desktop which + is being merged */ + if ((screen_desktop == rmdesktop - 1 || + screen_desktop == rmdesktop) && + (d == DESKTOP_ALL || d == screen_desktop)) + { + stacking_raise(CLIENT_AS_WINDOW(c)); + ob_debug("raising window %s\n", c->title); + } + } + } + + /* act like we're changing desktops */ + if (screen_desktop < screen_num_desktops - 1) { + gint d = screen_desktop; + screen_desktop = screen_last_desktop; + screen_set_desktop(d, TRUE); + ob_debug("fake desktop change\n"); + } + + screen_set_num_desktops(screen_num_desktops-1); +} + static void get_row_col(guint d, guint *r, guint *c) { switch (screen_desktop_layout.orientation) { @@ -767,22 +836,14 @@ void screen_desktop_popup(guint d, gboolean show) } } -guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, - gboolean dialog, gboolean done, gboolean cancel) +guint screen_find_desktop(guint from, ObDirection dir, + gboolean wrap, gboolean linear) { guint r, c; - static guint d = (guint)-1; - guint ret, oldd; + guint d; - if (d == (guint)-1) - d = screen_desktop; - - if ((cancel || done) && dialog) - goto show_cycle_dialog; - - oldd = d; + d = from; get_row_col(d, &r, &c); - if (linear) { switch (dir) { case OB_DIRECTION_EAST: @@ -790,16 +851,20 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, ++d; else if (wrap) d = 0; + else + return from; break; case OB_DIRECTION_WEST: if (d > 0) --d; else if (wrap) d = screen_num_desktops - 1; + else + return from; break; default: - assert(0); - return screen_desktop; + g_assert_not_reached(); + return from; } } else { switch (dir) { @@ -809,16 +874,14 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, if (wrap) c = 0; else - goto show_cycle_dialog; + return from; } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (wrap) { + if (wrap) ++c; - } else { - d = oldd; - goto show_cycle_dialog; - } + else + return from; } break; case OB_DIRECTION_WEST: @@ -827,16 +890,14 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, if (wrap) c = screen_desktop_layout.columns - 1; else - goto show_cycle_dialog; + return from; } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (wrap) { + if (wrap) --c; - } else { - d = oldd; - goto show_cycle_dialog; - } + else + return from; } break; case OB_DIRECTION_SOUTH: @@ -845,16 +906,14 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, if (wrap) r = 0; else - goto show_cycle_dialog; + return from; } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (wrap) { + if (wrap) ++r; - } else { - d = oldd; - goto show_cycle_dialog; - } + else + return from; } break; case OB_DIRECTION_NORTH: @@ -863,30 +922,41 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, if (wrap) r = screen_desktop_layout.rows - 1; else - goto show_cycle_dialog; + return from; } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (wrap) { + if (wrap) --r; - } else { - d = oldd; - goto show_cycle_dialog; - } + else + return from; } break; default: - assert(0); - return d = screen_desktop; + g_assert_not_reached(); + return from; } d = translate_row_col(r, c); } + return d; +} -show_cycle_dialog: - if (dialog && !cancel && !done) { +guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, + gboolean dialog, gboolean done, gboolean cancel) +{ + static guint d = (guint)-1; + guint ret; + + if (d == (guint)-1) + d = screen_desktop; + + if ((!cancel && !done) || !dialog) + d = screen_find_desktop(d, dir, wrap, linear); + + if (dialog && !cancel && !done) screen_desktop_popup(d, TRUE); - } else + else screen_desktop_popup(0, FALSE); ret = d; @@ -948,7 +1018,7 @@ void screen_update_layout() if (PROP_GETA32(RootWindow(ob_display, ob_screen), net_desktop_layout, cardinal, &data, &num)) { if (num == 3 || num == 4) { - + if (data[0] == prop_atoms.net_wm_orientation_vert) l.orientation = OB_ORIENTATION_VERT; else if (data[0] == prop_atoms.net_wm_orientation_horz) @@ -1030,7 +1100,7 @@ void screen_update_desktop_names() void screen_show_desktop(gboolean show, ObClient *show_only) { GList *it; - + if (show == screen_showing_desktop) return; /* no change */ screen_showing_desktop = show; @@ -1135,6 +1205,15 @@ typedef struct { sl = g_slist_prepend(sl, ss); \ } +#define VALIDATE_STRUTS(sl, side, max) \ +{ \ + GSList *it; \ + for (it = sl; it; it = g_slist_next(it)) { \ + ObScreenStrut *ss = it->data; \ + ss->strut->side = MIN(max, ss->strut->side); \ + } \ +} + void screen_update_areas() { guint i, j; @@ -1142,11 +1221,19 @@ void screen_update_areas() GList *it; GSList *sit; - ob_debug("updating screen areas\n"); - g_free(monitor_area); extensions_xinerama_screens(&monitor_area, &screen_num_monitors); + /* set up the user-specified margins */ + config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]); + config_margins.top_end = RECT_RIGHT(monitor_area[screen_num_monitors]); + config_margins.bottom_start = RECT_LEFT(monitor_area[screen_num_monitors]); + config_margins.bottom_end = RECT_RIGHT(monitor_area[screen_num_monitors]); + config_margins.left_start = RECT_TOP(monitor_area[screen_num_monitors]); + config_margins.left_end = RECT_BOTTOM(monitor_area[screen_num_monitors]); + config_margins.right_start = RECT_TOP(monitor_area[screen_num_monitors]); + config_margins.right_end = RECT_BOTTOM(monitor_area[screen_num_monitors]); + dims = g_new(gulong, 4 * screen_num_desktops * screen_num_monitors); RESET_STRUT_LIST(struts_left); @@ -1175,6 +1262,24 @@ void screen_update_areas() if (dock_strut.bottom) ADD_STRUT_TO_LIST(struts_bottom, DESKTOP_ALL, &dock_strut); + if (config_margins.left) + ADD_STRUT_TO_LIST(struts_left, DESKTOP_ALL, &config_margins); + if (config_margins.top) + ADD_STRUT_TO_LIST(struts_top, DESKTOP_ALL, &config_margins); + if (config_margins.right) + ADD_STRUT_TO_LIST(struts_right, DESKTOP_ALL, &config_margins); + if (config_margins.bottom) + ADD_STRUT_TO_LIST(struts_bottom, DESKTOP_ALL, &config_margins); + + VALIDATE_STRUTS(struts_left, left, + monitor_area[screen_num_monitors].width / 2); + VALIDATE_STRUTS(struts_right, right, + monitor_area[screen_num_monitors].width / 2); + VALIDATE_STRUTS(struts_top, top, + monitor_area[screen_num_monitors].height / 2); + VALIDATE_STRUTS(struts_bottom, bottom, + monitor_area[screen_num_monitors].height / 2); + /* set up the work areas to be full screen */ for (i = 0; i < screen_num_monitors; ++i) for (j = 0; j < screen_num_desktops; ++j) { @@ -1224,8 +1329,10 @@ void screen_update_areas() dims[(i * screen_num_desktops + j) * 4 + 3] -= t + b; } + /* all the work areas are not used here, only the ones for the first + monitor are */ PROP_SETA32(RootWindow(ob_display, ob_screen), net_workarea, cardinal, - dims, 4 * screen_num_desktops * screen_num_monitors); + dims, 4 * screen_num_desktops); /* the area has changed, adjust all the windows if they need it */ for (it = client_list; it; it = g_list_next(it)) @@ -1256,7 +1363,7 @@ Rect* screen_area_all_monitors(guint desktop) g_free(m); } - + return a; } #endif @@ -1448,7 +1555,9 @@ Rect* screen_physical_area_active() Rect *a; gint x, y; - if (focus_client) + if (moveresize_client) + a = screen_physical_area_monitor(client_monitor(focus_client)); + else if (focus_client) a = screen_physical_area_monitor(client_monitor(focus_client)); else { Rect mon;