X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclient.cc;h=91d61f4bd20392904744e19f06e675ebfde4b4c9;hb=ff98438acca3ae7ca0b2be66cb39cc29643ecaba;hp=39e47cc4f4e356bec0298888fd21655feeba920f;hpb=8b4004ac68f9a3433e657c5903c064ba37fa6f87;p=chaz%2Fopenbox diff --git a/src/client.cc b/src/client.cc index 39e47cc4..91d61f4b 100644 --- a/src/client.cc +++ b/src/client.cc @@ -37,9 +37,7 @@ Client::Client(int screen, Window window) // update EVERYTHING the first time!! // we default to NormalState, visible - _wmstate = NormalState; _iconic = false; - // no default decors or functions, each has to be enabled - _decorations = _functions = 0; + _wmstate = NormalState; // start unfocused _focused = false; // not a transient by default of course @@ -54,8 +52,7 @@ Client::Client(int screen, Window window) getType(); getMwmHints(); - getState(); // gets all the states except for iconic, which is found from - // the desktop == ICONIC_DESKTOP + getState(); getShaped(); updateProtocols(); @@ -66,23 +63,19 @@ Client::Client(int screen, Window window) getGravity(); // get the attribute gravity updateNormalHints(); // this may override the attribute gravity - updateWMHints(true); // also get the initial_state and set _iconic + // also get the initial_state and set _iconic if we aren't "starting" + // when we're "starting" that means we should use whatever state was already + // on the window over the initial map state, because it was already mapped + updateWMHints(openbox->state() != Openbox::State_Starting); updateTitle(); updateIconTitle(); updateClass(); updateStrut(); - // this makes sure that these windows: - // a) appear on all desktops - // b) don't start iconified - if (_type == Type_Dock || _type == Type_Desktop) { + // this makes sure that these windows appear on all desktops + if (_type == Type_Dock || _type == Type_Desktop) _desktop = 0xffffffff; - } - // restores iconic state when we restart. - // this will override the initial_state if that was set - if (_desktop == ICONIC_DESKTOP) _iconic = true; - // set the desktop hint, to make sure that it always exists, and to reflect // any changes we've made here otk::Property::set(_window, otk::Property::atoms.net_wm_desktop, @@ -307,7 +300,7 @@ void Client::getArea() void Client::getState() { _modal = _shaded = _max_horz = _max_vert = _fullscreen = _above = _below = - _skip_taskbar = _skip_pager = false; + _iconic = _skip_taskbar = _skip_pager = false; unsigned long *state; unsigned long num = (unsigned) -1; @@ -319,6 +312,8 @@ void Client::getState() _modal = true; else if (state[i] == otk::Property::atoms.net_wm_state_shaded) _shaded = true; + else if (state[i] == otk::Property::atoms.net_wm_state_hidden) + _iconic = true; else if (state[i] == otk::Property::atoms.net_wm_state_skip_taskbar) _skip_taskbar = true; else if (state[i] == otk::Property::atoms.net_wm_state_skip_pager) @@ -676,9 +671,10 @@ void Client::setDesktop(long target) _desktop = target; - // set the desktop hint - otk::Property::set(_window, otk::Property::atoms.net_wm_desktop, - otk::Property::atoms.cardinal, (unsigned)_desktop); + // set the desktop hint, but not if we're iconifying + if (_desktop != ICONIC_DESKTOP) + otk::Property::set(_window, otk::Property::atoms.net_wm_desktop, + otk::Property::atoms.cardinal, (unsigned)_desktop); // 'move' the window to the new desktop if (_desktop == openbox->screen(_screen)->desktop() || @@ -1166,8 +1162,8 @@ void Client::applyStartupState() // these are in a carefully crafted order.. if (_iconic) { + printf("MAP ICONIC\n"); _iconic = false; - _desktop = 0; // set some other source desktop so this goes through setDesktop(ICONIC_DESKTOP); } if (_fullscreen) { @@ -1252,7 +1248,7 @@ void Client::fullscreen(bool fs) } -bool Client::focus() const +bool Client::focus() { // won't try focus if the client doesn't want it, or if the window isn't // visible on the screen @@ -1261,12 +1257,21 @@ bool Client::focus() const if (_focused) return true; // do a check to see if the window has already been unmapped or destroyed + // do this intelligently while watching out for unmaps we've generated + // (ignore_unmaps > 0) XEvent ev; - if (XCheckTypedWindowEvent(**otk::display, _window, UnmapNotify, &ev) || - XCheckTypedWindowEvent(**otk::display, _window, DestroyNotify, &ev)) { + if (XCheckTypedWindowEvent(**otk::display, _window, DestroyNotify, &ev)) { XPutBackEvent(**otk::display, &ev); return false; } + while (XCheckTypedWindowEvent(**otk::display, _window, UnmapNotify, &ev)) { + if (ignore_unmaps) { + --ignore_unmaps; + } else { + XPutBackEvent(**otk::display, &ev); + return false; + } + } if (_can_focus) XSetInputFocus(**otk::display, _window, @@ -1401,7 +1406,7 @@ void Client::unmapHandler(const XUnmapEvent &e) { if (ignore_unmaps) { #ifdef DEBUG - printf("Ignored UnmapNotify for 0x%lx (event 0x%lx)\n", e.window, e.event); +// printf("Ignored UnmapNotify for 0x%lx (event 0x%lx)\n", e.window, e.event); #endif // DEBUG ignore_unmaps--; return;