From 905c82d4b5cb5c180ea18f6ed0d80566b35a78fc Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 19 May 2007 20:55:28 +0000 Subject: [PATCH] merge r6599-6634 from trunk --- Makefile.am | 6 + data/xsession/openbox.desktop.in | 2 +- debian/changelog.in | 2 +- doc/openbox.1.in | 6 +- doc/openbox.1.sgml | 4 +- makedeb | 4 +- openbox/action.c | 9 +- openbox/client.c | 6 +- openbox/client.h | 1 - openbox/client_menu.c | 8 +- openbox/event.c | 107 +++-- openbox/event.h | 6 +- openbox/focus.c | 703 +------------------------------ openbox/focus.h | 12 - openbox/frame.c | 9 +- openbox/openbox.c | 9 + openbox/popup.c | 2 +- openbox/prop.c | 1 + openbox/prop.h | 1 + openbox/screen.c | 3 +- openbox/session.c | 15 +- openbox/session.h | 5 +- render/obrender-3.0.pc.in | 9 +- render/render.c | 16 +- render/render.h | 1 + 25 files changed, 157 insertions(+), 790 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0d46f18c..185dd826 100644 --- a/Makefile.am +++ b/Makefile.am @@ -170,6 +170,12 @@ openbox_openbox_SOURCES = \ openbox/extensions.h \ openbox/focus.c \ openbox/focus.h \ + openbox/focus_cycle.c \ + openbox/focus_cycle.h \ + openbox/focus_cycle_indicator.c \ + openbox/focus_cycle_indicator.h \ + openbox/focus_cycle_popup.c \ + openbox/focus_cycle_popup.h \ openbox/frame.c \ openbox/frame.h \ openbox/framerender.c \ diff --git a/data/xsession/openbox.desktop.in b/data/xsession/openbox.desktop.in index f8cb9f36..0914e5b4 100644 --- a/data/xsession/openbox.desktop.in +++ b/data/xsession/openbox.desktop.in @@ -3,6 +3,6 @@ Encoding=UTF-8 Name=Openbox Comment=Log in using the Openbox window manager (without a session manager) Exec=@bindir@/openbox-session -TryExec=@bidir@/openbox-session +TryExec=@bindir@/openbox-session Icon=openbox.png Type=XSession diff --git a/debian/changelog.in b/debian/changelog.in index 678b1497..a2172800 100644 --- a/debian/changelog.in +++ b/debian/changelog.in @@ -1,4 +1,4 @@ -openbox (@version@-0) unstable; urgency=low +openbox (@version@) unstable; urgency=low * Upstream release. diff --git a/doc/openbox.1.in b/doc/openbox.1.in index 32acabc7..f419db14 100644 --- a/doc/openbox.1.in +++ b/doc/openbox.1.in @@ -48,9 +48,7 @@ above regarding the autostart.sh file. .PP You can use the \fBobconf\fR tool to configure Openbox easily with a graphical interface, however more in-depth configuration -is possible by editing the configuration files by hand. Please note that -\fBobconf\fR older than version 2.0 may not work at all -for you. +is possible by editing the configuration files by hand. .PP The default configuration and menu files are installed in @configdir@/openbox/, and the user configuration is placed in @@ -90,4 +88,4 @@ The program's full documentation is available on the website: .PP Please report bugs to: \fBhttp://bugzilla.icculus.org/ \fP -.\" created by instant / docbook-to-man, Wed 16 May 2007, 13:08 +.\" created by instant / docbook-to-man, Sat 19 May 2007, 16:56 diff --git a/doc/openbox.1.sgml b/doc/openbox.1.sgml index 6796f22e..2e0c3c83 100644 --- a/doc/openbox.1.sgml +++ b/doc/openbox.1.sgml @@ -90,9 +90,7 @@ manpage.1: manpage.sgml You can use the obconf tool to configure Openbox easily with a graphical interface, however more in-depth configuration - is possible by editing the configuration files by hand. Please note that - obconf older than version 2.0 may not work at all - for you. + is possible by editing the configuration files by hand. The default configuration and menu files are installed in @configdir@/openbox/, and the user configuration is placed in diff --git a/makedeb b/makedeb index ac5f6de7..ec0d6206 100755 --- a/makedeb +++ b/makedeb @@ -15,7 +15,7 @@ fi VERSION=$(grep AC_INIT\(\\\[openbox\\] configure.ac|cut -d [ -f 3-|cut -d ] -f 1) echo -echo "Building deb for openbox-$VERSION$APPEND" +echo "Building deb for openbox-$VERSION-0$APPEND" echo TIME="$(date '+%a, %d %B %Y %T %z')" @@ -28,6 +28,6 @@ make distclean > /dev/null || rm -f config.status rm -f $OUT -sed -e "s!@time@!$TIME!" -e "s!@version@!$VERSION$APPEND!" $IN >$OUT && \ +sed -e "s!@time@!$TIME!" -e "s!@version@!$VERSION-0$APPEND!" $IN >$OUT && \ fakeroot debian/rules binary && \ make distclean > /dev/null diff --git a/openbox/action.c b/openbox/action.c index 431b88c1..f1066979 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -20,6 +20,7 @@ #include "debug.h" #include "client.h" #include "focus.h" +#include "focus_cycle.h" #include "moveresize.h" #include "menu.h" #include "prop.h" @@ -38,16 +39,16 @@ #include -inline void client_action_start(union ActionData *data) +static void client_action_start(union ActionData *data) { } -inline void client_action_end(union ActionData *data) +static void client_action_end(union ActionData *data) { if (config_focus_follow) if (data->any.context != OB_FRAME_CONTEXT_CLIENT) { - if (!data->any.button) { - event_ignore_queued_enters(); + if (!data->any.button && data->any.c) { + event_ignore_all_queued_enters(); } else { ObClient *c; diff --git a/openbox/client.c b/openbox/client.c index addaed44..0dd12214 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -565,7 +565,7 @@ void client_unmanage(ObClient *self) /* ignore enter events from the unmap so it doesnt mess with the focus */ - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); mouse_grab_for_client(self, FALSE); @@ -1721,7 +1721,7 @@ void client_setup_decor_and_functions(ObClient *self) static void client_change_allowed_actions(ObClient *self) { - gulong actions[11]; + gulong actions[12]; gint num = 0; /* desktop windows are kept on all desktops */ @@ -1748,6 +1748,8 @@ static void client_change_allowed_actions(ObClient *self) actions[num++] = prop_atoms.net_wm_action_above; if (self->functions & OB_CLIENT_FUNC_BELOW) actions[num++] = prop_atoms.net_wm_action_below; + if (self->functions & OB_CLIENT_FUNC_UNDECORATE) + actions[num++] = prop_atoms.ob_wm_action_undecorate; PROP_SETA32(self->window, net_wm_allowed_actions, atom, actions, num); diff --git a/openbox/client.h b/openbox/client.h index 05153eb0..1467ecd1 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -80,7 +80,6 @@ typedef enum struct _ObClient { ObWindow obwin; - Window window; /*! The window's decorations. NULL while the window is being managed! */ diff --git a/openbox/client_menu.c b/openbox/client_menu.c index 6fa744c4..f538eafd 100644 --- a/openbox/client_menu.c +++ b/openbox/client_menu.c @@ -119,19 +119,15 @@ static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f, break; case CLIENT_RESTORE: client_maximize(c, FALSE, 0); - event_ignore_queued_enters(); break; case CLIENT_MAXIMIZE: client_maximize(c, TRUE, 0); - event_ignore_queued_enters(); break; case CLIENT_SHADE: client_shade(c, !c->shaded); - event_ignore_queued_enters(); break; case CLIENT_DECORATE: client_set_undecorated(c, !c->undecorated); - event_ignore_queued_enters(); break; case CLIENT_MOVE: /* this needs to grab the keyboard so hide the menu */ @@ -158,6 +154,8 @@ static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f, g_assert_not_reached(); } + event_ignore_all_queued_enters(); + /* update the menu cuz stuff can have changed */ if (f) { client_menu_update(f, NULL); @@ -217,7 +215,7 @@ static void layer_menu_execute(ObMenuEntry *e, ObMenuFrame *f, g_assert_not_reached(); } - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); /* update the menu cuz stuff can have changed */ if (f) { diff --git a/openbox/event.c b/openbox/event.c index 7b8793fa..8f211202 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -38,6 +38,7 @@ #include "mainloop.h" #include "framerender.h" #include "focus.h" +#include "focus_cycle.h" #include "moveresize.h" #include "group.h" #include "stacking.h" @@ -85,6 +86,7 @@ static void event_handle_dockapp(ObDockApp *app, XEvent *e); static void event_handle_client(ObClient *c, XEvent *e); static void event_handle_user_time_window_clients(GSList *l, XEvent *e); static void event_handle_user_input(ObClient *client, XEvent *e); +static gboolean is_enter_focus_event_ignored(XEvent *e); static void focus_delay_dest(gpointer data); static gboolean focus_delay_cmp(gconstpointer d1, gconstpointer d2); @@ -359,7 +361,7 @@ static Bool event_look_for_focusin(Display *d, XEvent *e, XPointer arg) return e->type == FocusIn && wanted_focusevent(e, FALSE); } -Bool event_look_for_focusin_client(Display *d, XEvent *e, XPointer arg) +static Bool event_look_for_focusin_client(Display *d, XEvent *e, XPointer arg) { return e->type == FocusIn && wanted_focusevent(e, TRUE); } @@ -574,7 +576,6 @@ static void event_process(const XEvent *ec, gpointer data) frame_adjust_focus(client->frame, FALSE); if (client == focus_client) focus_set_client(NULL); - /* focus_set_client has already been called for sure */ client_calc_layer(client); } } else if (timewinclients) @@ -884,7 +885,7 @@ static void event_handle_client(ObClient *client, XEvent *e) corresponding enter events. Pretend like the animating window doesn't even exist..! */ if (frame_iconify_animating(client->frame)) - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); ob_debug_type(OB_DEBUG_FOCUS, "%sNotify mode %d detail %d on %lx\n", @@ -910,13 +911,6 @@ static void event_handle_client(ObClient *client, XEvent *e) break; case EnterNotify: { - gboolean nofocus = FALSE; - - if (ignore_enter_focus) { - ignore_enter_focus--; - nofocus = TRUE; - } - con = frame_context(client, e->xcrossing.window, e->xcrossing.x, e->xcrossing.y); switch (con) { @@ -946,22 +940,23 @@ static void event_handle_client(ObClient *client, XEvent *e) if (e->xcrossing.mode == NotifyGrab || e->xcrossing.mode == NotifyUngrab || /*ignore enters when we're already in the window */ - e->xcrossing.detail == NotifyInferior) + e->xcrossing.detail == NotifyInferior || + is_enter_focus_event_ignored(e)) { ob_debug_type(OB_DEBUG_FOCUS, "%sNotify mode %d detail %d on %lx IGNORED\n", (e->type == EnterNotify ? "Enter" : "Leave"), e->xcrossing.mode, e->xcrossing.detail, client?client->window:0); - } else { + } + else { ob_debug_type(OB_DEBUG_FOCUS, "%sNotify mode %d detail %d on %lx, " - "focusing window: %d\n", + "focusing window\n", (e->type == EnterNotify ? "Enter" : "Leave"), e->xcrossing.mode, - e->xcrossing.detail, (client?client->window:0), - !nofocus); - if (!nofocus && config_focus_follow) + e->xcrossing.detail, (client?client->window:0)); + if (config_focus_follow) event_enter_client(client); } break; @@ -1085,7 +1080,7 @@ static void event_handle_client(ObClient *client, XEvent *e) client_configure(client, x, y, w, h, FALSE, TRUE); /* ignore enter events caused by these like ob actions do */ - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); } break; } @@ -1181,7 +1176,7 @@ static void event_handle_client(ObClient *client, XEvent *e) e->xclient.data.l[1], e->xclient.data.l[2]); /* ignore enter events caused by these like ob actions do */ - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); } else if (msgtype == prop_atoms.net_close_window) { ob_debug("net_close_window for 0x%lx\n", client->window); client_close(client); @@ -1269,7 +1264,7 @@ static void event_handle_client(ObClient *client, XEvent *e) client_configure(client, x, y, w, h, FALSE, TRUE); /* ignore enter events caused by these like ob actions do */ - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); } else if (msgtype == prop_atoms.net_restack_window) { if (e->xclient.data.l[0] != 2) { ob_debug_type(OB_DEBUG_APP_BUGS, @@ -1279,8 +1274,8 @@ static void event_handle_client(ObClient *client, XEvent *e) } else { ObClient *sibling = NULL; if (e->xclient.data.l[1]) { - ObWindow *win = g_hash_table_lookup(window_map, - &e->xclient.data.l[1]); + ObWindow *win = g_hash_table_lookup + (window_map, &e->xclient.data.l[1]); if (WINDOW_IS_CLIENT(win) && WINDOW_AS_CLIENT(win) != client) { @@ -1612,6 +1607,10 @@ static gboolean event_handle_menu(XEvent *ev) } break; case LeaveNotify: + /*ignore leaves when we're already in the window */ + if (ev->xcrossing.detail == NotifyInferior) + break; + if ((e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window)) && (f = find_active_menu()) && f->selected == e && e->entry->type != OB_MENU_ENTRY_TYPE_SUBMENU) @@ -1718,35 +1717,51 @@ void event_halt_focus_delay() ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func); } -void event_ignore_queued_enters() +static Bool event_look_for_enters(Display *d, XEvent *e, XPointer arg) { - GSList *saved = NULL, *it; - XEvent *e; - - XSync(ob_display, FALSE); + if (e->type == EnterNotify && + /* these types aren't used for focusing */ + !(e->xcrossing.mode == NotifyGrab || + e->xcrossing.mode == NotifyUngrab || + e->xcrossing.detail == NotifyInferior)) + { + ObWindow *win; - /* count the events */ - while (TRUE) { - e = g_new(XEvent, 1); - if (XCheckTypedEvent(ob_display, EnterNotify, e)) { - ObWindow *win; - - win = g_hash_table_lookup(window_map, &e->xany.window); - if (win && WINDOW_IS_CLIENT(win)) - ++ignore_enter_focus; - - saved = g_slist_append(saved, e); - } else { - g_free(e); - break; - } + /* found an enter for that leave, ignore it if it's going to + another window */ + win = g_hash_table_lookup(window_map, &e->xany.window); + if (win && WINDOW_IS_CLIENT(win)) + ++ignore_enter_focus; } - /* put the events back */ - for (it = saved; it; it = g_slist_next(it)) { - XPutBackEvent(ob_display, it->data); - g_free(it->data); + return False; /* don't disrupt the queue order, just count them */ +} + +void event_ignore_all_queued_enters() +{ + XEvent e; + + XSync(ob_display, FALSE); + + /* count the events without disrupting them */ + ignore_enter_focus = 0; + XCheckIfEvent(ob_display, &e, event_look_for_enters, NULL); +} + +static gboolean is_enter_focus_event_ignored(XEvent *e) +{ + g_assert(e->type == EnterNotify && + !(e->xcrossing.mode == NotifyGrab || + e->xcrossing.mode == NotifyUngrab || + e->xcrossing.detail == NotifyInferior)); + + ob_debug_type(OB_DEBUG_FOCUS, "# enters ignored: %d\n", + ignore_enter_focus); + + if (ignore_enter_focus) { + --ignore_enter_focus; + return TRUE; } - g_slist_free(saved); + return FALSE; } gboolean event_time_after(Time t1, Time t2) diff --git a/openbox/event.h b/openbox/event.h index 4fdf292e..542115fb 100644 --- a/openbox/event.h +++ b/openbox/event.h @@ -39,9 +39,9 @@ void event_shutdown(gboolean reconfig); follows mouse */ void event_enter_client(struct _ObClient *client); -/*! Request that any queued EnterNotify events not be used for distributing - focus */ -void event_ignore_queued_enters(); +/*! Make mouse focus not move at all from the stuff that has happened up + till now. */ +void event_ignore_all_queued_enters(); /* Halts any focus delay in progress, use this when the user is selecting a window for focus */ diff --git a/openbox/focus.c b/openbox/focus.c index 301e5ddf..42241224 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -21,130 +21,37 @@ #include "event.h" #include "openbox.h" #include "grab.h" -#include "framerender.h" #include "client.h" #include "config.h" -#include "frame.h" +#include "focus_cycle.h" #include "screen.h" -#include "group.h" #include "prop.h" #include "keyboard.h" #include "focus.h" #include "stacking.h" -#include "popup.h" -#include "render/render.h" #include #include -#include #define FOCUS_INDICATOR_WIDTH 6 ObClient *focus_client = NULL; GList *focus_order = NULL; -ObClient *focus_cycle_target = NULL; - -struct { - InternalWindow top; - InternalWindow left; - InternalWindow right; - InternalWindow bottom; -} focus_indicator; - -RrAppearance *a_focus_indicator; -RrColor *color_white; - -static ObIconPopup *focus_cycle_popup; - -static gboolean valid_focus_target(ObClient *ft, - gboolean all_desktops, - gboolean dock_windows, - gboolean desktop_windows); -static void focus_cycle_destroy_notify(ObClient *client, gpointer data); - -static Window createWindow(Window parent, gulong mask, - XSetWindowAttributes *attrib) -{ - return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0, - RrDepth(ob_rr_inst), InputOutput, - RrVisual(ob_rr_inst), mask, attrib); - -} void focus_startup(gboolean reconfig) { - focus_cycle_popup = icon_popup_new(TRUE); - - if (!reconfig) { - XSetWindowAttributes attr; - - client_add_destroy_notify(focus_cycle_destroy_notify, NULL); - - /* start with nothing focused */ - focus_nothing(); - - focus_indicator.top.obwin.type = Window_Internal; - focus_indicator.left.obwin.type = Window_Internal; - focus_indicator.right.obwin.type = Window_Internal; - focus_indicator.bottom.obwin.type = Window_Internal; - - attr.override_redirect = True; - attr.background_pixel = BlackPixel(ob_display, ob_screen); - focus_indicator.top.win = - createWindow(RootWindow(ob_display, ob_screen), - CWOverrideRedirect | CWBackPixel, &attr); - focus_indicator.left.win = - createWindow(RootWindow(ob_display, ob_screen), - CWOverrideRedirect | CWBackPixel, &attr); - focus_indicator.right.win = - createWindow(RootWindow(ob_display, ob_screen), - CWOverrideRedirect | CWBackPixel, &attr); - focus_indicator.bottom.win = - createWindow(RootWindow(ob_display, ob_screen), - CWOverrideRedirect | CWBackPixel, &attr); - - stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.top)); - stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.left)); - stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.right)); - stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.bottom)); - - color_white = RrColorNew(ob_rr_inst, 0xff, 0xff, 0xff); - - a_focus_indicator = RrAppearanceNew(ob_rr_inst, 4); - a_focus_indicator->surface.grad = RR_SURFACE_SOLID; - a_focus_indicator->surface.relief = RR_RELIEF_FLAT; - a_focus_indicator->surface.primary = RrColorNew(ob_rr_inst, - 0, 0, 0); - a_focus_indicator->texture[0].type = RR_TEXTURE_LINE_ART; - a_focus_indicator->texture[0].data.lineart.color = color_white; - a_focus_indicator->texture[1].type = RR_TEXTURE_LINE_ART; - a_focus_indicator->texture[1].data.lineart.color = color_white; - a_focus_indicator->texture[2].type = RR_TEXTURE_LINE_ART; - a_focus_indicator->texture[2].data.lineart.color = color_white; - a_focus_indicator->texture[3].type = RR_TEXTURE_LINE_ART; - a_focus_indicator->texture[3].data.lineart.color = color_white; - } + if (reconfig) return; + + /* start with nothing focused */ + focus_nothing(); } void focus_shutdown(gboolean reconfig) { - icon_popup_free(focus_cycle_popup); - - if (!reconfig) { - client_remove_destroy_notify(focus_cycle_destroy_notify); - - /* reset focus to root */ - XSetInputFocus(ob_display, PointerRoot, RevertToNone, CurrentTime); - - RrColorFree(color_white); - - RrAppearanceFree(a_focus_indicator); + if (reconfig) return; - XDestroyWindow(ob_display, focus_indicator.top.win); - XDestroyWindow(ob_display, focus_indicator.left.win); - XDestroyWindow(ob_display, focus_indicator.right.win); - XDestroyWindow(ob_display, focus_indicator.bottom.win); - } + /* reset focus to root */ + XSetInputFocus(ob_display, PointerRoot, RevertToNone, CurrentTime); } static void push_to_top(ObClient *client) @@ -167,11 +74,8 @@ void focus_set_client(ObClient *client) screen_install_colormap(focus_client, FALSE); screen_install_colormap(client, TRUE); - /* in the middle of cycling..? kill it. CurrentTime is fine, time won't - be used. - */ - if (focus_cycle_target) - focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); + /* in the middle of cycling..? kill it. */ + focus_cycle_stop(); focus_client = client; @@ -304,593 +208,6 @@ void focus_nothing() event_curtime); } -static gchar *popup_get_name(ObClient *c, ObClient **nametarget) -{ - ObClient *p; - gchar *title = NULL; - const gchar *desk = NULL; - gchar *ret; - - /* find our highest direct parent, including non-normal windows */ - for (p = c; p->transient_for && p->transient_for != OB_TRAN_GROUP; - p = p->transient_for); - - if (c->desktop != DESKTOP_ALL && c->desktop != screen_desktop) - desk = screen_desktop_names[c->desktop]; - - /* use the transient's parent's title/icon if we don't have one */ - if (p != c && !strcmp("", (c->iconic ? c->icon_title : c->title))) - title = g_strdup(p->iconic ? p->icon_title : p->title); - - if (title == NULL) - title = g_strdup(c->iconic ? c->icon_title : c->title); - - if (desk) - ret = g_strdup_printf("%s [%s]", title, desk); - else { - ret = title; - title = NULL; - } - g_free(title); - - /* set this only if we're returning true and they asked for it */ - if (ret && nametarget) *nametarget = p; - return ret; -} - -static void popup_cycle(ObClient *c, gboolean show, - gboolean all_desktops, gboolean dock_windows, - gboolean desktop_windows) -{ - gchar *showtext = NULL; - ObClient *showtarget; - - if (!show) { - icon_popup_hide(focus_cycle_popup); - return; - } - - /* do this stuff only when the dialog is first showing */ - if (!focus_cycle_popup->popup->mapped && - !focus_cycle_popup->popup->delay_mapped) - { - Rect *a; - gchar **names; - GList *targets = NULL, *it; - gint n = 0, i; - - /* position the popup */ - a = screen_physical_area_monitor(0); - icon_popup_position(focus_cycle_popup, CenterGravity, - a->x + a->width / 2, a->y + a->height / 2); - icon_popup_height(focus_cycle_popup, POPUP_HEIGHT); - icon_popup_min_width(focus_cycle_popup, POPUP_WIDTH); - icon_popup_max_width(focus_cycle_popup, - MAX(a->width/3, POPUP_WIDTH)); - - - /* make its width to be the width of all the possible titles */ - - /* build a list of all the valid focus targets */ - for (it = focus_order; it; it = g_list_next(it)) { - ObClient *ft = it->data; - if (valid_focus_target(ft, all_desktops, dock_windows - , desktop_windows)) - { - targets = g_list_prepend(targets, ft); - ++n; - } - } - /* make it null terminated so we can use g_strfreev */ - names = g_new(char*, n+1); - for (it = targets, i = 0; it; it = g_list_next(it), ++i) { - ObClient *ft = it->data, *t; - names[i] = popup_get_name(ft, &t); - - /* little optimization.. save this text and client, so we dont - have to get it again */ - if (ft == c) { - showtext = g_strdup(names[i]); - showtarget = t; - } - } - names[n] = NULL; - - icon_popup_text_width_to_strings(focus_cycle_popup, names, n); - g_strfreev(names); - } - - - if (!showtext) showtext = popup_get_name(c, &showtarget); - icon_popup_show(focus_cycle_popup, showtext, - client_icon(showtarget, 48, 48)); - g_free(showtext); -} - -static void focus_cycle_destroy_notify(ObClient *client, gpointer data) -{ - /* end cycling if the target disappears. CurrentTime is fine, time won't - be used - */ - if (focus_cycle_target == client) - focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); -} - -void focus_cycle_draw_indicator() -{ - if (!focus_cycle_target) { - XUnmapWindow(ob_display, focus_indicator.top.win); - XUnmapWindow(ob_display, focus_indicator.left.win); - XUnmapWindow(ob_display, focus_indicator.right.win); - XUnmapWindow(ob_display, focus_indicator.bottom.win); - - /* kill enter events cause by this unmapping */ - event_ignore_queued_enters(); - } else { - /* - if (focus_cycle_target) - frame_adjust_focus(focus_cycle_target->frame, FALSE); - frame_adjust_focus(focus_cycle_target->frame, TRUE); - */ - gint x, y, w, h; - gint wt, wl, wr, wb; - - wt = wl = wr = wb = FOCUS_INDICATOR_WIDTH; - - x = focus_cycle_target->frame->area.x; - y = focus_cycle_target->frame->area.y; - w = focus_cycle_target->frame->area.width; - h = wt; - - XMoveResizeWindow(ob_display, focus_indicator.top.win, - x, y, w, h); - a_focus_indicator->texture[0].data.lineart.x1 = 0; - a_focus_indicator->texture[0].data.lineart.y1 = h-1; - a_focus_indicator->texture[0].data.lineart.x2 = 0; - a_focus_indicator->texture[0].data.lineart.y2 = 0; - a_focus_indicator->texture[1].data.lineart.x1 = 0; - a_focus_indicator->texture[1].data.lineart.y1 = 0; - a_focus_indicator->texture[1].data.lineart.x2 = w-1; - a_focus_indicator->texture[1].data.lineart.y2 = 0; - a_focus_indicator->texture[2].data.lineart.x1 = w-1; - a_focus_indicator->texture[2].data.lineart.y1 = 0; - a_focus_indicator->texture[2].data.lineart.x2 = w-1; - a_focus_indicator->texture[2].data.lineart.y2 = h-1; - a_focus_indicator->texture[3].data.lineart.x1 = (wl-1); - a_focus_indicator->texture[3].data.lineart.y1 = h-1; - a_focus_indicator->texture[3].data.lineart.x2 = w - wr; - a_focus_indicator->texture[3].data.lineart.y2 = h-1; - RrPaint(a_focus_indicator, focus_indicator.top.win, - w, h); - - x = focus_cycle_target->frame->area.x; - y = focus_cycle_target->frame->area.y; - w = wl; - h = focus_cycle_target->frame->area.height; - - XMoveResizeWindow(ob_display, focus_indicator.left.win, - x, y, w, h); - a_focus_indicator->texture[0].data.lineart.x1 = w-1; - a_focus_indicator->texture[0].data.lineart.y1 = 0; - a_focus_indicator->texture[0].data.lineart.x2 = 0; - a_focus_indicator->texture[0].data.lineart.y2 = 0; - a_focus_indicator->texture[1].data.lineart.x1 = 0; - a_focus_indicator->texture[1].data.lineart.y1 = 0; - a_focus_indicator->texture[1].data.lineart.x2 = 0; - a_focus_indicator->texture[1].data.lineart.y2 = h-1; - a_focus_indicator->texture[2].data.lineart.x1 = 0; - a_focus_indicator->texture[2].data.lineart.y1 = h-1; - a_focus_indicator->texture[2].data.lineart.x2 = w-1; - a_focus_indicator->texture[2].data.lineart.y2 = h-1; - a_focus_indicator->texture[3].data.lineart.x1 = w-1; - a_focus_indicator->texture[3].data.lineart.y1 = wt-1; - a_focus_indicator->texture[3].data.lineart.x2 = w-1; - a_focus_indicator->texture[3].data.lineart.y2 = h - wb; - RrPaint(a_focus_indicator, focus_indicator.left.win, - w, h); - - x = focus_cycle_target->frame->area.x + - focus_cycle_target->frame->area.width - wr; - y = focus_cycle_target->frame->area.y; - w = wr; - h = focus_cycle_target->frame->area.height ; - - XMoveResizeWindow(ob_display, focus_indicator.right.win, - x, y, w, h); - a_focus_indicator->texture[0].data.lineart.x1 = 0; - a_focus_indicator->texture[0].data.lineart.y1 = 0; - a_focus_indicator->texture[0].data.lineart.x2 = w-1; - a_focus_indicator->texture[0].data.lineart.y2 = 0; - a_focus_indicator->texture[1].data.lineart.x1 = w-1; - a_focus_indicator->texture[1].data.lineart.y1 = 0; - a_focus_indicator->texture[1].data.lineart.x2 = w-1; - a_focus_indicator->texture[1].data.lineart.y2 = h-1; - a_focus_indicator->texture[2].data.lineart.x1 = w-1; - a_focus_indicator->texture[2].data.lineart.y1 = h-1; - a_focus_indicator->texture[2].data.lineart.x2 = 0; - a_focus_indicator->texture[2].data.lineart.y2 = h-1; - a_focus_indicator->texture[3].data.lineart.x1 = 0; - a_focus_indicator->texture[3].data.lineart.y1 = wt-1; - a_focus_indicator->texture[3].data.lineart.x2 = 0; - a_focus_indicator->texture[3].data.lineart.y2 = h - wb; - RrPaint(a_focus_indicator, focus_indicator.right.win, - w, h); - - x = focus_cycle_target->frame->area.x; - y = focus_cycle_target->frame->area.y + - focus_cycle_target->frame->area.height - wb; - w = focus_cycle_target->frame->area.width; - h = wb; - - XMoveResizeWindow(ob_display, focus_indicator.bottom.win, - x, y, w, h); - a_focus_indicator->texture[0].data.lineart.x1 = 0; - a_focus_indicator->texture[0].data.lineart.y1 = 0; - a_focus_indicator->texture[0].data.lineart.x2 = 0; - a_focus_indicator->texture[0].data.lineart.y2 = h-1; - a_focus_indicator->texture[1].data.lineart.x1 = 0; - a_focus_indicator->texture[1].data.lineart.y1 = h-1; - a_focus_indicator->texture[1].data.lineart.x2 = w-1; - a_focus_indicator->texture[1].data.lineart.y2 = h-1; - a_focus_indicator->texture[2].data.lineart.x1 = w-1; - a_focus_indicator->texture[2].data.lineart.y1 = h-1; - a_focus_indicator->texture[2].data.lineart.x2 = w-1; - a_focus_indicator->texture[2].data.lineart.y2 = 0; - a_focus_indicator->texture[3].data.lineart.x1 = wl-1; - a_focus_indicator->texture[3].data.lineart.y1 = 0; - a_focus_indicator->texture[3].data.lineart.x2 = w - wr; - a_focus_indicator->texture[3].data.lineart.y2 = 0; - RrPaint(a_focus_indicator, focus_indicator.bottom.win, - w, h); - - XMapWindow(ob_display, focus_indicator.top.win); - XMapWindow(ob_display, focus_indicator.left.win); - XMapWindow(ob_display, focus_indicator.right.win); - XMapWindow(ob_display, focus_indicator.bottom.win); - } -} - -static gboolean has_valid_group_siblings_on_desktop(ObClient *ft, - gboolean all_desktops) - -{ - GSList *it; - - if (!ft->group) return FALSE; - - for (it = ft->group->members; it; it = g_slist_next(it)) { - ObClient *c = it->data; - /* check that it's not a helper window to avoid infinite recursion */ - if (c != ft && !client_helper(c) && - valid_focus_target(c, all_desktops, FALSE, FALSE)) - { - return TRUE; - } - } - return FALSE; -} - -/*! @param allow_helpers This is used for calling itself recursively while - checking helper windows. */ -static gboolean valid_focus_target(ObClient *ft, - gboolean all_desktops, - gboolean dock_windows, - gboolean desktop_windows) -{ - gboolean ok = FALSE; - - /* it's on this desktop unless you want all desktops. - - do this check first because it will usually filter out the most - windows */ - ok = (all_desktops || ft->desktop == screen_desktop || - ft->desktop == DESKTOP_ALL); - - /* the window can receive focus somehow */ - ok = ok && (ft->can_focus || ft->focus_notify); - - /* it's the right type of window */ - if (dock_windows || desktop_windows) - ok = ok && ((dock_windows && ft->type == OB_CLIENT_TYPE_DOCK) || - (desktop_windows && ft->type == OB_CLIENT_TYPE_DESKTOP)); - else - /* normal non-helper windows are valid targets */ - ok = ok && - ((client_normal(ft) && !client_helper(ft)) - || - /* helper windows are valid targets it... */ - (client_helper(ft) && - /* ...a window in its group already has focus ... */ - ((focus_client && ft->group == focus_client->group) || - /* ... or if there are no other windows in its group - that can be cycled to instead */ - !has_valid_group_siblings_on_desktop(ft, all_desktops)))); - - /* it's not set to skip the taskbar (unless it is a type that would be - expected to set this hint */ - ok = ok && ((ft->type == OB_CLIENT_TYPE_DOCK || - ft->type == OB_CLIENT_TYPE_DESKTOP || - ft->type == OB_CLIENT_TYPE_TOOLBAR || - ft->type == OB_CLIENT_TYPE_MENU || - ft->type == OB_CLIENT_TYPE_UTILITY) || - !ft->skip_taskbar); - - /* it's not going to just send fous off somewhere else (modal window) */ - ok = ok && ft == client_focus_target(ft); - - return ok; -} - -void focus_cycle(gboolean forward, gboolean all_desktops, - gboolean dock_windows, gboolean desktop_windows, - gboolean linear, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel) -{ - static ObClient *first = NULL; - static ObClient *t = NULL; - static GList *order = NULL; - GList *it, *start, *list; - ObClient *ft = NULL; - - if (interactive) { - if (cancel) { - focus_cycle_target = NULL; - goto done_cycle; - } else if (done) - goto done_cycle; - - if (!focus_order) - goto done_cycle; - - if (!first) first = focus_client; - - if (linear) list = client_list; - else list = focus_order; - } else { - if (!focus_order) - goto done_cycle; - list = client_list; - } - if (!focus_cycle_target) focus_cycle_target = focus_client; - - start = it = g_list_find(list, focus_cycle_target); - if (!start) /* switched desktops or something? */ - start = it = forward ? g_list_last(list) : g_list_first(list); - if (!start) goto done_cycle; - - do { - if (forward) { - it = it->next; - if (it == NULL) it = g_list_first(list); - } else { - it = it->prev; - if (it == NULL) it = g_list_last(list); - } - ft = it->data; - if (valid_focus_target(ft, all_desktops, dock_windows, - desktop_windows)) - { - if (interactive) { - if (ft != focus_cycle_target) { /* prevents flicker */ - focus_cycle_target = ft; - focus_cycle_draw_indicator(); - } - /* same arguments as valid_focus_target */ - popup_cycle(ft, dialog, all_desktops, dock_windows, - desktop_windows); - return; - } else if (ft != focus_cycle_target) { - focus_cycle_target = ft; - done = TRUE; - break; - } - } - } while (it != start); - -done_cycle: - if (done && focus_cycle_target) - client_activate(focus_cycle_target, FALSE, TRUE); - - t = NULL; - first = NULL; - focus_cycle_target = NULL; - g_list_free(order); - order = NULL; - - if (interactive) { - focus_cycle_draw_indicator(); - popup_cycle(ft, FALSE, FALSE, FALSE, FALSE); - } - - return; -} - -/* this be mostly ripped from fvwm */ -static ObClient *focus_find_directional(ObClient *c, ObDirection dir, - gboolean dock_windows, - gboolean desktop_windows) -{ - gint my_cx, my_cy, his_cx, his_cy; - gint offset = 0; - gint distance = 0; - gint score, best_score; - ObClient *best_client, *cur; - GList *it; - - if(!client_list) - return NULL; - - /* first, find the centre coords of the currently focused window */ - my_cx = c->frame->area.x + c->frame->area.width / 2; - my_cy = c->frame->area.y + c->frame->area.height / 2; - - best_score = -1; - best_client = NULL; - - for(it = g_list_first(client_list); it; it = g_list_next(it)) { - cur = it->data; - - /* the currently selected window isn't interesting */ - if(cur == c) - continue; - if (cur->type == OB_CLIENT_TYPE_DOCK && !dock_windows) - continue; - if (cur->type == OB_CLIENT_TYPE_DESKTOP && !desktop_windows) - continue; - if (!client_normal(cur) && - cur->type != OB_CLIENT_TYPE_DOCK && - cur->type != OB_CLIENT_TYPE_DESKTOP) - continue; - /* using c->desktop instead of screen_desktop doesn't work if the - * current window was omnipresent, hope this doesn't have any other - * side effects */ - if(screen_desktop != cur->desktop && cur->desktop != DESKTOP_ALL) - continue; - if(cur->iconic) - continue; - if(!(client_focus_target(cur) == cur && - client_can_focus(cur))) - continue; - - /* find the centre coords of this window, from the - * currently focused window's point of view */ - his_cx = (cur->frame->area.x - my_cx) - + cur->frame->area.width / 2; - his_cy = (cur->frame->area.y - my_cy) - + cur->frame->area.height / 2; - - if(dir == OB_DIRECTION_NORTHEAST || dir == OB_DIRECTION_SOUTHEAST || - dir == OB_DIRECTION_SOUTHWEST || dir == OB_DIRECTION_NORTHWEST) { - gint tx; - /* Rotate the diagonals 45 degrees counterclockwise. - * To do this, multiply the matrix /+h +h\ with the - * vector (x y). \-h +h/ - * h = sqrt(0.5). We can set h := 1 since absolute - * distance doesn't matter here. */ - tx = his_cx + his_cy; - his_cy = -his_cx + his_cy; - his_cx = tx; - } - - switch(dir) { - case OB_DIRECTION_NORTH: - case OB_DIRECTION_SOUTH: - case OB_DIRECTION_NORTHEAST: - case OB_DIRECTION_SOUTHWEST: - offset = (his_cx < 0) ? -his_cx : his_cx; - distance = ((dir == OB_DIRECTION_NORTH || - dir == OB_DIRECTION_NORTHEAST) ? - -his_cy : his_cy); - break; - case OB_DIRECTION_EAST: - case OB_DIRECTION_WEST: - case OB_DIRECTION_SOUTHEAST: - case OB_DIRECTION_NORTHWEST: - offset = (his_cy < 0) ? -his_cy : his_cy; - distance = ((dir == OB_DIRECTION_WEST || - dir == OB_DIRECTION_NORTHWEST) ? - -his_cx : his_cx); - break; - } - - /* the target must be in the requested direction */ - if(distance <= 0) - continue; - - /* Calculate score for this window. The smaller the better. */ - score = distance + offset; - - /* windows more than 45 degrees off the direction are - * heavily penalized and will only be chosen if nothing - * else within a million pixels */ - if(offset > distance) - score += 1000000; - - if(best_score == -1 || score < best_score) - best_client = cur, - best_score = score; - } - - return best_client; -} - -void focus_directional_cycle(ObDirection dir, gboolean dock_windows, - gboolean desktop_windows, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel) -{ - static ObClient *first = NULL; - ObClient *ft = NULL; - - if (!interactive) - return; - - if (cancel) { - focus_cycle_target = NULL; - goto done_cycle; - } else if (done) - goto done_cycle; - - if (!focus_order) - goto done_cycle; - - if (!first) first = focus_client; - if (!focus_cycle_target) focus_cycle_target = focus_client; - - if (focus_cycle_target) - ft = focus_find_directional(focus_cycle_target, dir, dock_windows, - desktop_windows); - else { - GList *it; - - for (it = focus_order; it; it = g_list_next(it)) - if (valid_focus_target(it->data, FALSE, dock_windows, - desktop_windows)) - ft = it->data; - } - - if (ft) { - if (ft != focus_cycle_target) {/* prevents flicker */ - focus_cycle_target = ft; - focus_cycle_draw_indicator(); - } - } - if (focus_cycle_target) { - /* same arguments as valid_focus_target */ - popup_cycle(focus_cycle_target, dialog, FALSE, dock_windows, - desktop_windows); - if (dialog) - return; - } - - -done_cycle: - if (done && focus_cycle_target) - client_activate(focus_cycle_target, FALSE, TRUE); - - first = NULL; - focus_cycle_target = NULL; - - focus_cycle_draw_indicator(); - popup_cycle(ft, FALSE, FALSE, FALSE, FALSE); - - return; -} - -void focus_order_add_new(ObClient *c) -{ - if (c->iconic) - focus_order_to_top(c); - else { - g_assert(!g_list_find(focus_order, c)); - /* if there are any iconic windows, put this above them in the order, - but if there are not, then put it under the currently focused one */ - if (focus_order && ((ObClient*)focus_order->data)->iconic) - focus_order = g_list_insert(focus_order, c, 0); - else - focus_order = g_list_insert(focus_order, c, 1); - } -} - void focus_order_remove(ObClient *c) { focus_order = g_list_remove(focus_order, c); diff --git a/openbox/focus.h b/openbox/focus.h index 451cc162..9bd4f206 100644 --- a/openbox/focus.h +++ b/openbox/focus.h @@ -29,8 +29,6 @@ struct _ObClient; /*! The client which is currently focused */ extern struct _ObClient *focus_client; -/*! The client which appears focused during a focus cycle operation */ -extern struct _ObClient *focus_cycle_target; /*! The recent focus order on each desktop */ extern GList *focus_order; @@ -48,16 +46,6 @@ void focus_nothing(); /*! Call this when you need to focus something! */ struct _ObClient* focus_fallback(gboolean allow_refocus); -/*! Cycle focus amongst windows. */ -void focus_cycle(gboolean forward, gboolean all_desktops, - gboolean dock_windows, gboolean desktop_windows, - gboolean linear, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel); -void focus_directional_cycle(ObDirection dir, gboolean dock_windows, - gboolean desktop_windows, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel); -void focus_cycle_draw_indicator(); - /*! Add a new client into the focus order */ void focus_order_add_new(struct _ObClient *c); diff --git a/openbox/frame.c b/openbox/frame.c index 16c879e9..a0784d23 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -25,7 +25,8 @@ #include "config.h" #include "framerender.h" #include "mainloop.h" -#include "focus.h" +#include "focus_cycle.h" +#include "focus_cycle_indicator.h" #include "moveresize.h" #include "screen.h" #include "render/theme.h" @@ -507,7 +508,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved, /* if this occurs while we are focus cycling, the indicator needs to match the changes */ if (focus_cycle_target == self->client) - focus_cycle_draw_indicator(); + focus_cycle_draw_indicator(self->client); } if (resized && (self->decorations & OB_FRAME_DECOR_TITLEBAR)) XResizeWindow(ob_display, self->label, self->label_width, @@ -1171,6 +1172,10 @@ void frame_end_iconify_animation(ObFrame *self) if (!self->visible) XUnmapWindow(ob_display, self->window); + else + /* Send a ConfigureNotify when the animation is done, this fixes + KDE's pager showing the window in the wrong place. */ + client_reconfigure(self->client); /* we're not animating any more ! */ self->iconify_animation_going = 0; diff --git a/openbox/openbox.c b/openbox/openbox.c index 78b53223..996cb227 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -30,6 +30,9 @@ #include "screen.h" #include "startupnotify.h" #include "focus.h" +#include "focus_cycle.h" +#include "focus_cycle_indicator.h" +#include "focus_cycle_popup.h" #include "moveresize.h" #include "frame.h" #include "keyboard.h" @@ -283,6 +286,9 @@ gint main(gint argc, gchar **argv) /* focus_backup is used for stacking, so this needs to come before anything that calls stacking_add */ focus_startup(reconfigure); + focus_cycle_startup(reconfigure); + focus_cycle_indicator_startup(reconfigure); + focus_cycle_popup_startup(reconfigure); window_startup(reconfigure); sn_startup(reconfigure); screen_startup(reconfigure); @@ -348,6 +354,9 @@ gint main(gint argc, gchar **argv) propwin_shutdown(reconfigure); grab_shutdown(reconfigure); screen_shutdown(reconfigure); + focus_cycle_popup_shutdown(reconfigure); + focus_cycle_indicator_shutdown(reconfigure); + focus_cycle_shutdown(reconfigure); focus_shutdown(reconfigure); sn_shutdown(reconfigure); window_shutdown(reconfigure); diff --git a/openbox/popup.c b/openbox/popup.c index 91c1849c..2768ee2b 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -269,7 +269,7 @@ void popup_hide(ObPopup *self) self->mapped = FALSE; /* kill enter events cause by this unmapping */ - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); } else if (self->delay_mapped) { ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout); self->delay_mapped = FALSE; diff --git a/openbox/prop.c b/openbox/prop.c index 36e52017..1412752a 100644 --- a/openbox/prop.c +++ b/openbox/prop.c @@ -172,6 +172,7 @@ void prop_startup() CREATE(openbox_pid, "_OPENBOX_PID"); CREATE(ob_config, "_OB_CONFIG"); + CREATE(ob_wm_action_undecorate, "_OB_WM_ACTION_UNDECORATE"); CREATE(ob_wm_state_undecorated, "_OB_WM_STATE_UNDECORATED"); CREATE(ob_control, "_OB_CONTROL"); } diff --git a/openbox/prop.h b/openbox/prop.h index 35eb1979..3f18a363 100644 --- a/openbox/prop.h +++ b/openbox/prop.h @@ -190,6 +190,7 @@ typedef struct Atoms { /* Openbox specific atoms */ + Atom ob_wm_action_undecorate; Atom ob_wm_state_undecorated; Atom openbox_pid; /* this is depreecated in favour of ob_control */ Atom ob_config; diff --git a/openbox/screen.c b/openbox/screen.c index 45246297..6551da81 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -288,6 +288,7 @@ gboolean screen_annex() supported[i++] = prop_atoms.kde_net_wm_frame_strut; supported[i++] = prop_atoms.kde_net_wm_window_type_override; + supported[i++] = prop_atoms.ob_wm_action_undecorate; supported[i++] = prop_atoms.ob_wm_state_undecorated; supported[i++] = prop_atoms.openbox_pid; supported[i++] = prop_atoms.ob_config; @@ -522,7 +523,7 @@ void screen_set_desktop(guint num, gboolean dofocus) } } - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); if (event_curtime != CurrentTime) screen_desktop_user_time = event_curtime; diff --git a/openbox/session.c b/openbox/session.c index b07f1694..d0db0717 100644 --- a/openbox/session.c +++ b/openbox/session.c @@ -513,6 +513,8 @@ static gboolean session_save_to_file(const ObSMSaveData *savedata) fprintf(f, "\t%s\n", t); g_free(t); + fprintf(f, "\t%d\n", c->type); + fprintf(f, "\t%d\n", c->desktop); fprintf(f, "\t%d\n", prex); fprintf(f, "\t%d\n", prey); @@ -576,12 +578,14 @@ static gboolean session_state_cmp(ObSessionState *s, ObClient *c) ob_debug_type(OB_DEBUG_SM, " client name: %s \n", c->name); ob_debug_type(OB_DEBUG_SM, " client class: %s \n", c->class); ob_debug_type(OB_DEBUG_SM, " client role: %s \n", c->role); + ob_debug_type(OB_DEBUG_SM, " client type: %s \n", c->type); ob_debug_type(OB_DEBUG_SM, " client command: %s \n", c->wm_command ? c->wm_command : "(null)"); ob_debug_type(OB_DEBUG_SM, " state id: %s \n", s->id); ob_debug_type(OB_DEBUG_SM, " state name: %s \n", s->name); ob_debug_type(OB_DEBUG_SM, " state class: %s \n", s->class); ob_debug_type(OB_DEBUG_SM, " state role: %s \n", s->role); + ob_debug_type(OB_DEBUG_SM, " state type: %s \n", s->type); ob_debug_type(OB_DEBUG_SM, " state command: %s \n", s->command ? s->command : "(null)"); @@ -590,7 +594,13 @@ static gboolean session_state_cmp(ObSessionState *s, ObClient *c) { return (!strcmp(s->name, c->name) && !strcmp(s->class, c->class) && - !strcmp(s->role, c->role)); + !strcmp(s->role, c->role) && + /* the check for type is to catch broken clients, like + firefox, which open a different window on startup + with the same info as the one we saved. only do this + check for old windows that dont use xsmp, others should + know better ! */ + (!s->command || c->type == s->type)); } return FALSE; } @@ -639,6 +649,9 @@ static void session_load_file(const gchar *path) if (!(n = parse_find_node("role", node->children))) goto session_load_bail; state->role = parse_string(doc, n); + if (!(n = parse_find_node("windowtype", node->children))) + goto session_load_bail; + state->type = parse_int(doc, n); if (!(n = parse_find_node("desktop", node->children))) goto session_load_bail; state->desktop = parse_int(doc, n); diff --git a/openbox/session.h b/openbox/session.h index 8663fce2..97e55a3b 100644 --- a/openbox/session.h +++ b/openbox/session.h @@ -19,14 +19,15 @@ #ifndef __ob__session_h #define __ob__session_h -#include +#include "client.h" -struct _ObClient; +#include typedef struct _ObSessionState ObSessionState; struct _ObSessionState { gchar *id, *command, *name, *class, *role; + ObClientType type; guint desktop; gint x, y, w, h; gboolean shaded, iconic, skip_pager, skip_taskbar, fullscreen; diff --git a/render/obrender-3.0.pc.in b/render/obrender-3.0.pc.in index 12fc7012..81c37218 100644 --- a/render/obrender-3.0.pc.in +++ b/render/obrender-3.0.pc.in @@ -6,9 +6,12 @@ includedir=@includedir@ xcflags=@X_CFLAGS@ xlibs=@X_LIBS@ +pangocflags=@PANGO_CFLAGS@ +pangolibs=@PANGO_LIBS@ + Name: ObRender Description: Openbox Render Library Version: @VERSION@ -Requires: obparser-3.0 glib-2.0 xft -Libs: -L${libdir} -lobrender ${xlibs} -Cflags: -I${includedir}/openbox/@OB_VERSION@ ${xcflags} +Requires: obparser-3.4 glib-2.0 xft pangoxft +Libs: -L${libdir} -lobrender ${xlibs} ${pangolibs} +Cflags: -I${includedir}/openbox/@OB_VERSION@ ${xcflags} ${pangocflags} diff --git a/render/render.c b/render/render.c index ecb07ada..82e6f96e 100644 --- a/render/render.c +++ b/render/render.c @@ -42,7 +42,7 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h) { gint i, transferred = 0, sw, sh, partial_w, partial_h; RrPixel32 *source, *dest; - Pixmap oldp; + Pixmap oldp = None; RrRect tarea; /* area in which to draw textures */ gboolean resized; @@ -77,8 +77,10 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h) RrVisual(a->inst), RrColormap(a->inst)); g_assert(a->xftdraw != NULL); - g_free(a->surface.pixel_data); - a->surface.pixel_data = g_new(RrPixel32, w * h); + if (resized) { + g_free(a->surface.pixel_data); + a->surface.pixel_data = g_new(RrPixel32, w * h); + } if (a->surface.grad == RR_SURFACE_PARENTREL) { g_assert (a->surface.parent); @@ -194,6 +196,14 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex) return out; } +void RrAppearanceAddTextures(RrAppearance *a, gint numtex) +{ + g_assert(a->textures == 0); + + a->textures = numtex; + if (numtex) a->texture = g_new0(RrTexture, numtex); +} + RrAppearance *RrAppearanceCopy(RrAppearance *orig) { RrSurface *spo, *spc; diff --git a/render/render.h b/render/render.h index ad638ae8..ac1deb4b 100644 --- a/render/render.h +++ b/render/render.h @@ -230,6 +230,7 @@ GC RrColorGC (RrColor *c); RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex); RrAppearance *RrAppearanceCopy (RrAppearance *a); void RrAppearanceFree (RrAppearance *a); +void RrAppearanceAddTextures(RrAppearance *a, gint numtex); RrFont *RrFontOpen (const RrInstance *inst, const gchar *name, gint size, RrFontWeight weight, RrFontSlant slant); -- 2.34.1