X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient.c;h=4a553224e3c86e3d5c94201339f93b7ea548ca5e;hb=2d1b5d6e0a46cd8d3c89dec7662e28106dee0b88;hp=83291132a14535917763ad0c622b6f743e566fcb;hpb=4ccc4c5ed7d5cffc4bf733191f7bc30fbbf069c8;p=chaz%2Fopenbox diff --git a/openbox/client.c b/openbox/client.c index 83291132..4a553224 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1,3 +1,21 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + client.c for the Openbox window manager + Copyright (c) 2003 Ben Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + #include "client.h" #include "debug.h" #include "startupnotify.h" @@ -165,9 +183,6 @@ void client_manage_all() } } XFree(children); - - if (config_focus_new) - focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); } void client_manage(Window window) @@ -1647,9 +1662,7 @@ static ObStackingLayer calc_layer(ObClient *self) { ObStackingLayer l; - if (self->fullscreen && - (client_focused(self) || client_search_focus_tree(self))) - l = OB_STACKING_LAYER_FULLSCREEN; + if (self->fullscreen) l = OB_STACKING_LAYER_FULLSCREEN; else if (self->type == OB_CLIENT_TYPE_DESKTOP) l = OB_STACKING_LAYER_DESKTOP; else if (self->type == OB_CLIENT_TYPE_DOCK) { @@ -1671,9 +1684,7 @@ static void client_calc_layer_recursive(ObClient *self, ObClient *orig, old = self->layer; own = calc_layer(self); - self->layer = MAX(l, own); - - g_message("calc for 0x%x %d %d", self->window, old, self->layer); + self->layer = l > own ? l : own; for (it = self->transients; it; it = it->next) client_calc_layer_recursive(it->data, orig, @@ -1681,6 +1692,7 @@ static void client_calc_layer_recursive(ObClient *self, ObClient *orig, if (!raised && l != old) if (orig->frame) { /* only restack if the original window is managed */ + /* XXX add_non_intrusive ever? */ stacking_remove(CLIENT_AS_WINDOW(self)); stacking_add(CLIENT_AS_WINDOW(self)); } @@ -1945,8 +1957,8 @@ void client_configure_full(ObClient *self, ObCorner anchor, (resized && config_redraw_resize)))); /* if the client is enlarging, the resize the client before the frame */ - if (send_resize_client && (w > oldw || h > oldh)) - XResizeWindow(ob_display, self->window, MAX(w, oldw), MAX(h, oldh)); + if (send_resize_client && user && (w > oldw || h > oldh)) + XResizeWindow(ob_display, self->window, MAX(w, oldw), MAX(h, oldh)); /* move/resize the frame to match the request */ if (self->frame) { @@ -1976,12 +1988,12 @@ void client_configure_full(ObClient *self, ObCorner anchor, event.xconfigure.override_redirect = FALSE; XSendEvent(event.xconfigure.display, event.xconfigure.window, FALSE, StructureNotifyMask, &event); - } + } } /* if the client is shrinking, then resize the frame before the client */ - if (send_resize_client && (w <= oldw || h <= oldh)) - XResizeWindow(ob_display, self->window, w, h); + if (send_resize_client && (!user || (w <= oldw || h <= oldh))) + XResizeWindow(ob_display, self->window, w, h); XFlush(ob_display); } @@ -2059,7 +2071,14 @@ static void client_iconify_recursive(ObClient *self, if (iconic) { if (self->functions & OB_CLIENT_FUNC_ICONIFY) { + long old; + + old = self->wmstate; self->wmstate = IconicState; + if (old != self->wmstate) + PROP_MSG(self->window, kde_wm_change_state, + self->wmstate, 1, 0, 0); + self->ignore_unmaps++; /* we unmap the client itself so that we can get MapRequest events, and because the ICCCM tells us to! */ @@ -2073,9 +2092,17 @@ static void client_iconify_recursive(ObClient *self, changed = TRUE; } } else { + long old; + if (curdesk) client_set_desktop(self, screen_desktop, FALSE); + + old = self->wmstate; self->wmstate = self->shaded ? IconicState : NormalState; + if (old != self->wmstate) + PROP_MSG(self->window, kde_wm_change_state, + self->wmstate, 1, 0, 0); + XMapWindow(ob_display, self->window); /* this puts it after the current focused window */ @@ -2224,8 +2251,16 @@ void client_shade(ObClient *self, gboolean shade) self->shaded == shade) return; /* already done */ /* when we're iconic, don't change the wmstate */ - if (!self->iconic) - self->wmstate = shade ? IconicState : NormalState; + if (!self->iconic) { + long old; + + old = self->wmstate; + self->wmstate = shade ? IconicState : NormalState; + if (old != self->wmstate) + PROP_MSG(self->window, kde_wm_change_state, + self->wmstate, 1, 0, 0); + } + self->shaded = shade; client_change_state(self); /* resize the frame to just the titlebar */ @@ -2529,15 +2564,14 @@ gboolean client_focus(ObClient *self) /* choose the correct target */ self = client_focus_target(self); - if (!self->frame->visible) { - /* update the focus lists */ - focus_order_to_top(self); + if (!client_can_focus(self)) { + if (!self->frame->visible) { + /* update the focus lists */ + focus_order_to_top(self); + } return FALSE; } - if (!client_can_focus(self)) - return FALSE; - if (self->can_focus) { /* RevertToPointerRoot causes much more headache than RevertToNone, so I choose to use it always, hopefully to find errors quicker, if any @@ -2565,8 +2599,6 @@ gboolean client_focus(ObClient *self) XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce); } - focus_set_client(self); - #ifdef DEBUG_FOCUS ob_debug("%sively focusing %lx at %d\n", (self->can_focus ? "act" : "pass"), @@ -2582,11 +2614,12 @@ gboolean client_focus(ObClient *self) void client_unfocus(ObClient *self) { - g_assert(focus_client == self); + if (focus_client == self) { #ifdef DEBUG_FOCUS - ob_debug("client_unfocus for %lx\n", self->window); + ob_debug("client_unfocus for %lx\n", self->window); #endif - focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING); + focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING); + } } void client_activate(ObClient *self, gboolean here) @@ -3004,3 +3037,24 @@ int client_directional_edge_search(ObClient *c, ObDirection dir) } return dest; } + +ObClient* client_under_pointer() +{ + int x, y; + GList *it; + ObClient *ret = NULL; + + if (screen_pointer_pos(&x, &y)) { + for (it = stacking_list; it != NULL; it = it->next) { + if (WINDOW_IS_CLIENT(it->data)) { + ObClient *c = WINDOW_AS_CLIENT(it->data); + if (c->desktop == screen_desktop && + RECT_CONTAINS(c->frame->area, x, y)) { + ret = c; + break; + } + } + } + } + return ret; +}