1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
11 #include "bindings.hh"
12 #include "otk/display.hh"
13 #include "otk/property.hh"
17 #include <X11/Xutil.h>
18 #include <X11/Xatom.h>
23 #define _(str) gettext(str)
30 Client::Client(int screen
, Window window
)
31 : otk::EventHandler(),
32 WidgetBase(WidgetBase::Type_Client
),
33 frame(0), _screen(screen
), _window(window
)
40 // update EVERYTHING the first time!!
42 // we default to NormalState, visible
43 _wmstate
= NormalState
;
46 // not a transient by default of course
48 // pick a layer to start from
49 _layer
= Layer_Normal
;
50 // default to not urgent
52 // not positioned unless specified
54 // nothing is disabled unless specified
55 _disabled_decorations
= 0;
62 getType(); // this can change the mwmhints for special cases
69 getGravity(); // get the attribute gravity
70 updateNormalHints(); // this may override the attribute gravity
72 // got the type, the mwmhints, the protocols, and the normal hints (min/max
73 // sizes), so we're ready to set up
74 // the decorations/functions
75 setupDecorAndFunctions();
77 // also get the initial_state and set _iconic if we aren't "starting"
78 // when we're "starting" that means we should use whatever state was already
79 // on the window over the initial map state, because it was already mapped
80 updateWMHints(openbox
->state() != Openbox::State_Starting
);
86 // this makes sure that these windows appear on all desktops
87 if (/*_type == Type_Dock ||*/ _type
== Type_Desktop
)
88 _desktop
= 0xffffffff;
90 // set the desktop hint, to make sure that it always exists, and to reflect
91 // any changes we've made here
92 otk::Property::set(_window
, otk::Property::atoms
.net_wm_desktop
,
93 otk::Property::atoms
.cardinal
, (unsigned)_desktop
);
101 // clean up childrens' references
102 while (!_transients
.empty()) {
103 _transients
.front()->_transient_for
= 0;
104 _transients
.pop_front();
107 // clean up parents reference to this
109 _transient_for
->_transients
.remove(this); // remove from old parent
111 if (openbox
->state() != Openbox::State_Exiting
) {
112 // these values should not be persisted across a window unmapping/mapping
113 otk::Property::erase(_window
, otk::Property::atoms
.net_wm_desktop
);
114 otk::Property::erase(_window
, otk::Property::atoms
.net_wm_state
);
116 // if we're left in an iconic state, the client wont be mapped. this is
117 // bad, since we will no longer be managing the window on restart
119 XMapWindow(**otk::display
, _window
);
124 bool Client::validate() const
126 XSync(**otk::display
, false); // get all events on the server
129 if (XCheckTypedWindowEvent(**otk::display
, _window
, DestroyNotify
, &e
) ||
130 XCheckTypedWindowEvent(**otk::display
, _window
, UnmapNotify
, &e
)) {
131 XPutBackEvent(**otk::display
, &e
);
139 void Client::getGravity()
141 XWindowAttributes wattrib
;
144 ret
= XGetWindowAttributes(**otk::display
, _window
, &wattrib
);
145 assert(ret
!= BadWindow
);
146 _gravity
= wattrib
.win_gravity
;
150 void Client::getDesktop()
152 // defaults to the current desktop
153 _desktop
= openbox
->screen(_screen
)->desktop();
155 if (otk::Property::get(_window
, otk::Property::atoms
.net_wm_desktop
,
156 otk::Property::atoms
.cardinal
,
157 (long unsigned*)&_desktop
)) {
159 // printf("Window requested desktop: %ld\n", _desktop);
165 void Client::getType()
167 _type
= (WindowType
) -1;
170 unsigned long num
= (unsigned) -1;
171 if (otk::Property::get(_window
, otk::Property::atoms
.net_wm_window_type
,
172 otk::Property::atoms
.atom
, &num
, &val
)) {
173 // use the first value that we know about in the array
174 for (unsigned long i
= 0; i
< num
; ++i
) {
175 if (val
[i
] == otk::Property::atoms
.net_wm_window_type_desktop
)
176 _type
= Type_Desktop
;
177 else if (val
[i
] == otk::Property::atoms
.net_wm_window_type_dock
)
179 else if (val
[i
] == otk::Property::atoms
.net_wm_window_type_toolbar
)
180 _type
= Type_Toolbar
;
181 else if (val
[i
] == otk::Property::atoms
.net_wm_window_type_menu
)
183 else if (val
[i
] == otk::Property::atoms
.net_wm_window_type_utility
)
184 _type
= Type_Utility
;
185 else if (val
[i
] == otk::Property::atoms
.net_wm_window_type_splash
)
187 else if (val
[i
] == otk::Property::atoms
.net_wm_window_type_dialog
)
189 else if (val
[i
] == otk::Property::atoms
.net_wm_window_type_normal
)
191 else if (val
[i
] == otk::Property::atoms
.kde_net_wm_window_type_override
){
192 // prevent this window from getting any decor or functionality
193 _mwmhints
.flags
&= MwmFlag_Functions
| MwmFlag_Decorations
;
194 _mwmhints
.decorations
= 0;
195 _mwmhints
.functions
= 0;
197 if (_type
!= (WindowType
) -1)
198 break; // grab the first known type
203 if (_type
== (WindowType
) -1) {
205 * the window type hint was not set, which means we either classify ourself
206 * as a normal window or a dialog, depending on if we are a transient.
216 void Client::setupDecorAndFunctions()
218 // start with everything (cept fullscreen)
219 _decorations
= Decor_Titlebar
| Decor_Handle
| Decor_Border
|
220 Decor_AllDesktops
| Decor_Iconify
| Decor_Maximize
;
221 _functions
= Func_Resize
| Func_Move
| Func_Iconify
| Func_Maximize
|
223 if (_delete_window
) {
224 _decorations
|= Decor_Close
;
225 _functions
|= Func_Close
;
228 if (!(_min_size
.x() < _max_size
.x() || _min_size
.y() < _max_size
.y())) {
229 _decorations
&= ~(Decor_Maximize
| Decor_Handle
);
230 _functions
&= ~(Func_Resize
| Func_Maximize
);
235 // normal windows retain all of the possible decorations and
236 // functionality, and are the only windows that you can fullscreen
237 _functions
|= Func_Fullscreen
;
241 // dialogs cannot be maximized
242 _decorations
&= ~Decor_Maximize
;
243 _functions
&= ~Func_Maximize
;
249 // these windows get less functionality
250 _decorations
&= ~(Decor_Iconify
| Decor_Handle
);
251 _functions
&= ~(Func_Iconify
| Func_Resize
);
257 // none of these windows are manipulated by the window manager
263 // Mwm Hints are applied subtractively to what has already been chosen for
264 // decor and functionality
265 if (_mwmhints
.flags
& MwmFlag_Decorations
) {
266 if (! (_mwmhints
.decorations
& MwmDecor_All
)) {
267 if (! (_mwmhints
.decorations
& MwmDecor_Border
))
268 _decorations
&= ~Decor_Border
;
269 if (! (_mwmhints
.decorations
& MwmDecor_Handle
))
270 _decorations
&= ~Decor_Handle
;
271 if (! (_mwmhints
.decorations
& MwmDecor_Title
)) {
272 _decorations
&= ~Decor_Titlebar
;
273 // if we don't have a titlebar, then we cannot shade!
274 _functions
&= ~Func_Shade
;
276 if (! (_mwmhints
.decorations
& MwmDecor_Iconify
))
277 _decorations
&= ~Decor_Iconify
;
278 if (! (_mwmhints
.decorations
& MwmDecor_Maximize
))
279 _decorations
&= ~Decor_Maximize
;
283 if (_mwmhints
.flags
& MwmFlag_Functions
) {
284 if (! (_mwmhints
.functions
& MwmFunc_All
)) {
285 if (! (_mwmhints
.functions
& MwmFunc_Resize
))
286 _functions
&= ~Func_Resize
;
287 if (! (_mwmhints
.functions
& MwmFunc_Move
))
288 _functions
&= ~Func_Move
;
289 if (! (_mwmhints
.functions
& MwmFunc_Iconify
))
290 _functions
&= ~Func_Iconify
;
291 if (! (_mwmhints
.functions
& MwmFunc_Maximize
))
292 _functions
&= ~Func_Maximize
;
293 // dont let mwm hints kill the close button
294 //if (! (_mwmhints.functions & MwmFunc_Close))
295 // _functions &= ~Func_Close;
299 // finally, user specified disabled decorations are applied to subtract
301 if (_disabled_decorations
& Decor_Titlebar
)
302 _decorations
&= ~Decor_Titlebar
;
303 if (_disabled_decorations
& Decor_Handle
)
304 _decorations
&= ~Decor_Handle
;
305 if (_disabled_decorations
& Decor_Border
)
306 _decorations
&= ~Decor_Border
;
307 if (_disabled_decorations
& Decor_Iconify
)
308 _decorations
&= ~Decor_Iconify
;
309 if (_disabled_decorations
& Decor_Maximize
)
310 _decorations
&= ~Decor_Maximize
;
311 if (_disabled_decorations
& Decor_AllDesktops
)
312 _decorations
&= ~Decor_AllDesktops
;
313 if (_disabled_decorations
& Decor_Close
)
314 _decorations
&= ~Decor_Close
;
316 // You can't shade without a titlebar
317 if (!(_decorations
& Decor_Titlebar
))
318 _functions
&= ~Func_Shade
;
320 changeAllowedActions();
323 frame
->adjustSize(); // change the decors on the frame
324 frame
->adjustPosition(); // with more/less decorations, we may need to be
330 void Client::getMwmHints()
332 unsigned long num
= MwmHints::elements
;
333 unsigned long *hints
;
335 _mwmhints
.flags
= 0; // default to none
337 if (!otk::Property::get(_window
, otk::Property::atoms
.motif_wm_hints
,
338 otk::Property::atoms
.motif_wm_hints
, &num
,
339 (unsigned long **)&hints
))
342 if (num
>= MwmHints::elements
) {
343 // retrieved the hints
344 _mwmhints
.flags
= hints
[0];
345 _mwmhints
.functions
= hints
[1];
346 _mwmhints
.decorations
= hints
[2];
353 void Client::getArea()
355 XWindowAttributes wattrib
;
358 ret
= XGetWindowAttributes(**otk::display
, _window
, &wattrib
);
359 assert(ret
!= BadWindow
);
361 _area
.setRect(wattrib
.x
, wattrib
.y
, wattrib
.width
, wattrib
.height
);
362 _border_width
= wattrib
.border_width
;
366 void Client::getState()
368 _modal
= _shaded
= _max_horz
= _max_vert
= _fullscreen
= _above
= _below
=
369 _iconic
= _skip_taskbar
= _skip_pager
= false;
371 unsigned long *state
;
372 unsigned long num
= (unsigned) -1;
374 if (otk::Property::get(_window
, otk::Property::atoms
.net_wm_state
,
375 otk::Property::atoms
.atom
, &num
, &state
)) {
376 for (unsigned long i
= 0; i
< num
; ++i
) {
377 if (state
[i
] == otk::Property::atoms
.net_wm_state_modal
)
379 else if (state
[i
] == otk::Property::atoms
.net_wm_state_shaded
)
381 else if (state
[i
] == otk::Property::atoms
.net_wm_state_hidden
)
383 else if (state
[i
] == otk::Property::atoms
.net_wm_state_skip_taskbar
)
384 _skip_taskbar
= true;
385 else if (state
[i
] == otk::Property::atoms
.net_wm_state_skip_pager
)
387 else if (state
[i
] == otk::Property::atoms
.net_wm_state_fullscreen
)
389 else if (state
[i
] == otk::Property::atoms
.net_wm_state_maximized_vert
)
391 else if (state
[i
] == otk::Property::atoms
.net_wm_state_maximized_horz
)
393 else if (state
[i
] == otk::Property::atoms
.net_wm_state_above
)
395 else if (state
[i
] == otk::Property::atoms
.net_wm_state_below
)
404 void Client::getShaped()
408 if (otk::display
->shape()) {
413 XShapeSelectInput(**otk::display
, _window
, ShapeNotifyMask
);
415 XShapeQueryExtents(**otk::display
, _window
, &s
, &foo
,
416 &foo
, &ufoo
, &ufoo
, &foo
, &foo
, &foo
, &ufoo
, &ufoo
);
423 void Client::calcLayer() {
426 if (_iconic
) l
= Layer_Icon
;
427 else if (_fullscreen
) l
= Layer_Fullscreen
;
428 else if (_type
== Type_Desktop
) l
= Layer_Desktop
;
429 else if (_type
== Type_Dock
) {
430 if (!_below
) l
= Layer_Top
;
431 else l
= Layer_Normal
;
433 else if (_above
) l
= Layer_Above
;
434 else if (_below
) l
= Layer_Below
;
435 else l
= Layer_Normal
;
441 if we don't have a frame, then we aren't mapped yet (and this would
444 openbox
->screen(_screen
)->raiseWindow(this);
450 void Client::updateProtocols()
455 _focus_notify
= false;
456 _delete_window
= false;
458 if (XGetWMProtocols(**otk::display
, _window
, &proto
, &num_return
)) {
459 for (int i
= 0; i
< num_return
; ++i
) {
460 if (proto
[i
] == otk::Property::atoms
.wm_delete_window
) {
461 // this means we can request the window to close
462 _delete_window
= true;
463 } else if (proto
[i
] == otk::Property::atoms
.wm_take_focus
)
464 // if this protocol is requested, then the window will be notified
465 // by the window manager whenever it receives focus
466 _focus_notify
= true;
473 void Client::updateNormalHints()
477 int oldgravity
= _gravity
;
482 _size_inc
.setPoint(1, 1);
483 _base_size
.setPoint(0, 0);
484 _min_size
.setPoint(0, 0);
485 _max_size
.setPoint(INT_MAX
, INT_MAX
);
487 // get the hints from the window
488 if (XGetWMNormalHints(**otk::display
, _window
, &size
, &ret
)) {
489 _positioned
= (size
.flags
& (PPosition
|USPosition
));
491 if (size
.flags
& PWinGravity
) {
492 _gravity
= size
.win_gravity
;
494 // if the client has a frame, i.e. has already been mapped and is
495 // changing its gravity
496 if (frame
&& _gravity
!= oldgravity
) {
497 // move our idea of the client's position based on its new gravity
498 int x
= frame
->rect().x(), y
= frame
->rect().y();
499 frame
->frameGravity(x
, y
);
504 if (size
.flags
& PAspect
) {
505 if (size
.min_aspect
.y
) _min_ratio
= size
.min_aspect
.x
/size
.min_aspect
.y
;
506 if (size
.max_aspect
.y
) _max_ratio
= size
.max_aspect
.x
/size
.max_aspect
.y
;
509 if (size
.flags
& PMinSize
)
510 _min_size
.setPoint(size
.min_width
, size
.min_height
);
512 if (size
.flags
& PMaxSize
)
513 _max_size
.setPoint(size
.max_width
, size
.max_height
);
515 if (size
.flags
& PBaseSize
)
516 _base_size
.setPoint(size
.base_width
, size
.base_height
);
518 if (size
.flags
& PResizeInc
)
519 _size_inc
.setPoint(size
.width_inc
, size
.height_inc
);
524 void Client::updateWMHints(bool initstate
)
528 // assume a window takes input if it doesnt specify
532 if ((hints
= XGetWMHints(**otk::display
, _window
)) != NULL
) {
533 if (hints
->flags
& InputHint
)
534 _can_focus
= hints
->input
;
536 // only do this when initstate is true!
537 if (initstate
&& (hints
->flags
& StateHint
))
538 _iconic
= hints
->initial_state
== IconicState
;
540 if (hints
->flags
& XUrgencyHint
)
543 if (hints
->flags
& WindowGroupHint
) {
544 if (hints
->window_group
!= _group
) {
545 // XXX: remove from the old group if there was one
546 _group
= hints
->window_group
;
547 // XXX: do stuff with the group
558 printf("DEBUG: Urgent Hint for 0x%lx: %s\n",
559 (long)_window
, _urgent
? "ON" : "OFF");
561 // fire the urgent callback if we're mapped, otherwise, wait until after
569 void Client::updateTitle()
574 if (!otk::Property::get(_window
, otk::Property::atoms
.net_wm_name
,
575 otk::Property::utf8
, &_title
)) {
577 otk::Property::get(_window
, otk::Property::atoms
.wm_name
,
578 otk::Property::ascii
, &_title
);
582 _title
= _("Unnamed Window");
585 frame
->setTitle(_title
);
589 void Client::updateIconTitle()
594 if (!otk::Property::get(_window
, otk::Property::atoms
.net_wm_icon_name
,
595 otk::Property::utf8
, &_icon_title
)) {
597 otk::Property::get(_window
, otk::Property::atoms
.wm_icon_name
,
598 otk::Property::ascii
, &_icon_title
);
602 _icon_title
= _("Unnamed Window");
606 void Client::updateClass()
609 _app_name
= _app_class
= _role
= "";
611 otk::Property::StringVect v
;
612 unsigned long num
= 2;
614 if (otk::Property::get(_window
, otk::Property::atoms
.wm_class
,
615 otk::Property::ascii
, &num
, &v
)) {
616 if (num
> 0) _app_name
= v
[0].c_str();
617 if (num
> 1) _app_class
= v
[1].c_str();
622 if (otk::Property::get(_window
, otk::Property::atoms
.wm_window_role
,
623 otk::Property::ascii
, &num
, &v
)) {
624 if (num
> 0) _role
= v
[0].c_str();
629 void Client::updateStrut()
631 unsigned long num
= 4;
633 if (!otk::Property::get(_window
, otk::Property::atoms
.net_wm_strut
,
634 otk::Property::atoms
.cardinal
, &num
, &data
))
638 _strut
.left
= data
[0];
639 _strut
.right
= data
[1];
640 _strut
.top
= data
[2];
641 _strut
.bottom
= data
[3];
643 // updating here is pointless while we're being mapped cuz we're not in
644 // the screen's client list yet
646 openbox
->screen(_screen
)->updateStrut();
653 void Client::updateTransientFor()
658 if (XGetTransientForHint(**otk::display
, _window
, &t
) &&
659 t
!= _window
) { // cant be transient to itself!
660 c
= openbox
->findClient(t
);
661 assert(c
!= this); // if this happens then we need to check for it
663 if (!c
/*XXX: && _group*/) {
664 // not transient to a client, see if it is transient for a group
665 if (//t == _group->leader() ||
667 t
== otk::display
->screenInfo(_screen
)->rootWindow()) {
668 // window is a transient for its group!
669 // XXX: for now this is treated as non-transient.
670 // this needs to be fixed!
675 // if anything has changed...
676 if (c
!= _transient_for
) {
678 _transient_for
->_transients
.remove(this); // remove from old parent
681 _transient_for
->_transients
.push_back(this); // add to new parent
683 // XXX: change decor status?
688 void Client::propertyHandler(const XPropertyEvent
&e
)
690 otk::EventHandler::propertyHandler(e
);
692 // validate cuz we query stuff off the client here
693 if (!validate()) return;
695 // compress changes to a single property into a single change
697 while (XCheckTypedEvent(**otk::display
, e
.type
, &ce
)) {
698 // XXX: it would be nice to compress ALL changes to a property, not just
699 // changes in a row without other props between.
700 if (ce
.xproperty
.atom
!= e
.atom
) {
701 XPutBackEvent(**otk::display
, &ce
);
706 if (e
.atom
== XA_WM_NORMAL_HINTS
) {
708 setupDecorAndFunctions(); // normal hints can make a window non-resizable
709 } else if (e
.atom
== XA_WM_HINTS
)
711 else if (e
.atom
== XA_WM_TRANSIENT_FOR
) {
712 updateTransientFor();
714 calcLayer(); // type may have changed, so update the layer
715 setupDecorAndFunctions();
717 else if (e
.atom
== otk::Property::atoms
.net_wm_name
||
718 e
.atom
== otk::Property::atoms
.wm_name
)
720 else if (e
.atom
== otk::Property::atoms
.net_wm_icon_name
||
721 e
.atom
== otk::Property::atoms
.wm_icon_name
)
723 else if (e
.atom
== otk::Property::atoms
.wm_class
)
725 else if (e
.atom
== otk::Property::atoms
.wm_protocols
) {
727 setupDecorAndFunctions();
729 else if (e
.atom
== otk::Property::atoms
.net_wm_strut
)
734 void Client::setWMState(long state
)
736 if (state
== _wmstate
) return; // no change
740 setDesktop(ICONIC_DESKTOP
);
743 setDesktop(openbox
->screen(_screen
)->desktop());
749 void Client::setDesktop(long target
)
751 if (target
== _desktop
) return;
753 printf("Setting desktop %ld\n", target
);
755 if (!(target
>= 0 || target
== (signed)0xffffffff ||
756 target
== ICONIC_DESKTOP
))
761 // set the desktop hint, but not if we're iconifying
762 if (_desktop
!= ICONIC_DESKTOP
)
763 otk::Property::set(_window
, otk::Property::atoms
.net_wm_desktop
,
764 otk::Property::atoms
.cardinal
, (unsigned)_desktop
);
766 // 'move' the window to the new desktop
767 if (_desktop
== openbox
->screen(_screen
)->desktop() ||
768 _desktop
== (signed)0xffffffff)
773 // Handle Iconic state. Iconic state is maintained by the client being a
774 // member of the ICONIC_DESKTOP, so this is where we make iconifying and
775 // uniconifying happen.
776 bool i
= _desktop
== ICONIC_DESKTOP
;
777 if (i
!= _iconic
) { // has the state changed?
780 _wmstate
= IconicState
;
782 // we unmap the client itself so that we can get MapRequest events, and
783 // because the ICCCM tells us to!
784 XUnmapWindow(**otk::display
, _window
);
786 _wmstate
= NormalState
;
787 XMapWindow(**otk::display
, _window
);
792 frame
->adjustState();
796 void Client::setState(StateAction action
, long data1
, long data2
)
798 bool shadestate
= _shaded
;
799 bool fsstate
= _fullscreen
;
800 bool maxh
= _max_horz
;
801 bool maxv
= _max_vert
;
803 if (!(action
== State_Add
|| action
== State_Remove
||
804 action
== State_Toggle
))
805 return; // an invalid action was passed to the client message, ignore it
807 for (int i
= 0; i
< 2; ++i
) {
808 Atom state
= i
== 0 ? data1
: data2
;
810 if (! state
) continue;
812 // if toggling, then pick whether we're adding or removing
813 if (action
== State_Toggle
) {
814 if (state
== otk::Property::atoms
.net_wm_state_modal
)
815 action
= _modal
? State_Remove
: State_Add
;
816 else if (state
== otk::Property::atoms
.net_wm_state_maximized_vert
)
817 action
= _max_vert
? State_Remove
: State_Add
;
818 else if (state
== otk::Property::atoms
.net_wm_state_maximized_horz
)
819 action
= _max_horz
? State_Remove
: State_Add
;
820 else if (state
== otk::Property::atoms
.net_wm_state_shaded
)
821 action
= _shaded
? State_Remove
: State_Add
;
822 else if (state
== otk::Property::atoms
.net_wm_state_skip_taskbar
)
823 action
= _skip_taskbar
? State_Remove
: State_Add
;
824 else if (state
== otk::Property::atoms
.net_wm_state_skip_pager
)
825 action
= _skip_pager
? State_Remove
: State_Add
;
826 else if (state
== otk::Property::atoms
.net_wm_state_fullscreen
)
827 action
= _fullscreen
? State_Remove
: State_Add
;
828 else if (state
== otk::Property::atoms
.net_wm_state_above
)
829 action
= _above
? State_Remove
: State_Add
;
830 else if (state
== otk::Property::atoms
.net_wm_state_below
)
831 action
= _below
? State_Remove
: State_Add
;
834 if (action
== State_Add
) {
835 if (state
== otk::Property::atoms
.net_wm_state_modal
) {
836 if (_modal
) continue;
838 // XXX: give it focus if another window has focus that shouldnt now
839 } else if (state
== otk::Property::atoms
.net_wm_state_maximized_vert
) {
841 } else if (state
== otk::Property::atoms
.net_wm_state_maximized_horz
) {
842 if (_max_horz
) continue;
844 // XXX: resize the window etc
845 } else if (state
== otk::Property::atoms
.net_wm_state_shaded
) {
847 } else if (state
== otk::Property::atoms
.net_wm_state_skip_taskbar
) {
848 _skip_taskbar
= true;
849 } else if (state
== otk::Property::atoms
.net_wm_state_skip_pager
) {
851 } else if (state
== otk::Property::atoms
.net_wm_state_fullscreen
) {
853 } else if (state
== otk::Property::atoms
.net_wm_state_above
) {
854 if (_above
) continue;
856 } else if (state
== otk::Property::atoms
.net_wm_state_below
) {
857 if (_below
) continue;
861 } else { // action == State_Remove
862 if (state
== otk::Property::atoms
.net_wm_state_modal
) {
863 if (!_modal
) continue;
865 } else if (state
== otk::Property::atoms
.net_wm_state_maximized_vert
) {
867 } else if (state
== otk::Property::atoms
.net_wm_state_maximized_horz
) {
869 } else if (state
== otk::Property::atoms
.net_wm_state_shaded
) {
871 } else if (state
== otk::Property::atoms
.net_wm_state_skip_taskbar
) {
872 _skip_taskbar
= false;
873 } else if (state
== otk::Property::atoms
.net_wm_state_skip_pager
) {
875 } else if (state
== otk::Property::atoms
.net_wm_state_fullscreen
) {
877 } else if (state
== otk::Property::atoms
.net_wm_state_above
) {
878 if (!_above
) continue;
880 } else if (state
== otk::Property::atoms
.net_wm_state_below
) {
881 if (!_below
) continue;
886 if (maxh
!= _max_horz
|| maxv
!= _max_vert
) {
887 if (maxh
!= _max_horz
&& maxv
!= _max_vert
) { // toggling both
888 if (maxh
== maxv
) { // both going the same way
889 maximize(maxh
, 0, true);
891 maximize(maxh
, 1, true);
892 maximize(maxv
, 2, true);
894 } else { // toggling one
895 if (maxh
!= _max_horz
)
896 maximize(maxh
, 1, true);
898 maximize(maxv
, 2, true);
901 // change fullscreen state before shading, as it will affect if the window
903 if (fsstate
!= _fullscreen
)
904 fullscreen(fsstate
, true);
905 if (shadestate
!= _shaded
)
908 changeState(); // change the hint to relect these changes
912 void Client::toggleClientBorder(bool addborder
)
914 // adjust our idea of where the client is, based on its border. When the
915 // border is removed, the client should now be considered to be in a
916 // different position.
917 // when re-adding the border to the client, the same operation needs to be
919 int oldx
= _area
.x(), oldy
= _area
.y();
920 int x
= oldx
, y
= oldy
;
923 case NorthWestGravity
:
925 case SouthWestGravity
:
927 case NorthEastGravity
:
929 case SouthEastGravity
:
930 if (addborder
) x
-= _border_width
* 2;
931 else x
+= _border_width
* 2;
938 if (addborder
) x
-= _border_width
;
939 else x
+= _border_width
;
944 case NorthWestGravity
:
946 case NorthEastGravity
:
948 case SouthWestGravity
:
950 case SouthEastGravity
:
951 if (addborder
) y
-= _border_width
* 2;
952 else y
+= _border_width
* 2;
959 if (addborder
) y
-= _border_width
;
960 else y
+= _border_width
;
966 XSetWindowBorderWidth(**otk::display
, _window
, _border_width
);
968 // move the client so it is back it the right spot _with_ its border!
969 if (x
!= oldx
|| y
!= oldy
)
970 XMoveWindow(**otk::display
, _window
, x
, y
);
972 XSetWindowBorderWidth(**otk::display
, _window
, 0);
976 void Client::clientMessageHandler(const XClientMessageEvent
&e
)
978 otk::EventHandler::clientMessageHandler(e
);
980 // validate cuz we query stuff off the client here
981 if (!validate()) return;
983 if (e
.format
!= 32) return;
985 if (e
.message_type
== otk::Property::atoms
.wm_change_state
) {
986 // compress changes into a single change
987 bool compress
= false;
989 while (XCheckTypedEvent(**otk::display
, e
.type
, &ce
)) {
990 // XXX: it would be nice to compress ALL messages of a type, not just
991 // messages in a row without other message types between.
992 if (ce
.xclient
.message_type
!= e
.message_type
) {
993 XPutBackEvent(**otk::display
, &ce
);
999 setWMState(ce
.xclient
.data
.l
[0]); // use the found event
1001 setWMState(e
.data
.l
[0]); // use the original event
1002 } else if (e
.message_type
== otk::Property::atoms
.net_wm_desktop
) {
1003 // compress changes into a single change
1004 bool compress
= false;
1006 while (XCheckTypedEvent(**otk::display
, e
.type
, &ce
)) {
1007 // XXX: it would be nice to compress ALL messages of a type, not just
1008 // messages in a row without other message types between.
1009 if (ce
.xclient
.message_type
!= e
.message_type
) {
1010 XPutBackEvent(**otk::display
, &ce
);
1016 setDesktop(e
.data
.l
[0]); // use the found event
1018 setDesktop(e
.data
.l
[0]); // use the original event
1019 } else if (e
.message_type
== otk::Property::atoms
.net_wm_state
) {
1020 // can't compress these
1022 printf("net_wm_state %s %ld %ld for 0x%lx\n",
1023 (e
.data
.l
[0] == 0 ? "Remove" : e
.data
.l
[0] == 1 ? "Add" :
1024 e
.data
.l
[0] == 2 ? "Toggle" : "INVALID"),
1025 e
.data
.l
[1], e
.data
.l
[2], _window
);
1027 setState((StateAction
)e
.data
.l
[0], e
.data
.l
[1], e
.data
.l
[2]);
1028 } else if (e
.message_type
== otk::Property::atoms
.net_close_window
) {
1030 printf("net_close_window for 0x%lx\n", _window
);
1033 } else if (e
.message_type
== otk::Property::atoms
.net_active_window
) {
1035 printf("net_active_window for 0x%lx\n", _window
);
1038 setDesktop(openbox
->screen(_screen
)->desktop());
1043 openbox
->screen(_screen
)->raiseWindow(this);
1049 void Client::shapeHandler(const XShapeEvent
&e
)
1051 otk::EventHandler::shapeHandler(e
);
1053 if (e
.kind
== ShapeBounding
) {
1055 frame
->adjustShape();
1061 void Client::resize(Corner anchor
, int w
, int h
)
1063 if (!(_functions
& Func_Resize
)) return;
1064 internal_resize(anchor
, w
, h
);
1068 void Client::internal_resize(Corner anchor
, int w
, int h
, bool user
,
1071 w
-= _base_size
.x();
1072 h
-= _base_size
.y();
1075 // for interactive resizing. have to move half an increment in each
1077 int mw
= w
% _size_inc
.x(); // how far we are towards the next size inc
1078 int mh
= h
% _size_inc
.y();
1079 int aw
= _size_inc
.x() / 2; // amount to add
1080 int ah
= _size_inc
.y() / 2;
1081 // don't let us move into a new size increment
1082 if (mw
+ aw
>= _size_inc
.x()) aw
= _size_inc
.x() - mw
- 1;
1083 if (mh
+ ah
>= _size_inc
.y()) ah
= _size_inc
.y() - mh
- 1;
1087 // if this is a user-requested resize, then check against min/max sizes
1088 // and aspect ratios
1090 // smaller than min size or bigger than max size?
1091 if (w
< _min_size
.x()) w
= _min_size
.x();
1092 else if (w
> _max_size
.x()) w
= _max_size
.x();
1093 if (h
< _min_size
.y()) h
= _min_size
.y();
1094 else if (h
> _max_size
.y()) h
= _max_size
.y();
1096 // adjust the height ot match the width for the aspect ratios
1098 if (h
* _min_ratio
> w
) h
= static_cast<int>(w
/ _min_ratio
);
1100 if (h
* _max_ratio
< w
) h
= static_cast<int>(w
/ _max_ratio
);
1103 // keep to the increments
1107 // you cannot resize to nothing
1111 // store the logical size
1112 _logical_size
.setPoint(w
, h
);
1117 w
+= _base_size
.x();
1118 h
+= _base_size
.y();
1120 if (x
== INT_MIN
|| y
== INT_MIN
) {
1127 x
-= w
- _area
.width();
1130 y
-= h
- _area
.height();
1133 x
-= w
- _area
.width();
1134 y
-= h
- _area
.height();
1139 _area
.setSize(w
, h
);
1141 XResizeWindow(**otk::display
, _window
, w
, h
);
1143 // resize the frame to match the request
1144 frame
->adjustSize();
1145 internal_move(x
, y
);
1149 void Client::move(int x
, int y
)
1151 if (!(_functions
& Func_Move
)) return;
1152 frame
->frameGravity(x
, y
); // get the client's position based on x,y for the
1154 internal_move(x
, y
);
1158 void Client::internal_move(int x
, int y
)
1162 // move the frame to be in the requested position
1163 if (frame
) { // this can be called while mapping, before frame exists
1164 frame
->adjustPosition();
1166 // send synthetic configure notify (we don't need to if we aren't mapped
1169 event
.type
= ConfigureNotify
;
1170 event
.xconfigure
.display
= **otk::display
;
1171 event
.xconfigure
.event
= _window
;
1172 event
.xconfigure
.window
= _window
;
1174 // root window coords with border in mind
1175 event
.xconfigure
.x
= x
- _border_width
+ frame
->size().left
;
1176 event
.xconfigure
.y
= y
- _border_width
+ frame
->size().top
;
1178 event
.xconfigure
.width
= _area
.width();
1179 event
.xconfigure
.height
= _area
.height();
1180 event
.xconfigure
.border_width
= _border_width
;
1181 event
.xconfigure
.above
= frame
->plate();
1182 event
.xconfigure
.override_redirect
= False
;
1183 XSendEvent(event
.xconfigure
.display
, event
.xconfigure
.window
, False
,
1184 StructureNotifyMask
, &event
);
1186 printf("Sent synthetic ConfigureNotify %d,%d %d,%d to 0x%lx\n",
1187 event
.xconfigure
.x
, event
.xconfigure
.y
, event
.xconfigure
.width
,
1188 event
.xconfigure
.height
, event
.xconfigure
.window
);
1194 void Client::close()
1198 if (!(_functions
& Func_Close
)) return;
1200 // XXX: itd be cool to do timeouts and shit here for killing the client's
1202 // like... if the window is around after 5 seconds, then the close button
1203 // turns a nice red, and if this function is called again, the client is
1204 // explicitly killed.
1206 ce
.xclient
.type
= ClientMessage
;
1207 ce
.xclient
.message_type
= otk::Property::atoms
.wm_protocols
;
1208 ce
.xclient
.display
= **otk::display
;
1209 ce
.xclient
.window
= _window
;
1210 ce
.xclient
.format
= 32;
1211 ce
.xclient
.data
.l
[0] = otk::Property::atoms
.wm_delete_window
;
1212 ce
.xclient
.data
.l
[1] = CurrentTime
;
1213 ce
.xclient
.data
.l
[2] = 0l;
1214 ce
.xclient
.data
.l
[3] = 0l;
1215 ce
.xclient
.data
.l
[4] = 0l;
1216 XSendEvent(**otk::display
, _window
, false, NoEventMask
, &ce
);
1220 void Client::changeState()
1222 unsigned long state
[2];
1223 state
[0] = _wmstate
;
1225 otk::Property::set(_window
, otk::Property::atoms
.wm_state
,
1226 otk::Property::atoms
.wm_state
, state
, 2);
1231 netstate
[num
++] = otk::Property::atoms
.net_wm_state_modal
;
1233 netstate
[num
++] = otk::Property::atoms
.net_wm_state_shaded
;
1235 netstate
[num
++] = otk::Property::atoms
.net_wm_state_hidden
;
1237 netstate
[num
++] = otk::Property::atoms
.net_wm_state_skip_taskbar
;
1239 netstate
[num
++] = otk::Property::atoms
.net_wm_state_skip_pager
;
1241 netstate
[num
++] = otk::Property::atoms
.net_wm_state_fullscreen
;
1243 netstate
[num
++] = otk::Property::atoms
.net_wm_state_maximized_vert
;
1245 netstate
[num
++] = otk::Property::atoms
.net_wm_state_maximized_horz
;
1247 netstate
[num
++] = otk::Property::atoms
.net_wm_state_above
;
1249 netstate
[num
++] = otk::Property::atoms
.net_wm_state_below
;
1250 otk::Property::set(_window
, otk::Property::atoms
.net_wm_state
,
1251 otk::Property::atoms
.atom
, netstate
, num
);
1256 frame
->adjustState();
1260 void Client::changeAllowedActions(void)
1265 actions
[num
++] = otk::Property::atoms
.net_wm_action_change_desktop
;
1267 if (_functions
& Func_Shade
)
1268 actions
[num
++] = otk::Property::atoms
.net_wm_action_shade
;
1269 if (_functions
& Func_Close
)
1270 actions
[num
++] = otk::Property::atoms
.net_wm_action_close
;
1271 if (_functions
& Func_Move
)
1272 actions
[num
++] = otk::Property::atoms
.net_wm_action_move
;
1273 if (_functions
& Func_Iconify
)
1274 actions
[num
++] = otk::Property::atoms
.net_wm_action_minimize
;
1275 if (_functions
& Func_Resize
)
1276 actions
[num
++] = otk::Property::atoms
.net_wm_action_resize
;
1277 if (_functions
& Func_Fullscreen
)
1278 actions
[num
++] = otk::Property::atoms
.net_wm_action_fullscreen
;
1279 if (_functions
& Func_Maximize
) {
1280 actions
[num
++] = otk::Property::atoms
.net_wm_action_maximize_horz
;
1281 actions
[num
++] = otk::Property::atoms
.net_wm_action_maximize_vert
;
1284 otk::Property::set(_window
, otk::Property::atoms
.net_wm_allowed_actions
,
1285 otk::Property::atoms
.atom
, actions
, num
);
1289 void Client::remaximize()
1292 if (_max_horz
&& _max_vert
)
1299 return; // not maximized
1300 _max_horz
= _max_vert
= false;
1301 maximize(true, dir
, false);
1305 void Client::applyStartupState()
1307 // these are in a carefully crafted order..
1311 setDesktop(ICONIC_DESKTOP
);
1314 _fullscreen
= false;
1315 fullscreen(true, false);
1324 if (_max_vert
&& _max_horz
) {
1325 _max_vert
= _max_horz
= false;
1326 maximize(true, 0, false);
1327 } else if (_max_vert
) {
1329 maximize(true, 2, false);
1330 } else if (_max_horz
) {
1332 maximize(true, 1, false);
1335 if (_skip_taskbar
); // nothing to do for this
1336 if (_skip_pager
); // nothing to do for this
1337 if (_modal
); // nothing to do for this
1338 if (_above
); // nothing to do for this
1339 if (_below
); // nothing to do for this
1343 void Client::fireUrgent()
1345 // call the python UrgentWindow callbacks
1346 EventData
data(_screen
, this, EventAction::UrgentWindow
, 0);
1347 openbox
->bindings()->fireEvent(&data
);
1351 void Client::shade(bool shade
)
1353 if (!(_functions
& Func_Shade
) || // can't
1354 _shaded
== shade
) return; // already done
1356 // when we're iconic, don't change the wmstate
1358 _wmstate
= shade
? IconicState
: NormalState
;
1361 frame
->adjustSize();
1365 void Client::maximize(bool max
, int dir
, bool savearea
)
1367 assert(dir
== 0 || dir
== 1 || dir
== 2);
1368 if (!(_functions
& Func_Maximize
)) return; // can't
1370 // check if already done
1372 if (dir
== 0 && _max_horz
&& _max_vert
) return;
1373 if (dir
== 1 && _max_horz
) return;
1374 if (dir
== 2 && _max_vert
) return;
1376 if (dir
== 0 && !_max_horz
&& !_max_vert
) return;
1377 if (dir
== 1 && !_max_horz
) return;
1378 if (dir
== 2 && !_max_vert
) return;
1381 const otk::Rect
&a
= openbox
->screen(_screen
)->area();
1382 int x
= frame
->rect().x(), y
= frame
->rect().y(),
1383 w
= _area
.width(), h
= _area
.height();
1389 unsigned long n
= 4;
1396 // get the property off the window and use it for the dimentions we are
1398 if (otk::Property::get(_window
, otk::Property::atoms
.openbox_premax
,
1399 otk::Property::atoms
.cardinal
, &n
,
1400 (long unsigned**) &readdim
)) {
1403 dimensions
[0] = readdim
[0];
1404 dimensions
[2] = readdim
[2];
1407 dimensions
[1] = readdim
[1];
1408 dimensions
[3] = readdim
[3];
1414 otk::Property::set(_window
, otk::Property::atoms
.openbox_premax
,
1415 otk::Property::atoms
.cardinal
,
1416 (long unsigned*)dimensions
, 4);
1418 if (dir
== 0 || dir
== 1) { // horz
1422 if (dir
== 0 || dir
== 2) { // vert
1424 h
= a
.height() - frame
->size().top
- frame
->size().bottom
;
1428 long unsigned n
= 4;
1430 if (otk::Property::get(_window
, otk::Property::atoms
.openbox_premax
,
1431 otk::Property::atoms
.cardinal
, &n
,
1432 (long unsigned**) &dimensions
)) {
1434 if (dir
== 0 || dir
== 1) { // horz
1435 x
= (signed int)dimensions
[0];
1436 w
= (signed int)dimensions
[2];
1438 if (dir
== 0 || dir
== 2) { // vert
1439 y
= (signed int)dimensions
[1];
1440 h
= (signed int)dimensions
[3];
1445 // pick some fallbacks...
1446 if (dir
== 0 || dir
== 1) { // horz
1447 x
= a
.x() + a
.width() / 4;
1450 if (dir
== 0 || dir
== 2) { // vert
1451 y
= a
.y() + a
.height() / 4;
1457 if (dir
== 0 || dir
== 1) // horz
1459 if (dir
== 0 || dir
== 2) // vert
1462 if (!_max_horz
&& !_max_vert
)
1463 otk::Property::erase(_window
, otk::Property::atoms
.openbox_premax
);
1465 changeState(); // change the state hints on the client
1467 frame
->frameGravity(x
, y
); // figure out where the client should be going
1468 internal_resize(TopLeft
, w
, h
, true, x
, y
);
1472 void Client::fullscreen(bool fs
, bool savearea
)
1474 static FunctionFlags saved_func
;
1475 static DecorationFlags saved_decor
;
1477 if (!(_functions
& Func_Fullscreen
) || // can't
1478 _fullscreen
== fs
) return; // already done
1481 changeState(); // change the state hints on the client
1483 int x
= _area
.x(), y
= _area
.y(), w
= _area
.width(), h
= _area
.height();
1486 // save the functions and remove them
1487 saved_func
= _functions
;
1488 _functions
= _functions
& (Func_Close
| Func_Fullscreen
| Func_Iconify
);
1489 // save the decorations and remove them
1490 saved_decor
= _decorations
;
1494 dimensions
[0] = _area
.x();
1495 dimensions
[1] = _area
.y();
1496 dimensions
[2] = _area
.width();
1497 dimensions
[3] = _area
.height();
1498 otk::Property::set(_window
, otk::Property::atoms
.openbox_premax
,
1499 otk::Property::atoms
.cardinal
,
1500 (long unsigned*)dimensions
, 4);
1502 const otk::ScreenInfo
*info
= otk::display
->screenInfo(_screen
);
1508 _functions
= saved_func
;
1509 _decorations
= saved_decor
;
1512 long unsigned n
= 4;
1514 if (otk::Property::get(_window
, otk::Property::atoms
.openbox_premax
,
1515 otk::Property::atoms
.cardinal
, &n
,
1516 (long unsigned**) &dimensions
)) {
1525 // pick some fallbacks...
1526 const otk::Rect
&a
= openbox
->screen(_screen
)->area();
1527 x
= a
.x() + a
.width() / 4;
1528 y
= a
.y() + a
.height() / 4;
1534 changeAllowedActions(); // based on the new _functions
1536 // when fullscreening, don't obey things like increments, fill the screen
1537 internal_resize(TopLeft
, w
, h
, !fs
, x
, y
);
1539 // raise (back) into our stacking layer
1540 openbox
->screen(_screen
)->raiseWindow(this);
1542 // try focus us when we go into fullscreen mode
1547 void Client::disableDecorations(DecorationFlags flags
)
1549 _disabled_decorations
= flags
;
1550 setupDecorAndFunctions();
1554 bool Client::focus()
1556 // won't try focus if the client doesn't want it, or if the window isn't
1557 // visible on the screen
1558 if (!(frame
->isVisible() && (_can_focus
|| _focus_notify
))) return false;
1560 if (_focused
) return true;
1562 // do a check to see if the window has already been unmapped or destroyed
1563 // do this intelligently while watching out for unmaps we've generated
1564 // (ignore_unmaps > 0)
1566 if (XCheckTypedWindowEvent(**otk::display
, _window
, DestroyNotify
, &ev
)) {
1567 XPutBackEvent(**otk::display
, &ev
);
1570 while (XCheckTypedWindowEvent(**otk::display
, _window
, UnmapNotify
, &ev
)) {
1571 if (ignore_unmaps
) {
1572 unmapHandler(ev
.xunmap
);
1574 XPutBackEvent(**otk::display
, &ev
);
1580 XSetInputFocus(**otk::display
, _window
,
1581 RevertToNone
, CurrentTime
);
1583 if (_focus_notify
) {
1585 ce
.xclient
.type
= ClientMessage
;
1586 ce
.xclient
.message_type
= otk::Property::atoms
.wm_protocols
;
1587 ce
.xclient
.display
= **otk::display
;
1588 ce
.xclient
.window
= _window
;
1589 ce
.xclient
.format
= 32;
1590 ce
.xclient
.data
.l
[0] = otk::Property::atoms
.wm_take_focus
;
1591 ce
.xclient
.data
.l
[1] = openbox
->lastTime();
1592 ce
.xclient
.data
.l
[2] = 0l;
1593 ce
.xclient
.data
.l
[3] = 0l;
1594 ce
.xclient
.data
.l
[4] = 0l;
1595 XSendEvent(**otk::display
, _window
, False
, NoEventMask
, &ce
);
1598 XSync(**otk::display
, False
);
1603 void Client::unfocus() const
1605 if (!_focused
) return;
1607 assert(openbox
->focusedClient() == this);
1608 openbox
->setFocusedClient(0);
1612 void Client::focusHandler(const XFocusChangeEvent
&e
)
1615 // printf("FocusIn for 0x%lx\n", e.window);
1618 otk::EventHandler::focusHandler(e
);
1623 openbox
->setFocusedClient(this);
1627 void Client::unfocusHandler(const XFocusChangeEvent
&e
)
1630 // printf("FocusOut for 0x%lx\n", e.window);
1633 otk::EventHandler::unfocusHandler(e
);
1638 if (openbox
->focusedClient() == this)
1639 openbox
->setFocusedClient(0);
1643 void Client::configureRequestHandler(const XConfigureRequestEvent
&e
)
1646 printf("ConfigureRequest for 0x%lx\n", e
.window
);
1649 otk::EventHandler::configureRequestHandler(e
);
1651 // if we are iconic (or shaded (fvwm does this)) ignore the event
1652 if (_iconic
|| _shaded
) return;
1654 if (e
.value_mask
& CWBorderWidth
)
1655 _border_width
= e
.border_width
;
1657 // resize, then move, as specified in the EWMH section 7.7
1658 if (e
.value_mask
& (CWWidth
| CWHeight
)) {
1659 int w
= (e
.value_mask
& CWWidth
) ? e
.width
: _area
.width();
1660 int h
= (e
.value_mask
& CWHeight
) ? e
.height
: _area
.height();
1664 case NorthEastGravity
:
1668 case SouthWestGravity
:
1670 corner
= BottomLeft
;
1672 case SouthEastGravity
:
1673 corner
= BottomRight
;
1675 default: // NorthWest, Static, etc
1679 // if moving AND resizing ...
1680 if (e
.value_mask
& (CWX
| CWY
)) {
1681 int x
= (e
.value_mask
& CWX
) ? e
.x
: _area
.x();
1682 int y
= (e
.value_mask
& CWY
) ? e
.y
: _area
.y();
1683 internal_resize(corner
, w
, h
, false, x
, y
);
1684 } else // if JUST resizing...
1685 internal_resize(corner
, w
, h
, false);
1686 } else if (e
.value_mask
& (CWX
| CWY
)) { // if JUST moving...
1687 int x
= (e
.value_mask
& CWX
) ? e
.x
: _area
.x();
1688 int y
= (e
.value_mask
& CWY
) ? e
.y
: _area
.y();
1689 internal_move(x
, y
);
1692 if (e
.value_mask
& CWStackMode
) {
1696 openbox
->screen(_screen
)->lowerWindow(this);
1702 openbox
->screen(_screen
)->raiseWindow(this);
1709 void Client::unmapHandler(const XUnmapEvent
&e
)
1711 if (ignore_unmaps
) {
1713 // printf("Ignored UnmapNotify for 0x%lx (event 0x%lx)\n", e.window, e.event);
1720 printf("UnmapNotify for 0x%lx\n", e
.window
);
1723 otk::EventHandler::unmapHandler(e
);
1725 // this deletes us etc
1726 openbox
->screen(_screen
)->unmanageWindow(this);
1730 void Client::destroyHandler(const XDestroyWindowEvent
&e
)
1733 printf("DestroyNotify for 0x%lx\n", e
.window
);
1736 otk::EventHandler::destroyHandler(e
);
1738 // this deletes us etc
1739 openbox
->screen(_screen
)->unmanageWindow(this);
1743 void Client::reparentHandler(const XReparentEvent
&e
)
1745 // this is when the client is first taken captive in the frame
1746 if (e
.parent
== frame
->plate()) return;
1749 printf("ReparentNotify for 0x%lx\n", e
.window
);
1752 otk::EventHandler::reparentHandler(e
);
1755 This event is quite rare and is usually handled in unmapHandler.
1756 However, if the window is unmapped when the reparent event occurs,
1757 the window manager never sees it because an unmap event is not sent
1758 to an already unmapped window.
1761 // we don't want the reparent event, put it back on the stack for the X
1762 // server to deal with after we unmanage the window
1765 XPutBackEvent(**otk::display
, &ev
);
1767 // this deletes us etc
1768 openbox
->screen(_screen
)->unmanageWindow(this);
1771 void Client::mapRequestHandler(const XMapRequestEvent
&e
)
1774 printf("MapRequest for already managed 0x%lx\n", e
.window
);
1777 assert(_iconic
); // we shouldn't be able to get this unless we're iconic
1779 // move to the current desktop (uniconify)
1780 setDesktop(openbox
->screen(_screen
)->desktop());
1781 // XXX: should we focus/raise the window? (basically a net_wm_active_window)