X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fscreen.c;h=5d640a90950e13e0ff111b5dea29e21133e1794c;hb=174de91c343dfbdfe866e566393bf4790ae22596;hp=628d0344cc176aa34dbc9f5102c60133c1476a90;hpb=9ed3baf9dbf0c4c1dcf4b63262eca03247b50a0d;p=chaz%2Fopenbox diff --git a/openbox/screen.c b/openbox/screen.c index 628d0344..5d640a90 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -54,7 +54,7 @@ guint screen_last_desktop; Size screen_physical_size; gboolean screen_showing_desktop; DesktopLayout screen_desktop_layout; -char **screen_desktop_names; +gchar **screen_desktop_names; Window screen_support_win; static Rect **area; /* array of desktop holding array of xinerama areas */ @@ -64,7 +64,7 @@ static ObPagerPopup *desktop_cycle_popup; static gboolean replace_wm() { - char *wm_sn; + gchar *wm_sn; Atom wm_sn_atom; Window current_wm_sn_owner; Time timestamp; @@ -74,6 +74,8 @@ static gboolean replace_wm() g_free(wm_sn); current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom); + if (current_wm_sn_owner == screen_support_win) + current_wm_sn_owner = None; if (current_wm_sn_owner) { if (!ob_replace_wm) { g_warning("A window manager is already running on screen %d", @@ -279,9 +281,9 @@ void screen_startup(gboolean reconfig) screen_resize(); /* set the names */ - screen_desktop_names = g_new(char*, + screen_desktop_names = g_new(gchar*, g_slist_length(config_desktops_names) + 1); - for (i = 0, it = config_desktops_names; it; ++i, it = it->next) + for (i = 0, it = config_desktops_names; it; ++i, it = g_slist_next(it)) screen_desktop_names[i] = it->data; /* dont strdup */ screen_desktop_names[i] = NULL; PROP_SETSS(RootWindow(ob_display, ob_screen), @@ -334,8 +336,8 @@ void screen_shutdown(gboolean reconfig) void screen_resize() { - static int oldw = 0, oldh = 0; - int w, h; + static gint oldw = 0, oldh = 0; + gint w, h; GList *it; guint32 geometry[2]; @@ -358,7 +360,7 @@ void screen_resize() screen_update_areas(); dock_configure(); - for (it = client_list; it; it = it->next) + for (it = client_list; it; it = g_list_next(it)) client_move_onscreen(it->data, FALSE); } @@ -390,7 +392,7 @@ void screen_set_num_desktops(guint num) screen_update_desktop_names(); /* move windows on desktops that will no longer exist! */ - for (it = client_list; it != NULL; it = it->next) { + for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; if (c->desktop >= num && c->desktop != DESKTOP_ALL) client_set_desktop(c, num - 1, FALSE); @@ -438,16 +440,16 @@ void screen_set_desktop(guint num) /* show windows before hiding the rest to lessen the enter/leave events */ /* show windows from top to bottom */ - for (it = stacking_list; it != NULL; it = it->next) { + for (it = stacking_list; it; it = g_list_next(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *c = it->data; - if (!c->frame->visible && client_should_show(c)) + if (client_should_show(c)) frame_show(c->frame); } } /* hide windows from bottom to top */ - for (it = g_list_last(stacking_list); it != NULL; it = it->prev) { + for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *c = it->data; if (c->frame->visible && !client_should_show(c)) @@ -457,7 +459,18 @@ void screen_set_desktop(guint num) event_ignore_queued_enters(); - focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); + focus_hilite = focus_fallback_target(OB_FOCUS_FALLBACK_NOFOCUS); + if (focus_hilite) { + frame_adjust_focus(focus_hilite->frame, TRUE); + + /*! + When this focus_client check is not used, you can end up with races, + as demonstrated with gnome-panel, sometmies the window you click on + another desktop ends up losing focus cuz of the focus change here. + */ + /*if (!focus_client)*/ + client_focus(focus_hilite); + } } static void get_row_col(guint d, guint *r, guint *c) @@ -572,7 +585,7 @@ void screen_desktop_popup(guint d, gboolean show) { Rect *a; - if (!show || !config_dialog_desktop) { + if (!show) { pager_popup_hide(desktop_cycle_popup); } else { a = screen_physical_area_monitor(0); @@ -633,49 +646,81 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, case OB_DIRECTION_EAST: ++c; if (c >= screen_desktop_layout.columns) { - if (!wrap) return d = screen_desktop; - c = 0; + if (wrap) { + c = 0; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (!wrap) return d = screen_desktop; - ++c; + if (wrap) { + ++c; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } break; case OB_DIRECTION_WEST: --c; if (c >= screen_desktop_layout.columns) { - if (!wrap) return d = screen_desktop; - c = screen_desktop_layout.columns - 1; + if (wrap) { + c = screen_desktop_layout.columns - 1; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (!wrap) return d = screen_desktop; - --c; + if (wrap) { + --c; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } break; case OB_DIRECTION_SOUTH: ++r; if (r >= screen_desktop_layout.rows) { - if (!wrap) return d = screen_desktop; - r = 0; + if (wrap) { + r = 0; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (!wrap) return d = screen_desktop; - ++r; + if (wrap) { + ++r; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } break; case OB_DIRECTION_NORTH: --r; if (r >= screen_desktop_layout.rows) { - if (!wrap) return d = screen_desktop; - r = screen_desktop_layout.rows - 1; + if (wrap) { + r = screen_desktop_layout.rows - 1; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } d = translate_row_col(r, c); if (d >= screen_num_desktops) { - if (!wrap) return d = screen_desktop; - --r; + if (wrap) { + --r; + } else { + d = screen_desktop; + goto show_cycle_dialog; + } } break; default: @@ -686,6 +731,7 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, d = translate_row_col(r, c); } +show_cycle_dialog: if (dialog) { screen_desktop_popup(d, TRUE); return d; @@ -804,7 +850,7 @@ void screen_update_desktop_names() else i = 0; if (i <= screen_num_desktops) { - screen_desktop_names = g_renew(char*, screen_desktop_names, + screen_desktop_names = g_renew(gchar*, screen_desktop_names, screen_num_desktops + 1); screen_desktop_names[screen_num_desktops] = NULL; for (; i < screen_num_desktops; ++i) @@ -821,28 +867,28 @@ void screen_show_desktop(gboolean show) screen_showing_desktop = show; if (show) { - /* bottom to top */ - for (it = g_list_last(stacking_list); it != NULL; it = it->prev) { + /* bottom to top */ + for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *client = it->data; if (client->frame->visible && !client_should_show(client)) frame_hide(client->frame); } - } + } } else { /* top to bottom */ - for (it = stacking_list; it != NULL; it = it->next) { + for (it = stacking_list; it; it = g_list_next(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *client = it->data; if (!client->frame->visible && client_should_show(client)) frame_show(client->frame); } - } + } } if (show) { /* focus desktop */ - for (it = focus_order[screen_desktop]; it; it = it->next) + for (it = focus_order[screen_desktop]; it; it = g_list_next(it)) if (((ObClient*)it->data)->type == OB_CLIENT_TYPE_DESKTOP && client_focus(it->data)) break; @@ -975,7 +1021,7 @@ void screen_update_areas() o = MIN(o, area[i][x].x); for (x = 0; x < screen_num_monitors; ++x) { - for (it = client_list; it; it = it->next) { + for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; screen_area_add_strut_left(&c->strut, &monitor_area[x], @@ -997,7 +1043,7 @@ void screen_update_areas() o = MIN(o, area[i][x].y); for (x = 0; x < screen_num_monitors; ++x) { - for (it = client_list; it; it = it->next) { + for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; screen_area_add_strut_top(&c->strut, &monitor_area[x], @@ -1019,7 +1065,7 @@ void screen_update_areas() o = MAX(o, area[i][x].x + area[i][x].width - 1); for (x = 0; x < screen_num_monitors; ++x) { - for (it = client_list; it; it = it->next) { + for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; screen_area_add_strut_right(&c->strut, &monitor_area[x], @@ -1044,7 +1090,7 @@ void screen_update_areas() o = MAX(o, area[i][x].y + area[i][x].height - 1); for (x = 0; x < screen_num_monitors; ++x) { - for (it = client_list; it; it = it->next) { + for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; screen_area_add_strut_bottom(&c->strut, &monitor_area[x], @@ -1080,7 +1126,7 @@ void screen_update_areas() /* the area has changed, adjust all the maximized windows */ - for (it = client_list; it; it = it->next) { + for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; if (i < screen_num_desktops) { if (c->desktop == i) @@ -1144,10 +1190,10 @@ void screen_set_root_cursor() ob_cursor(OB_CURSOR_POINTER)); } -gboolean screen_pointer_pos(int *x, int *y) +gboolean screen_pointer_pos(gint *x, gint *y) { Window w; - int i; + gint i; guint u; return !!XQueryPointer(ob_display, RootWindow(ob_display, ob_screen),