X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fscreen.c;h=79008e75c2ecbe082f62c7cfb84682811ba050ef;hb=6593261f30d611ff3b71abdb9fd043851fdd2ca9;hp=926b21e45d8ea4d75d400e82f5a4d88986185c62;hpb=8bcd349e4e7078e663d3092a6ad6c7aff8eb05a0;p=chaz%2Fopenbox diff --git a/openbox/screen.c b/openbox/screen.c index 926b21e4..79008e75 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -27,7 +27,6 @@ #include "moveresize.h" #include "config.h" #include "screen.h" -#include "composite.h" #include "client.h" #include "session.h" #include "frame.h" @@ -49,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(); @@ -108,22 +107,7 @@ static gboolean replace_wm() current_wm_sn_owner = None; } - { - /* Generate a timestamp */ - XEvent event; - - XSelectInput(ob_display, screen_support_win, PropertyChangeMask); - - XChangeProperty(ob_display, screen_support_win, - prop_atoms.wm_class, prop_atoms.string, - 8, PropModeAppend, NULL, 0); - XWindowEvent(ob_display, screen_support_win, - PropertyChangeMask, &event); - - XSelectInput(ob_display, screen_support_win, NoEventMask); - - timestamp = event.xproperty.time; - } + timestamp = event_get_server_time(); XSetSelectionOwner(ob_display, wm_sn_atom, screen_support_win, timestamp); @@ -173,12 +157,14 @@ gboolean screen_annex() /* create the netwm support window */ attrib.override_redirect = TRUE; + attrib.event_mask = PropertyChangeMask; screen_support_win = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen), -100, -100, 1, 1, 0, CopyFromParent, InputOutput, CopyFromParent, - CWOverrideRedirect, &attrib); + CWEventMask | CWOverrideRedirect, + &attrib); XMapWindow(ob_display, screen_support_win); XLowerWindow(ob_display, screen_support_win); @@ -284,7 +270,9 @@ gboolean screen_annex() supported[i++] = prop_atoms.net_moveresize_window; supported[i++] = prop_atoms.net_wm_moveresize; supported[i++] = prop_atoms.net_wm_user_time; +/* supported[i++] = prop_atoms.net_wm_user_time_window; +*/ supported[i++] = prop_atoms.net_frame_extents; supported[i++] = prop_atoms.net_request_frame_extents; supported[i++] = prop_atoms.net_restack_window; @@ -491,9 +479,6 @@ void screen_resize() for (it = client_list; it; it = g_list_next(it)) client_move_onscreen(it->data, FALSE); - - /* this needs to be setup whenever the root window's size changes */ - composite_setup_root_window(); } void screen_set_num_desktops(guint num) @@ -536,7 +521,7 @@ void screen_set_num_desktops(guint num) stacking_raise(CLIENT_AS_WINDOW(c)); } } - + /* change our struts/area to match (after moving windows) */ screen_update_areas(); @@ -556,7 +541,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; @@ -645,8 +630,14 @@ void screen_add_desktop(gboolean current) for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; - if (c->desktop != DESKTOP_ALL && c->desktop >= screen_desktop) + 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); + } } } } @@ -674,9 +665,13 @@ void screen_remove_desktop(gboolean current) if (WINDOW_IS_CLIENT(it->data)) { ObClient *c = it->data; guint d = c->desktop; - if (d != DESKTOP_ALL && d >= movedesktop) { - client_set_desktop(c, c->desktop - 1, TRUE, TRUE); + 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 */ @@ -830,22 +825,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; - - if (d == (guint)-1) - d = screen_desktop; - - if ((cancel || done) && dialog) - goto show_cycle_dialog; + guint d; - oldd = d; + d = from; get_row_col(d, &r, &c); - if (linear) { switch (dir) { case OB_DIRECTION_EAST: @@ -853,16 +840,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) { @@ -872,16 +863,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: @@ -890,16 +879,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: @@ -908,16 +895,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: @@ -926,30 +911,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; +} + +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; -show_cycle_dialog: - if (dialog && !cancel && !done) { + 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; @@ -1011,7 +1007,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) @@ -1093,7 +1089,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; @@ -1198,6 +1194,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; @@ -1205,11 +1210,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); @@ -1238,6 +1251,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) { @@ -1287,8 +1318,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)) @@ -1319,7 +1352,7 @@ Rect* screen_area_all_monitors(guint desktop) g_free(m); } - + return a; } #endif @@ -1511,7 +1544,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;