From c4eca6cfd9fa8b38326865003647442da2ea2386 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 6 May 2007 06:44:09 +0000 Subject: [PATCH] merge r6104-6108 from trunk --- data/rc.xml.in | 8 +++---- openbox/action.c | 18 ++++++++++------ openbox/action.h | 1 + openbox/client.c | 2 +- openbox/event.c | 2 +- openbox/focus.c | 44 +++++++++++++++++++++++++-------------- openbox/focus.h | 3 ++- openbox/popup.c | 34 ++++++++++++------------------ openbox/popup.h | 19 +++++++++-------- openbox/screen.c | 54 ++++++++++++++++++++++++++++++------------------ openbox/screen.h | 2 +- 11 files changed, 108 insertions(+), 79 deletions(-) diff --git a/data/rc.xml.in b/data/rc.xml.in index bfffdd78..28ec2ff1 100644 --- a/data/rc.xml.in +++ b/data/rc.xml.in @@ -80,10 +80,10 @@ 4 1 - one - two - three - four + desktop one + desktop two + desktop three + desktop four diff --git a/openbox/action.c b/openbox/action.c index 797552f6..e056487f 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -293,6 +293,7 @@ void setup_action_cycle_windows_next(ObAction **a, ObUserAction uact) (*a)->data.cycle.forward = TRUE; (*a)->data.cycle.dialog = TRUE; (*a)->data.cycle.dock_windows = FALSE; + (*a)->data.cycle.all_desktops = FALSE; } void setup_action_cycle_windows_previous(ObAction **a, ObUserAction uact) @@ -302,6 +303,7 @@ void setup_action_cycle_windows_previous(ObAction **a, ObUserAction uact) (*a)->data.cycle.forward = FALSE; (*a)->data.cycle.dialog = TRUE; (*a)->data.cycle.dock_windows = FALSE; + (*a)->data.cycle.all_desktops = FALSE; } void setup_action_movefromedge_north(ObAction **a, ObUserAction uact) @@ -1009,6 +1011,9 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, act->data.cycle.dialog = parse_bool(doc, n); if ((n = parse_find_node("panels", node->xmlChildrenNode))) act->data.cycle.dock_windows = parse_bool(doc, n); + if ((n = parse_find_node("allDesktops", + node->xmlChildrenNode))) + act->data.cycle.all_desktops = parse_bool(doc, n); } else if (act->func == action_directional_focus) { if ((n = parse_find_node("dialog", node->xmlChildrenNode))) act->data.interdiraction.dialog = parse_bool(doc, n); @@ -1512,7 +1517,7 @@ void action_send_to_desktop(union ActionData *data) data->sendto.desk == DESKTOP_ALL) { client_set_desktop(c, data->sendto.desk, data->sendto.follow); if (data->sendto.follow) - screen_set_desktop(data->sendto.desk); + screen_set_desktop(data->sendto.desk, TRUE); } } @@ -1529,12 +1534,12 @@ void action_desktop(union ActionData *data) if (data->desktop.desk < screen_num_desktops || data->desktop.desk == DESKTOP_ALL) { - screen_set_desktop(data->desktop.desk); + screen_set_desktop(data->desktop.desk, TRUE); if (data->inter.any.interactive) screen_desktop_popup(data->desktop.desk, TRUE); } } else if (data->inter.cancel) { - screen_set_desktop(first); + screen_set_desktop(first, TRUE); } if (!data->inter.any.interactive || data->inter.final) { @@ -1557,7 +1562,7 @@ void action_desktop_dir(union ActionData *data) !data->sendtodir.inter.final || data->sendtodir.inter.cancel) { - screen_set_desktop(d); + screen_set_desktop(d, TRUE); } } @@ -1579,13 +1584,13 @@ void action_send_to_desktop_dir(union ActionData *data) { client_set_desktop(c, d, data->sendtodir.follow); if (data->sendtodir.follow) - screen_set_desktop(d); + screen_set_desktop(d, TRUE); } } void action_desktop_last(union ActionData *data) { - screen_set_desktop(screen_last_desktop); + screen_set_desktop(screen_last_desktop, TRUE); } void action_toggle_decorations(union ActionData *data) @@ -1771,6 +1776,7 @@ void action_cycle_windows(union ActionData *data) event_halt_focus_delay(); focus_cycle(data->cycle.forward, + data->cycle.all_desktops, data->cycle.dock_windows, data->cycle.linear, data->any.interactive, data->cycle.dialog, diff --git a/openbox/action.h b/openbox/action.h index c4c06fa8..7e3a09c8 100644 --- a/openbox/action.h +++ b/openbox/action.h @@ -143,6 +143,7 @@ struct CycleWindows { gboolean forward; gboolean dialog; gboolean dock_windows; + gboolean all_desktops; }; struct Stacking { diff --git a/openbox/client.c b/openbox/client.c index c18139fb..0caaa4b5 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3297,7 +3297,7 @@ static void client_present(ObClient *self, gboolean here, gboolean raise) if (here) client_set_desktop(self, screen_desktop, FALSE); else - screen_set_desktop(self->desktop); + screen_set_desktop(self->desktop, FALSE); } else if (!self->frame->visible) /* if its not visible for other reasons, then don't mess with it */ diff --git a/openbox/event.c b/openbox/event.c index 3666e9fd..2dcb6af2 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -591,7 +591,7 @@ static void event_handle_root(XEvent *e) ob_debug_type(OB_DEBUG_APP_BUGS, "_NET_CURRENT_DESKTOP message is missing " "a timestamp\n"); - screen_set_desktop(d); + screen_set_desktop(d, TRUE); } } else if (msgtype == prop_atoms.net_number_of_desktops) { guint d = e->xclient.data.l[0]; diff --git a/openbox/focus.c b/openbox/focus.c index cf65ff25..fbac20ec 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -61,7 +61,7 @@ static void focus_cycle_destructor(ObClient *client, gpointer data) be used */ if (focus_cycle_target == client) - focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); + focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); } static Window createWindow(Window parent, gulong mask, @@ -170,7 +170,7 @@ void focus_set_client(ObClient *client) be used. */ if (focus_cycle_target) - focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); + focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); focus_client = client; @@ -295,8 +295,10 @@ static void popup_cycle(ObClient *c, gboolean show) icon_popup_hide(focus_cycle_popup); } else { Rect *a; - ObClient *p = c; + ObClient *p; + gchar *text; gchar *title = NULL; + const gchar *desk = NULL; a = screen_physical_area_monitor(0); icon_popup_position(focus_cycle_popup, CenterGravity, @@ -305,20 +307,27 @@ static void popup_cycle(ObClient *c, gboolean show) icon_popup_height(focus_cycle_popup, POPUP_HEIGHT); /* use the transient's parent's title/icon */ - while (p->transient_for && p->transient_for != OB_TRAN_GROUP) - p = p->transient_for; + p = client_search_top_parent(c); + + if (c->desktop != DESKTOP_ALL && c->desktop != screen_desktop) + desk = screen_desktop_names[c->desktop]; if (p != c && !strcmp("", (c->iconic ? c->icon_title : c->title))) title = g_strdup(p->iconic ? p->icon_title : p->title); - /*title = g_strconcat((c->iconic ? c->icon_title : c->title), + /*ptitle = g_strconcat((c->iconic ? c->icon_title : c->title), " - ", (p->iconic ? p->icon_title : p->title), NULL); */ - icon_popup_show(focus_cycle_popup, - (title ? title : - (c->iconic ? c->icon_title : c->title)), - client_icon(p, 48, 48)); + if (title == NULL) + title = g_strdup(c->iconic ? c->icon_title : c->title); + if (desk) + text = g_strdup_printf("%s [%s]", title, desk); + else + text = g_strdup(title); + + icon_popup_show(focus_cycle_popup, text, client_icon(p, 48, 48)); + g_free(text); g_free(title); } } @@ -457,7 +466,9 @@ void focus_cycle_draw_indicator() } } -static gboolean valid_focus_target(ObClient *ft, gboolean dock_windows) +static gboolean valid_focus_target(ObClient *ft, + gboolean all_desktops, + gboolean dock_windows) { gboolean ok = FALSE; /* we don't use client_can_focus here, because that doesn't let you @@ -483,7 +494,9 @@ static gboolean valid_focus_target(ObClient *ft, gboolean dock_windows) ft->type == OB_CLIENT_TYPE_MENU || /* being allowed to target */ ft->type == OB_CLIENT_TYPE_UTILITY)) /* one of these, don't let */ ok = ok && !ft->skip_taskbar; /* skip taskbar stop us */ - ok = ok && (ft->desktop == screen_desktop || ft->desktop == DESKTOP_ALL); + if (!all_desktops) + ok = ok && (ft->desktop == screen_desktop || + ft->desktop == DESKTOP_ALL); ok = ok && ft == client_focus_target(ft); return ok; /* @@ -501,7 +514,8 @@ static gboolean valid_focus_target(ObClient *ft, gboolean dock_windows) */ } -void focus_cycle(gboolean forward, gboolean dock_windows, +void focus_cycle(gboolean forward, gboolean all_desktops, + gboolean dock_windows, gboolean linear, gboolean interactive, gboolean dialog, gboolean done, gboolean cancel) { @@ -546,7 +560,7 @@ void focus_cycle(gboolean forward, gboolean dock_windows, if (it == NULL) it = g_list_last(list); } ft = it->data; - if (valid_focus_target(ft, dock_windows)) { + if (valid_focus_target(ft, all_desktops, dock_windows)) { if (interactive) { if (ft != focus_cycle_target) { /* prevents flicker */ focus_cycle_target = ft; @@ -712,7 +726,7 @@ void focus_directional_cycle(ObDirection dir, gboolean dock_windows, GList *it; for (it = focus_order; it; it = g_list_next(it)) - if (valid_focus_target(it->data, dock_windows)) + if (valid_focus_target(it->data, FALSE, dock_windows)) ft = it->data; } diff --git a/openbox/focus.h b/openbox/focus.h index b838ab55..1c8cb157 100644 --- a/openbox/focus.h +++ b/openbox/focus.h @@ -52,7 +52,8 @@ struct _ObClient* focus_fallback_target(gboolean allow_refocus, void focus_fallback(gboolean allow_refocus); /*! Cycle focus amongst windows. */ -void focus_cycle(gboolean forward, gboolean dock_windows, +void focus_cycle(gboolean forward, gboolean all_desktops, + gboolean dock_windows, gboolean linear, gboolean interactive, gboolean dialog, gboolean done, gboolean cancel); void focus_directional_cycle(ObDirection dir, gboolean dock_windows, diff --git a/openbox/popup.c b/openbox/popup.c index a3c94653..82a78f1d 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -91,6 +91,7 @@ void popup_position(ObPopup *self, gint gravity, gint x, gint y) void popup_width(ObPopup *self, gint w) { self->w = w; + self->maxw = w; } void popup_height(ObPopup *self, gint h) @@ -104,19 +105,9 @@ void popup_height(ObPopup *self, gint h) void popup_width_to_string(ObPopup *self, gchar *text, gint max) { - gint textw, iconw; - self->a_text->texture[0].data.text.string = text; - textw = RrMinWidth(self->a_text); - if (self->hasicon) { - gint texth = RrMinHeight(self->a_text) + ob_rr_theme->paddingy * 2; - iconw = texth; - } else - iconw = 0; - self->w = textw + iconw + ob_rr_theme->paddingx * (self->hasicon ? 3 : 2); - /* cap it at "max" */ - if (max > 0) - self->w = MIN(self->w, max); + self->w = RrMinWidth(self->a_text); + self->maxw = max; } void popup_height_to_string(ObPopup *self, gchar *text) @@ -124,12 +115,12 @@ void popup_height_to_string(ObPopup *self, gchar *text) self->h = RrMinHeight(self->a_text) + ob_rr_theme->paddingy * 2; } -void popup_width_to_strings(ObPopup *self, gchar **strings, gint max) +void popup_width_to_strings(ObPopup *self, gchar **strings, gint num, gint max) { gint i, maxw; maxw = 0; - for (i = 0; strings[i] != NULL; ++i) { + for (i = 0; i < num; ++i) { popup_width_to_string(self, strings[i], max); maxw = MAX(maxw, self->w); } @@ -174,13 +165,13 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) } else h = t+b + texth + ob_rr_theme->paddingy * 2; iconw = (self->hasicon ? texth : 0); - if (self->w) { - w = self->w; - textw = w - (l+r + iconw + ob_rr_theme->paddingx * - (self->hasicon ? 3 : 2)); - } else - w = l+r + textw + iconw + ob_rr_theme->paddingx * - (self->hasicon ? 3 : 2); + if (self->w) + textw = self->w; + w = l+r + textw + iconw + ob_rr_theme->paddingx * + (self->hasicon ? 3 : 2); + /* cap it at "maxw" */ + w = MIN(w, self->maxw); + /* sanity checks to avoid crashes! */ if (w < 1) w = 1; if (h < 1) h = 1; @@ -452,6 +443,7 @@ ObPagerPopup *pager_popup_new() self->hilight = RrAppearanceCopy(ob_rr_theme->osd_hilite_fg); self->unhilight = RrAppearanceCopy(ob_rr_theme->osd_unhilite_fg); + self->popup->hasicon = TRUE; self->popup->draw_icon = pager_popup_draw_icon; self->popup->draw_icon_data = self; diff --git a/openbox/popup.h b/openbox/popup.h index c16e4cab..4b07bd9d 100644 --- a/openbox/popup.h +++ b/openbox/popup.h @@ -47,6 +47,7 @@ struct _ObPopup gint y; gint w; gint h; + gint maxw; gboolean mapped; gboolean delay_mapped; @@ -88,7 +89,7 @@ void popup_width(ObPopup *self, gint w); void popup_height(ObPopup *self, gint w); void popup_width_to_string(ObPopup *self, gchar *text, gint max); void popup_height_to_string(ObPopup *self, gchar *text); -void popup_width_to_strings(ObPopup *self, gchar **strings, gint max); +void popup_width_to_strings(ObPopup *self, gchar **strings, gint num,gint max); void popup_set_text_align(ObPopup *self, RrJustify align); @@ -109,10 +110,10 @@ void icon_popup_delay_show(ObIconPopup *self, gulong usec, #define icon_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y)) #define icon_popup_width(p, w) popup_width((p)->popup,(w)) #define icon_popup_height(p, h) popup_height((p)->popup,(h)) -#define icon_popup_width_to_string(p, s, m) \ - popup_width_to_string((p)->popup,(s),(m)) -#define icon_popup_width_to_strings(p, s, m) \ - popup_width_to_strings((p)->popup,(s),(m)) +#define icon_popup_width_to_string(p, s, n, m) \ + popup_width_to_string((p)->popup,(s),(n),(m)) +#define icon_popup_width_to_strings(p, s, n, m) \ + popup_width_to_strings((p)->popup,(s),(n),(m)) #define icon_popup_set_text_align(p, j) popup_set_text_align((p)->popup,(j)) ObPagerPopup *pager_popup_new(); @@ -125,10 +126,10 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec, #define pager_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y)) #define pager_popup_width(p, w) popup_width((p)->popup,(w)) #define pager_popup_height(p, h) popup_height((p)->popup,(h)) -#define pager_popup_width_to_string(p, s, m) \ - popup_width_to_string((p)->popup,(s),(m)) -#define pager_popup_width_to_strings(p, s, m) \ - popup_width_to_strings((p)->popup,(s),(m)) +#define pager_popup_width_to_string(p, s, n, m) \ + popup_width_to_string((p)->popup,(s),(n),(m)) +#define pager_popup_width_to_strings(p, s, n, m) \ + popup_width_to_strings((p)->popup,(s),(n),(m)) #define pager_popup_set_text_align(p, j) popup_set_text_align((p)->popup,(j)) #endif diff --git a/openbox/screen.c b/openbox/screen.c index a32f649f..148aaf5a 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -302,20 +302,29 @@ void screen_startup(gboolean reconfig) guint i; desktop_cycle_popup = pager_popup_new(FALSE); + pager_popup_height(desktop_cycle_popup, POPUP_HEIGHT); if (!reconfig) /* get the initial size */ screen_resize(); - /* set the names */ - screen_desktop_names = g_new(gchar*, - g_slist_length(config_desktops_names) + 1); - 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; + /* get the names */ + if (PROP_GETSS(RootWindow(ob_display, ob_screen), + net_desktop_names, utf8, &screen_desktop_names)) + for (i = 0; screen_desktop_names[i]; ++i); + else + i = 0; + for (it = g_slist_nth(config_desktops_names, i); it; + it = g_slist_next(it), ++i) + { + screen_desktop_names = g_renew(gchar*, screen_desktop_names, i + 2); + screen_desktop_names[i+1] = NULL; + screen_desktop_names[i] = g_strdup(it->data); + } + /* then set the names */ PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names, screen_desktop_names); - g_free(screen_desktop_names); /* dont free the individual strings */ + g_strfreev(screen_desktop_names); screen_desktop_names = NULL; if (!reconfig) @@ -328,13 +337,13 @@ void screen_startup(gboolean reconfig) net_current_desktop, cardinal, &d) && d < screen_num_desktops) { - screen_set_desktop(d); + screen_set_desktop(d, FALSE); } else if (session_desktop >= 0) screen_set_desktop(MIN((guint)session_desktop, - screen_num_desktops)); + screen_num_desktops), FALSE); else screen_set_desktop(MIN(config_screen_firstdesk, - screen_num_desktops) - 1); + screen_num_desktops) - 1, FALSE); /* don't start in showing-desktop mode */ screen_showing_desktop = FALSE; @@ -427,9 +436,6 @@ void screen_set_num_desktops(guint num) /* the number of rows/columns will differ */ screen_update_layout(); - /* may be some unnamed desktops that we need to fill in with names */ - screen_update_desktop_names(); - /* move windows on desktops that will no longer exist! */ for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; @@ -440,12 +446,16 @@ void screen_set_num_desktops(guint num) /* change our struts/area to match (after moving windows) */ screen_update_areas(); + /* may be some unnamed desktops that we need to fill in with names + (after updating the areas so the popup can resize) */ + screen_update_desktop_names(); + /* change our desktop if we're on one that no longer exists! */ if (screen_desktop >= screen_num_desktops) - screen_set_desktop(num - 1); + screen_set_desktop(num - 1, TRUE); } -void screen_set_desktop(guint num) +void screen_set_desktop(guint num, gboolean dofocus) { ObClient *c; GList *it; @@ -487,7 +497,7 @@ void screen_set_desktop(guint num) /* have to try focus here because when you leave an empty desktop there is no focus out to watch for */ - if ((c = focus_fallback_target(TRUE, focus_client))) { + if (dofocus && (c = focus_fallback_target(TRUE, focus_client))) { /* reduce flicker by hiliting now rather than waiting for the server FocusIn event */ frame_adjust_focus(c->frame, TRUE); @@ -618,9 +628,6 @@ void screen_desktop_popup(guint d, gboolean show) a = screen_physical_area_monitor(0); pager_popup_position(desktop_cycle_popup, CenterGravity, a->x + a->width / 2, a->y + a->height / 2); - pager_popup_width(desktop_cycle_popup, MAX(a->width/3, POPUP_WIDTH)); - pager_popup_height(desktop_cycle_popup, POPUP_HEIGHT); - pager_popup_show(desktop_cycle_popup, screen_desktop_names[d], d); } } @@ -876,8 +883,15 @@ void screen_update_desktop_names() screen_num_desktops + 1); screen_desktop_names[screen_num_desktops] = NULL; for (; i < screen_num_desktops; ++i) - screen_desktop_names[i] = g_strdup_printf("Desktop %i", i + 1); + screen_desktop_names[i] = g_strdup_printf("desktop %i", i + 1); } + + /* resize the pager for these names */ + pager_popup_width_to_strings(desktop_cycle_popup, + screen_desktop_names, + screen_num_desktops, + MAX(screen_physical_area_monitor(0)->width/3, + POPUP_WIDTH)); } void screen_show_desktop(gboolean show, gboolean restore_focus) diff --git a/openbox/screen.h b/openbox/screen.h index 558081b5..b4c510a7 100644 --- a/openbox/screen.h +++ b/openbox/screen.h @@ -66,7 +66,7 @@ void screen_resize(); /*! Change the number of available desktops */ void screen_set_num_desktops(guint num); /*! Change the current desktop */ -void screen_set_desktop(guint num); +void screen_set_desktop(guint num, gboolean dofocus); /*! Interactively change desktops */ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear, gboolean dialog, gboolean done, gboolean cancel); -- 2.34.1