X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclient.cc;h=eeb09a374981a4fe5cfe9dc30d3f6386c6faa980;hb=5face4c6f35172761367f63ac0b6eaf62d84e532;hp=94813a2e319c1521c0819b4e00a399ba0190e2ad;hpb=b6defb3c1a267d72e8056adf77a33458fe8877ae;p=chaz%2Fopenbox diff --git a/src/client.cc b/src/client.cc index 94813a2e..eeb09a37 100644 --- a/src/client.cc +++ b/src/client.cc @@ -8,6 +8,7 @@ #include "frame.hh" #include "screen.hh" #include "openbox.hh" +#include "bindings.hh" #include "otk/display.hh" #include "otk/property.hh" @@ -44,6 +45,8 @@ Client::Client(int screen, Window window) _transient_for = 0; // pick a layer to start from _layer = Layer_Normal; + // default to not urgent + _urgent = false; getArea(); getDesktop(); @@ -73,7 +76,7 @@ Client::Client(int screen, Window window) updateStrut(); // this makes sure that these windows appear on all desktops - if (_type == Type_Dock || _type == Type_Desktop) + if (/*_type == Type_Dock ||*/ _type == Type_Desktop) _desktop = 0xffffffff; // set the desktop hint, to make sure that it always exists, and to reflect @@ -126,9 +129,13 @@ void Client::getDesktop() // defaults to the current desktop _desktop = openbox->screen(_screen)->desktop(); - otk::Property::get(_window, otk::Property::atoms.net_wm_desktop, - otk::Property::atoms.cardinal, - (long unsigned*)&_desktop); + if (otk::Property::get(_window, otk::Property::atoms.net_wm_desktop, + otk::Property::atoms.cardinal, + (long unsigned*)&_desktop)) { +#ifdef DEBUG +// printf("Window requested desktop: %ld\n", _desktop); +#endif + } } @@ -457,7 +464,7 @@ void Client::updateWMHints(bool initstate) // assume a window takes input if it doesnt specify _can_focus = true; - _urgent = false; + bool ur = false; if ((hints = XGetWMHints(**otk::display, _window)) != NULL) { if (hints->flags & InputHint) @@ -468,7 +475,7 @@ void Client::updateWMHints(bool initstate) _iconic = hints->initial_state == IconicState; if (hints->flags & XUrgencyHint) - _urgent = true; + ur = true; if (hints->flags & WindowGroupHint) { if (hints->window_group != _group) { @@ -481,6 +488,18 @@ void Client::updateWMHints(bool initstate) XFree(hints); } + + if (ur != _urgent) { + _urgent = ur; +#ifdef DEBUG + printf("DEBUG: Urgent Hint for 0x%lx: %s\n", + (long)_window, _urgent ? "ON" : "OFF"); +#endif + // fire the urgent callback if we're mapped, otherwise, wait until after + // we're mapped + if (_urgent && frame) + fireUrgent(); + } } @@ -556,8 +575,8 @@ void Client::updateStrut() _strut.left = data[0]; _strut.right = data[1]; _strut.top = data[2]; - _strut.bottom = data[3]; - + _strut.bottom = data[3]; + openbox->screen(_screen)->updateStrut(); } @@ -1162,7 +1181,6 @@ void Client::applyStartupState() // these are in a carefully crafted order.. if (_iconic) { - printf("MAP ICONIC\n"); _iconic = false; setDesktop(ICONIC_DESKTOP); } @@ -1174,6 +1192,8 @@ void Client::applyStartupState() _shaded = false; shade(true); } + if (_urgent) + fireUrgent(); if (_max_vert); // XXX: incomplete if (_max_horz); // XXX: incomplete @@ -1186,6 +1206,14 @@ void Client::applyStartupState() } +void Client::fireUrgent() +{ + // call the python UrgentWindow callbacks + EventData data(_screen, this, EventAction::UrgentWindow, 0); + openbox->bindings()->fireEvent(&data); +} + + void Client::shade(bool shade) { if (!(_functions & Func_Shade) || // can't @@ -1248,7 +1276,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 @@ -1257,12 +1285,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) { + unmapHandler(ev.xunmap); + } else { + XPutBackEvent(**otk::display, &ev); + return false; + } + } if (_can_focus) XSetInputFocus(**otk::display, _window, @@ -1397,7 +1434,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;