X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclient.cc;h=c69d576a47f1c5c3b4e1d58359d3ae4ce0ae9be3;hb=8f8acc24933830d4f5784616b9b0c5896bde0b93;hp=026f4f2f8bd6b7aad78f12ded2fda0c7a52dab0b;hpb=f11bd1b0cc5973590d1ee547736ac00f50447efa;p=chaz%2Fopenbox diff --git a/src/client.cc b/src/client.cc index 026f4f2f..c69d576a 100644 --- a/src/client.cc +++ b/src/client.cc @@ -43,6 +43,8 @@ OBClient::OBClient(int screen, Window window) _focused = false; // not a transient by default of course _transient_for = 0; + // pick a layer to start from + _layer = Layer_Normal; getArea(); getDesktop(); @@ -897,7 +899,10 @@ void OBClient::clientMessageHandler(const XClientMessageEvent &e) } else if (e.message_type == property->atom(otk::OBProperty::net_wm_state)) { // can't compress these #ifdef DEBUG - printf("net_wm_state for 0x%lx\n", _window); + printf("net_wm_state %s %ld %ld for 0x%lx\n", + (e.data.l[0] == 0 ? "Remove" : e.data.l[0] == 1 ? "Add" : + e.data.l[0] == 2 ? "Toggle" : "INVALID"), + e.data.l[1], e.data.l[2], _window); #endif setState((StateAction)e.data.l[0], e.data.l[1], e.data.l[2]); } else if (e.message_type == @@ -911,6 +916,9 @@ void OBClient::clientMessageHandler(const XClientMessageEvent &e) #ifdef DEBUG printf("net_active_window for 0x%lx\n", _window); #endif + if (_shaded) + shade(false); + // XXX: deiconify focus(); Openbox::instance->screen(_screen)->restack(true, this); // raise } @@ -997,8 +1005,26 @@ void OBClient::move(int x, int y) _area.setPos(x, y); // move the frame to be in the requested position - if (frame) // this can be called while mapping, before frame exists + if (frame) { // this can be called while mapping, before frame exists frame->adjustPosition(); + + // send synthetic configure notify (we don't need to if we aren't mapped + // yet) + XEvent event; + event.type = ConfigureNotify; + event.xconfigure.display = otk::OBDisplay::display; + event.xconfigure.event = _window; + event.xconfigure.window = _window; + event.xconfigure.x = x; + event.xconfigure.y = y; + event.xconfigure.width = _area.width(); + event.xconfigure.height = _area.height(); + event.xconfigure.border_width = _border_width; + event.xconfigure.above = frame->window(); + event.xconfigure.override_redirect = False; + XSendEvent(event.xconfigure.display, event.xconfigure.window, False, + StructureNotifyMask, &event); + } } @@ -1025,7 +1051,7 @@ void OBClient::close() ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; ce.xclient.data.l[4] = 0l; - XSendEvent(otk::OBDisplay::display, _window, False, NoEventMask, &ce); + XSendEvent(otk::OBDisplay::display, _window, false, NoEventMask, &ce); } @@ -1082,9 +1108,12 @@ void OBClient::shade(bool shade) } -bool OBClient::focus() +bool OBClient::focus() const { - if (!(_can_focus || _focus_notify)) return false; + // won't try focus if the client doesn't want it, or if the window isn't + // visible on the screen + if (!(frame->isVisible() && (_can_focus || _focus_notify))) return false; + if (_focused) return true; if (_can_focus) @@ -1112,7 +1141,7 @@ bool OBClient::focus() } -void OBClient::unfocus() +void OBClient::unfocus() const { if (!_focused) return; @@ -1269,8 +1298,14 @@ void OBClient::reparentHandler(const XReparentEvent &e) to an already unmapped window. */ + // we don't want the reparent event, put it back on the stack for the X + // server to deal with after we unmanage the window + XEvent ev; + ev.xreparent = e; + XPutBackEvent(otk::OBDisplay::display, &ev); + // this deletes us etc - Openbox::instance->screen(_screen)->unmanageWindow(this, true); + Openbox::instance->screen(_screen)->unmanageWindow(this); } }