X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient.c;h=7b7872b37d7a0f8ea5b51093565f92ee6be18901;hb=00042637e8b8bef92456d96547230ec710cf6a7b;hp=a33e2847a82053b8280f1b8458691d3c3cfc175b;hpb=5f53cd5fb8b454f309fc8002e21004f70957f7bd;p=chaz%2Fopenbox diff --git a/openbox/client.c b/openbox/client.c index a33e2847..7b7872b3 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3,13 +3,13 @@ #include "prop.h" #include "extensions.h" #include "frame.h" -#include "engine.h" #include "event.h" #include "grab.h" #include "focus.h" #include "stacking.h" #include "dispatch.h" #include "group.h" +#include "config.h" #include #include @@ -138,8 +138,8 @@ void client_manage_all() client_startup_stack_order = NULL; client_startup_stack_size = 0; - if (focus_new) - focus_fallback(FALSE); + if (config_focus_new) + focus_fallback(Fallback_NoFocus); } void client_manage(Window window) @@ -182,6 +182,7 @@ void client_manage(Window window) XFree(wmhint); } */ + g_message("Managing window: %lx", window); /* choose the events we want to receive on the CLIENT window */ attrib_set.event_mask = CLIENT_EVENTMASK; @@ -204,9 +205,9 @@ void client_manage(Window window) XChangeSaveSet(ob_display, window, SetModeInsert); /* create the decoration frame for the client window */ - self->frame = engine_frame_new(); + self->frame = frame_new(); - engine_frame_grab_client(self->frame, self); + frame_grab_client(self->frame, self); client_apply_startup_state(self); @@ -236,8 +237,25 @@ void client_manage(Window window) dispatch_client(Event_Client_Mapped, self, 0, 0); - if (ob_state != State_Starting && focus_new) - client_focus(self); + /* focus the new window? */ + if (ob_state != State_Starting) { + if (config_focus_new) + client_focus(self); + else if (self->transient_for) { + if (self->transient_for != TRAN_GROUP) {/* transient of a window */ + if (focus_client == self->transient_for) + client_focus(self); + } else { /* transient of a group */ + GSList *it; + + for (it = self->group->members; it; it = it->next) + if (focus_client == it->data) { + client_focus(self); + break; + } + } + } + } /* update the list hints */ client_set_list(); @@ -245,7 +263,7 @@ void client_manage(Window window) /* make sure the window is visible */ client_move_onscreen(self); -/* g_message("Managed window 0x%lx", window);*/ + g_message("Managed window 0x%lx", window); } void client_unmanage_all() @@ -260,7 +278,7 @@ void client_unmanage(Client *self) int j; GSList *it; -/* g_message("Unmanaging window: %lx", self->window);*/ + g_message("Unmanaging window: %lx", self->window); dispatch_client(Event_Client_Destroy, self, 0, 0); g_assert(self != NULL); @@ -271,7 +289,7 @@ void client_unmanage(Client *self) /* we dont want events no more */ XSelectInput(ob_display, self->window, NoEventMask); - engine_frame_hide(self->frame); + frame_hide(self->frame); client_list = g_list_remove(client_list, self); stacking_list = g_list_remove(stacking_list, self); @@ -311,6 +329,9 @@ void client_unmanage(Client *self) } } + if (focus_client == self) + client_unfocus(self); + /* remove from its group */ if (self->group) { group_remove(self->group, self); @@ -325,7 +346,7 @@ void client_unmanage(Client *self) client_toggle_border(self, TRUE); /* reparent the window out of the frame, and free the frame */ - engine_frame_release_client(self->frame, self); + frame_release_client(self->frame, self); self->frame = NULL; if (ob_state != State_Exiting) { @@ -340,6 +361,8 @@ void client_unmanage(Client *self) XMapWindow(ob_display, self->window); } + g_message("Unmanaged window 0x%lx", self->window); + /* free all data allocated in the client struct */ g_slist_free(self->transients); for (j = 0; j < self->nicons; ++j) @@ -822,14 +845,14 @@ void client_setup_decor_and_functions(Client *self) break; case Type_Dialog: - /* dialogs cannot be maximized */ + case Type_Utility: + /* these windows cannot be maximized */ self->decorations &= ~Decor_Maximize; self->functions &= ~Func_Maximize; break; case Type_Menu: case Type_Toolbar: - case Type_Utility: /* these windows get less functionality */ self->decorations &= ~(Decor_Iconify | Decor_Handle); self->functions &= ~(Func_Iconify | Func_Resize); @@ -909,7 +932,7 @@ void client_setup_decor_and_functions(Client *self) if (self->frame) { /* change the decors on the frame, and with more/less decorations, we may also need to be repositioned */ - engine_frame_adjust_area(self->frame, TRUE, TRUE); + frame_adjust_area(self->frame, TRUE, TRUE); /* with new decor, the window's maximized size may change */ client_remaximize(self); } @@ -1027,7 +1050,7 @@ void client_update_wmhints(Client *self) self->pixmap_icon_mask = None; if (self->frame) - engine_frame_adjust_icon(self->frame); + frame_adjust_icon(self->frame); } } @@ -1076,7 +1099,7 @@ void client_update_title(Client *self) self->title = data; if (self->frame) - engine_frame_adjust_title(self->frame); + frame_adjust_title(self->frame); } void client_update_icon_title(Client *self) @@ -1200,7 +1223,7 @@ void client_update_icons(Client *self) } if (self->frame) - engine_frame_adjust_icon(self->frame); + frame_adjust_icon(self->frame); } void client_update_kwm_icon(Client *self) @@ -1215,7 +1238,7 @@ void client_update_kwm_icon(Client *self) self->pixmap_icon = self->pixmap_icon_mask = None; } if (self->frame) - engine_frame_adjust_icon(self->frame); + frame_adjust_icon(self->frame); } static void client_change_state(Client *self) @@ -1254,7 +1277,7 @@ static void client_change_state(Client *self) client_calc_layer(self); if (self->frame) - engine_frame_adjust_state(self->frame); + frame_adjust_state(self->frame); } static Client *search_focus_tree(Client *node, Client *skip) @@ -1325,9 +1348,9 @@ static void client_showhide(Client *self) { if (client_should_show(self)) - engine_frame_show(self->frame); + frame_show(self->frame); else - engine_frame_hide(self->frame); + frame_hide(self->frame); } gboolean client_normal(Client *self) { @@ -1500,7 +1523,7 @@ void client_configure(Client *self, Corner anchor, int x, int y, int w, int h, /* move/resize the frame to match the request */ if (self->frame) { if (moved || resized) - engine_frame_adjust_area(self->frame, moved, resized); + frame_adjust_area(self->frame, moved, resized); if (!user || final) { XEvent event; @@ -1597,6 +1620,33 @@ void client_fullscreen(Client *self, gboolean fs, gboolean savearea) void client_iconify(Client *self, gboolean iconic, gboolean curdesk) { + /* move up the transient chain as far as possible first if deiconifying */ + if (!iconic) + while (self->transient_for) { + if (self->transient_for != TRAN_GROUP) { + if (self->transient_for->iconic == iconic) + break; + self = self->transient_for; + } else { + GSList *it; + + /* the check for TRAN_GROUP is to prevent an infinate loop with + 2 transients of the same group at the head of the group's + members list */ + for (it = self->group->members; it; it = it->next) { + Client *c = it->data; + + if (c != self && c->transient_for->iconic != iconic && + (c->transient_for != TRAN_GROUP || + c->group != self->group)) { + self = it->data; + break; + } + } + if (it == NULL) break; + } + } + if (self->iconic == iconic) return; /* nothing to do */ g_message("%sconifying window: 0x%lx", (iconic ? "I" : "Uni"), @@ -1739,7 +1789,7 @@ void client_shade(Client *self, gboolean shade) self->shaded = shade; client_change_state(self); /* resize the frame to just the titlebar */ - engine_frame_adjust_area(self->frame, FALSE, FALSE); + frame_adjust_area(self->frame, FALSE, FALSE); } void client_close(Client *self) @@ -1788,7 +1838,7 @@ void client_set_desktop(Client *self, guint target, gboolean donthide) self->desktop = target; PROP_SET32(self->window, net_wm_desktop, cardinal, target); /* the frame can display the current desktop state */ - engine_frame_adjust_state(self->frame); + frame_adjust_state(self->frame); /* 'move' the window to the new desktop */ if (!donthide) client_showhide(self); @@ -1805,13 +1855,13 @@ void client_set_desktop(Client *self, guint target, gboolean donthide) focus_order[old] = g_list_remove(focus_order[old], self); if (target == DESKTOP_ALL) { for (i = 0; i < screen_num_desktops; ++i) { - if (focus_new) + if (config_focus_new) focus_order[i] = g_list_prepend(focus_order[i], self); else focus_order[i] = g_list_append(focus_order[i], self); } } else { - if (focus_new) + if (config_focus_new) focus_order[target] = g_list_prepend(focus_order[target], self); else focus_order[target] = g_list_append(focus_order[target], self); @@ -2074,8 +2124,10 @@ gboolean client_focus(Client *self) void client_unfocus(Client *self) { g_assert(focus_client == self); +#ifndef DEBUG_FOCUS g_message("client_unfocus"); - focus_fallback(FALSE); +#endif + focus_fallback(Fallback_Unfocusing); } gboolean client_focused(Client *self)