1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
7 #include <X11/extensions/shape.h>
13 #include "otk/display.hh"
14 #include "otk/surface.hh"
21 const long Frame::event_mask
;
23 Window
createWindow(const otk::ScreenInfo
*info
, Window parent
,
24 unsigned long mask
, XSetWindowAttributes
*attrib
)
26 return XCreateWindow(**otk::display
, parent
, 0, 0, 1, 1, 0,
27 info
->depth(), InputOutput
, info
->visual(),
32 Frame::Frame(Client
*client
)
58 _iconify_press(false),
65 XSetWindowAttributes attrib
;
67 const otk::ScreenInfo
*info
= otk::display
->screenInfo(client
->screen());
69 // create all of the decor windows (except title bar buttons)
70 mask
= CWOverrideRedirect
| CWEventMask
;
71 attrib
.event_mask
= Frame::event_mask
;
72 attrib
.override_redirect
= true;
73 _frame
= createWindow(info
, info
->rootWindow(), mask
, &attrib
);
76 _plate
= createWindow(info
, _frame
, mask
, &attrib
);
78 attrib
.event_mask
= (ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
|
80 _title
= createWindow(info
, _frame
, mask
, &attrib
);
81 _label
= createWindow(info
, _title
, mask
, &attrib
);
82 _max
= createWindow(info
, _title
, mask
, &attrib
);
83 _close
= createWindow(info
, _title
, mask
, &attrib
);
84 _desk
= createWindow(info
, _title
, mask
, &attrib
);
85 _icon
= createWindow(info
, _title
, mask
, &attrib
);
86 _iconify
= createWindow(info
, _title
, mask
, &attrib
);
87 _handle
= createWindow(info
, _frame
, mask
, &attrib
);
89 attrib
.cursor
= openbox
->cursors().ll_angle
;
90 _lgrip
= createWindow(info
, _handle
, mask
, &attrib
);
91 attrib
.cursor
= openbox
->cursors().lr_angle
;
92 _rgrip
= createWindow(info
, _handle
, mask
, &attrib
);
94 // the other stuff is shown based on decor settings
95 XMapWindow(**otk::display
, _plate
);
96 XMapWindow(**otk::display
, _lgrip
);
97 XMapWindow(**otk::display
, _rgrip
);
98 XMapWindow(**otk::display
, _label
);
100 applyStyle(*otk::RenderStyle::style(_client
->screen()));
102 _layout
= openbox
->screen(_client
->screen())->config().titlebar_layout
;
104 // register all of the windows with the event dispatcher
105 Window
*w
= allWindows();
106 for (unsigned int i
= 0; w
[i
]; ++i
)
107 openbox
->registerHandler(w
[i
], this);
113 // unregister all of the windows with the event dispatcher
114 Window
*w
= allWindows();
115 for (unsigned int i
= 0; w
[i
]; ++i
)
116 openbox
->clearHandler(w
[i
]);
119 XDestroyWindow(**otk::display
, _rgrip
);
120 XDestroyWindow(**otk::display
, _lgrip
);
121 XDestroyWindow(**otk::display
, _handle
);
122 XDestroyWindow(**otk::display
, _max
);
123 XDestroyWindow(**otk::display
, _icon
);
124 XDestroyWindow(**otk::display
, _iconify
);
125 XDestroyWindow(**otk::display
, _desk
);
126 XDestroyWindow(**otk::display
, _close
);
127 XDestroyWindow(**otk::display
, _label
);
128 XDestroyWindow(**otk::display
, _title
);
129 XDestroyWindow(**otk::display
, _frame
);
131 if (_frame_sur
) delete _frame_sur
;
132 if (_title_sur
) delete _title_sur
;
133 if (_label_sur
) delete _label_sur
;
134 if (_handle_sur
) delete _handle_sur
;
135 if (_grip_sur
) delete _grip_sur
;
136 if (_max_sur
) delete _max_sur
;
137 if (_desk_sur
) delete _desk_sur
;
138 if (_iconify_sur
) delete _iconify_sur
;
139 if (_icon_sur
) delete _icon_sur
;
140 if (_close_sur
) delete _close_sur
;
147 XMapWindow(**otk::display
, _frame
);
155 XUnmapWindow(**otk::display
, _frame
);
159 void Frame::buttonPressHandler(const XButtonEvent
&e
)
161 if (_press_button
) return;
162 _press_button
= e
.button
;
164 if (e
.window
== _max
) {
168 if (e
.window
== _close
) {
172 if (e
.window
== _desk
) {
176 if (e
.window
== _iconify
) {
177 _iconify_press
= true;
180 if (e
.window
== _icon
) {
186 void Frame::buttonReleaseHandler(const XButtonEvent
&e
)
188 if (e
.button
!= _press_button
) return;
191 if (e
.window
== _max
) {
195 if (e
.window
== _close
) {
196 _close_press
= false;
199 if (e
.window
== _desk
) {
203 if (e
.window
== _iconify
) {
204 _iconify_press
= false;
207 if (e
.window
== _icon
) {
213 MouseContext::MC
Frame::mouseContext(Window win
) const
215 if (win
== _frame
) return MouseContext::Frame
;
217 win
== _label
) return MouseContext::Titlebar
;
218 if (win
== _handle
) return MouseContext::Handle
;
219 if (win
== _plate
) return MouseContext::Window
;
221 win
== _rgrip
) return MouseContext::Grip
;
222 if (win
== _max
) return MouseContext::MaximizeButton
;
223 if (win
== _close
) return MouseContext::CloseButton
;
224 if (win
== _desk
) return MouseContext::AllDesktopsButton
;
225 if (win
== _iconify
)return MouseContext::IconifyButton
;
226 if (win
== _icon
) return MouseContext::IconButton
;
227 return (MouseContext::MC
) -1;
230 Window
*Frame::allWindows() const
232 Window
*w
= new Window
[12 + 1];
250 void Frame::applyStyle(const otk::RenderStyle
&style
)
252 // set static border colors
253 XSetWindowBorder(**otk::display
, _frame
, style
.frameBorderColor()->pixel());
254 XSetWindowBorder(**otk::display
, _title
, style
.frameBorderColor()->pixel());
255 XSetWindowBorder(**otk::display
, _handle
, style
.frameBorderColor()->pixel());
256 XSetWindowBorder(**otk::display
, _lgrip
, style
.frameBorderColor()->pixel());
257 XSetWindowBorder(**otk::display
, _rgrip
, style
.frameBorderColor()->pixel());
259 // size all the fixed-size elements
260 geom
.font_height
= style
.labelFont()->height();
261 if (geom
.font_height
< 1) geom
.font_height
= 1;
262 geom
.button_size
= geom
.font_height
- 2;
263 if (geom
.button_size
< 1) geom
.button_size
= 1;
264 geom
.handle_height
= style
.handleWidth();
265 if (geom
.handle_height
< 1) geom
.handle_height
= 1;
266 geom
.bevel
= style
.bevelWidth();
268 XResizeWindow(**otk::display
, _lgrip
, geom
.grip_width(), geom
.handle_height
);
269 XResizeWindow(**otk::display
, _rgrip
, geom
.grip_width(), geom
.handle_height
);
271 XResizeWindow(**otk::display
, _max
, geom
.button_size
, geom
.button_size
);
272 XResizeWindow(**otk::display
, _close
, geom
.button_size
, geom
.button_size
);
273 XResizeWindow(**otk::display
, _desk
, geom
.button_size
, geom
.button_size
);
274 XResizeWindow(**otk::display
, _iconify
, geom
.button_size
, geom
.button_size
);
275 XResizeWindow(**otk::display
, _icon
, geom
.button_size
, geom
.button_size
);
278 void Frame::styleChanged(const otk::RenderStyle
&style
)
282 // size/position everything
287 void Frame::adjustFocus()
289 // XXX optimizations later...
293 void Frame::adjustTitle()
295 // XXX optimizations later...
299 static void render(int screen
, const otk::Size
&size
, Window win
,
300 otk::Surface
**surface
,
301 const otk::RenderTexture
&texture
, bool freedata
=true)
303 otk::Surface
*s
= new otk::Surface(screen
, size
);
304 otk::display
->renderControl(screen
)->drawBackground(*s
, texture
);
305 XSetWindowBackgroundPixmap(**otk::display
, win
, s
->pixmap());
306 XClearWindow(**otk::display
, win
);
307 if (*surface
) delete *surface
;
308 if (freedata
) s
->freePixelData();
312 void Frame::adjustSize()
314 _decorations
= _client
->decorations();
315 const otk::RenderStyle
*style
= otk::RenderStyle::style(_client
->screen());
317 if (_decorations
& Client::Decor_Border
) {
318 geom
.bwidth
= style
->frameBorderWidth();
319 geom
.cbwidth
= style
->clientBorderWidth();
321 geom
.bwidth
= geom
.cbwidth
= 0;
323 _innersize
.left
= _innersize
.top
= _innersize
.bottom
= _innersize
.right
=
325 geom
.width
= _client
->area().width() + geom
.cbwidth
* 2;
326 assert(geom
.width
> 0);
329 XSetWindowBorderWidth(**otk::display
, _plate
, geom
.cbwidth
);
330 XSetWindowBorderWidth(**otk::display
, _frame
, geom
.bwidth
);
331 XSetWindowBorderWidth(**otk::display
, _title
, geom
.bwidth
);
332 XSetWindowBorderWidth(**otk::display
, _handle
, geom
.bwidth
);
333 XSetWindowBorderWidth(**otk::display
, _lgrip
, geom
.bwidth
);
334 XSetWindowBorderWidth(**otk::display
, _rgrip
, geom
.bwidth
);
336 // position/size and map/unmap all the windows
338 if (_decorations
& Client::Decor_Titlebar
) {
339 XMoveResizeWindow(**otk::display
, _title
, -geom
.bwidth
, -geom
.bwidth
,
340 geom
.width
, geom
.title_height());
341 _innersize
.top
+= geom
.title_height() + geom
.bwidth
;
342 XMapWindow(**otk::display
, _title
);
344 // layout the title bar elements
347 XUnmapWindow(**otk::display
, _title
);
348 // make all the titlebar stuff not render
349 _decorations
&= ~(Client::Decor_Icon
| Client::Decor_Iconify
|
350 Client::Decor_Maximize
| Client::Decor_Close
|
351 Client::Decor_AllDesktops
);
354 if (_decorations
& Client::Decor_Handle
) {
355 geom
.handle_y
= _innersize
.top
+ _client
->area().height() + geom
.cbwidth
;
356 XMoveResizeWindow(**otk::display
, _handle
, -geom
.bwidth
, geom
.handle_y
,
357 geom
.width
, geom
.handle_height
);
358 XMoveWindow(**otk::display
, _lgrip
, -geom
.bwidth
, -geom
.bwidth
);
359 XMoveWindow(**otk::display
, _rgrip
,
360 -geom
.bwidth
+ geom
.width
- geom
.grip_width(),
362 _innersize
.bottom
+= geom
.handle_height
+ geom
.bwidth
;
363 XMapWindow(**otk::display
, _handle
);
365 XUnmapWindow(**otk::display
, _handle
);
367 XResizeWindow(**otk::display
, _frame
, geom
.width
,
368 (_client
->shaded() ? geom
.title_height() :
369 _innersize
.top
+ _innersize
.bottom
+
370 _client
->area().height()));
372 // do this in two steps because clients whose gravity is set to
373 // 'Static' don't end up getting moved at all with an XMoveResizeWindow
374 XMoveWindow(**otk::display
, _plate
, _innersize
.left
- geom
.cbwidth
,
375 _innersize
.top
- geom
.cbwidth
);
376 XResizeWindow(**otk::display
, _plate
, _client
->area().width(),
377 _client
->area().height());
379 _size
.left
= _innersize
.left
+ geom
.bwidth
;
380 _size
.right
= _innersize
.right
+ geom
.bwidth
;
381 _size
.top
= _innersize
.top
+ geom
.bwidth
;
382 _size
.bottom
= _innersize
.bottom
+ geom
.bwidth
;
384 _area
= otk::Rect(_area
.position(), otk::Size(_client
->area().width() +
385 _size
.left
+ _size
.right
,
386 _client
->area().height() +
387 _size
.top
+ _size
.bottom
));
389 // render all the elements
390 int screen
= _client
->screen();
391 bool focus
= _client
->focused();
392 if (_decorations
& Client::Decor_Titlebar
) {
393 render(screen
, otk::Size(geom
.width
, geom
.title_height()), _title
,
394 &_title_sur
, *(focus
? style
->titlebarFocusBackground() :
395 style
->titlebarUnfocusBackground()), false);
405 if (_decorations
& Client::Decor_Handle
) {
406 render(screen
, otk::Size(geom
.width
, geom
.handle_height
), _handle
,
407 &_handle_sur
, *(focus
? style
->handleFocusBackground() :
408 style
->handleUnfocusBackground()));
409 render(screen
, otk::Size(geom
.grip_width(), geom
.handle_height
), _lgrip
,
410 &_grip_sur
, *(focus
? style
->gripFocusBackground() :
411 style
->gripUnfocusBackground()));
412 XSetWindowBackgroundPixmap(**otk::display
, _rgrip
, _grip_sur
->pixmap());
413 XClearWindow(**otk::display
, _rgrip
);
416 XSetWindowBorder(**otk::display
, _plate
,
417 focus
? style
->clientBorderFocusColor()->pixel() :
418 style
->clientBorderUnfocusColor()->pixel());
423 void Frame::renderLabel()
425 const otk::RenderStyle
*style
= otk::RenderStyle::style(_client
->screen());
426 const otk::RenderControl
*control
=
427 otk::display
->renderControl(_client
->screen());
428 const otk::Font
*font
= style
->labelFont();
430 otk::Surface
*s
= new otk::Surface(_client
->screen(),
431 otk::Size(geom
.label_width
,
432 geom
.label_height()));
433 control
->drawBackground(*s
, *(_client
->focused() ?
434 style
->labelFocusBackground() :
435 style
->labelUnfocusBackground()));
437 otk::ustring t
= _client
->title(); // the actual text to draw
438 int x
= geom
.bevel
; // x coord for the text
440 if (x
* 2 < geom
.label_width
) {
441 // find a string that will fit inside the area for text
442 otk::ustring::size_type text_len
= t
.size();
444 int maxsize
= geom
.label_width
- geom
.bevel
* 2;
448 length
= font
->measureString(t
);// this returns an unsigned, so check < 0
449 if (length
< 0) length
= maxsize
;// if the string's that long just adjust
450 } while (length
> maxsize
&& text_len
-- > 0);
453 switch (style
->labelTextJustify()) {
454 case otk::RenderStyle::RightBottomJustify
:
455 x
+= maxsize
- length
;
457 case otk::RenderStyle::CenterJustify
:
458 x
+= (maxsize
- length
) / 2;
460 case otk::RenderStyle::LeftTopJustify
:
465 control
->drawString(*s
, *font
, x
, 0,
466 *(_client
->focused() ? style
->textFocusColor() :
467 style
->textUnfocusColor()), t
);
470 XSetWindowBackgroundPixmap(**otk::display
, _label
, s
->pixmap());
471 XClearWindow(**otk::display
, _label
);
472 if (_label_sur
) delete _label_sur
;
477 static void renderButton(int screen
, bool focus
, bool press
, Window win
,
478 otk::Surface
**sur
, int butsize
,
479 const otk::PixmapMask
*mask
)
481 const otk::RenderStyle
*style
= otk::RenderStyle::style(screen
);
482 const otk::RenderControl
*control
= otk::display
->renderControl(screen
);
483 otk::Surface
*s
= new otk::Surface(screen
, otk::Size(butsize
, butsize
));
485 const otk::RenderTexture
*tx
= (focus
?
487 style
->buttonPressFocusBackground() :
488 style
->buttonUnpressFocusBackground()) :
490 style
->buttonPressUnfocusBackground() :
491 style
->buttonUnpressUnfocusBackground()));
492 const otk::RenderColor
*maskcolor
= (focus
?
493 style
->buttonFocusColor() :
494 style
->buttonUnfocusColor());
495 control
->drawBackground(*s
, *tx
);
496 control
->drawMask(*s
, *maskcolor
, *mask
);
498 XSetWindowBackgroundPixmap(**otk::display
, win
, s
->pixmap());
499 XClearWindow(**otk::display
, win
);
500 if (*sur
) delete *sur
;
505 void Frame::renderMax()
507 if (!(_decorations
& Client::Decor_Maximize
)) return;
508 bool press
= _max_press
|| _client
->maxVert() || _client
->maxHorz();
509 renderButton(_client
->screen(), _client
->focused(), press
, _max
,
510 &_max_sur
, geom
.button_size
,
511 otk::RenderStyle::style(_client
->screen())->maximizeMask());
514 void Frame::renderDesk()
516 if (!(_decorations
& Client::Decor_AllDesktops
)) return;
517 bool press
= _desk_press
|| _client
->desktop() == 0xffffffff;
518 renderButton(_client
->screen(), _client
->focused(), press
, _desk
,
519 &_desk_sur
, geom
.button_size
,
520 otk::RenderStyle::style(_client
->screen())->alldesktopsMask());
523 void Frame::renderIconify()
525 if (!(_decorations
& Client::Decor_Iconify
)) return;
526 renderButton(_client
->screen(), _client
->focused(), _iconify_press
, _iconify
,
527 &_iconify_sur
, geom
.button_size
,
528 otk::RenderStyle::style(_client
->screen())->iconifyMask());
531 void Frame::renderClose()
533 if (!(_decorations
& Client::Decor_Close
)) return;
534 renderButton(_client
->screen(), _client
->focused(), _close_press
, _close
,
535 &_close_sur
, geom
.button_size
,
536 otk::RenderStyle::style(_client
->screen())->closeMask());
539 void Frame::renderIcon()
541 if (!(_decorations
& Client::Decor_Icon
)) return;
542 const int screen
= _client
->screen();
543 const otk::RenderControl
*control
= otk::display
->renderControl(screen
);
545 otk::Surface
*s
= new otk::Surface(screen
, otk::Size(geom
.button_size
,
547 otk::pixel32
*dest
= s
->pixelData(), *src
;
548 int w
= _title_sur
->size().width();
550 src
= _title_sur
->pixelData() + w
* (geom
.bevel
+ 1) + geom
.icon_x
;
552 // get the background under the icon button
553 for (int y
= 0; y
< geom
.button_size
; ++y
, src
+= w
- geom
.button_size
)
554 for (int x
= 0; x
< geom
.button_size
; ++x
, ++dest
, ++src
)
556 // draw the icon over it
557 const Icon
*icon
= _client
->icon(otk::Size(geom
.button_size
,
559 control
->drawImage(*s
, icon
->w
, icon
->h
, icon
->data
);
561 Pixmap p
= _client
->pixmapIcon(), m
= _client
->pixmapIconMask();
563 control
->drawImage(*s
, p
, m
);
566 XSetWindowBackgroundPixmap(**otk::display
, _icon
, s
->pixmap());
567 XClearWindow(**otk::display
, _icon
);
568 if (_icon_sur
) delete _icon_sur
;
572 void Frame::layoutTitle()
574 // figure out whats being shown, and the width of the label
575 geom
.label_width
= geom
.width
- geom
.bevel
* 2;
576 bool n
, d
, i
, t
, m
,c
;
577 n
= d
= i
= t
= m
= c
= false;
578 for (const char *l
= _layout
.c_str(); *l
; ++l
) {
582 if (!(_decorations
& Client::Decor_Icon
)) break;
584 geom
.label_width
-= geom
.button_size
+ geom
.bevel
;
588 if (!(_decorations
& Client::Decor_AllDesktops
)) break;
590 geom
.label_width
-= geom
.button_size
+ geom
.bevel
;
594 if (!(_decorations
& Client::Decor_Iconify
)) break;
596 geom
.label_width
-= geom
.button_size
+ geom
.bevel
;
604 if (!(_decorations
& Client::Decor_Maximize
)) break;
606 geom
.label_width
-= geom
.button_size
+ geom
.bevel
;
610 if (!(_decorations
& Client::Decor_Close
)) break;
612 geom
.label_width
-= geom
.button_size
+ geom
.bevel
;
616 if (geom
.label_width
< 1) geom
.label_width
= 1;
618 XResizeWindow(**otk::display
, _label
, geom
.label_width
, geom
.font_height
);
621 _decorations
&= ~Client::Decor_Icon
;
622 XUnmapWindow(**otk::display
, _icon
);
625 _decorations
&= ~Client::Decor_AllDesktops
;
626 XUnmapWindow(**otk::display
, _desk
);
629 _decorations
&= ~Client::Decor_Iconify
;
630 XUnmapWindow(**otk::display
, _iconify
);
633 XUnmapWindow(**otk::display
, _label
);
635 _decorations
&= ~Client::Decor_Maximize
;
636 XUnmapWindow(**otk::display
, _max
);
639 _decorations
&= ~Client::Decor_Close
;
640 XUnmapWindow(**otk::display
, _close
);
644 for (const char *lc
= _layout
.c_str(); *lc
; ++lc
) {
650 XMapWindow(**otk::display
, _icon
);
651 XMoveWindow(**otk::display
, _icon
, x
, geom
.bevel
+ 1);
652 x
+= geom
.button_size
+ geom
.bevel
;
657 XMapWindow(**otk::display
, _desk
);
658 XMoveWindow(**otk::display
, _desk
, x
, geom
.bevel
+ 1);
659 x
+= geom
.button_size
+ geom
.bevel
;
664 XMapWindow(**otk::display
, _iconify
);
665 XMoveWindow(**otk::display
, _iconify
, x
, geom
.bevel
+ 1);
666 x
+= geom
.button_size
+ geom
.bevel
;
671 XMapWindow(**otk::display
, _label
);
672 XMoveWindow(**otk::display
, _label
, x
, geom
.bevel
);
673 x
+= geom
.label_width
+ geom
.bevel
;
678 XMapWindow(**otk::display
, _max
);
679 XMoveWindow(**otk::display
, _max
, x
, geom
.bevel
+ 1);
680 x
+= geom
.button_size
+ geom
.bevel
;
685 XMapWindow(**otk::display
, _close
);
686 XMoveWindow(**otk::display
, _close
, x
, geom
.bevel
+ 1);
687 x
+= geom
.button_size
+ geom
.bevel
;
693 void Frame::adjustPosition()
696 x
= _client
->area().x();
697 y
= _client
->area().y();
699 XMoveWindow(**otk::display
, _frame
, x
, y
);
700 _area
= otk::Rect(otk::Point(x
, y
), _area
.size());
704 void Frame::adjustShape()
707 if (!_client
->shaped()) {
708 // clear the shape on the frame window
709 XShapeCombineMask(**otk::display
, _frame
, ShapeBounding
,
714 // make the frame's shape match the clients
715 XShapeCombineShape(**otk::display
, _frame
, ShapeBounding
,
718 _client
->window(), ShapeBounding
, ShapeSet
);
723 if (_decorations
& Client::Decor_Titlebar
) {
724 xrect
[0].x
= -geom
.bevel
;
725 xrect
[0].y
= -geom
.bevel
;
726 xrect
[0].width
= geom
.width
+ geom
.bwidth
* 2;
727 xrect
[0].height
= geom
.title_height() + geom
.bwidth
* 2;
731 if (_decorations
& Client::Decor_Handle
) {
732 xrect
[1].x
= -geom
.bevel
;
733 xrect
[1].y
= geom
.handle_y
;
734 xrect
[1].width
= geom
.width
+ geom
.bwidth
* 2;
735 xrect
[1].height
= geom
.handle_height
+ geom
.bwidth
* 2;
739 XShapeCombineRectangles(**otk::display
, _frame
,
740 ShapeBounding
, 0, 0, xrect
, num
,
741 ShapeUnion
, Unsorted
);
746 void Frame::adjustState()
752 void Frame::adjustIcon()
757 void Frame::grabClient()
759 // reparent the client to the frame
760 XReparentWindow(**otk::display
, _client
->window(), _plate
, 0, 0);
762 When reparenting the client window, it is usually not mapped yet, since
763 this occurs from a MapRequest. However, in the case where Openbox is
764 starting up, the window is already mapped, so we'll see unmap events for
765 it. There are 2 unmap events generated that we see, one with the 'event'
766 member set the root window, and one set to the client, but both get handled
767 and need to be ignored.
769 if (openbox
->state() == Openbox::State_Starting
)
770 _client
->ignore_unmaps
+= 2;
772 // select the event mask on the client's parent (to receive config/map req's)
773 XSelectInput(**otk::display
, _plate
, SubstructureRedirectMask
);
775 // map the client so it maps when the frame does
776 XMapWindow(**otk::display
, _client
->window());
783 void Frame::releaseClient()
787 // check if the app has already reparented its window away
788 if (XCheckTypedWindowEvent(**otk::display
, _client
->window(),
789 ReparentNotify
, &ev
)) {
790 XPutBackEvent(**otk::display
, &ev
);
791 // re-map the window since the unmanaging process unmaps it
792 XMapWindow(**otk::display
, _client
->window());
794 // according to the ICCCM - if the client doesn't reparent itself, then we
795 // will reparent the window to root for them
796 XReparentWindow(**otk::display
, _client
->window(),
797 otk::display
->screenInfo(_client
->screen())->rootWindow(),
798 _client
->area().x(), _client
->area().y());
803 void Frame::clientGravity(int &x
, int &y
)
806 switch (_client
->gravity()) {
808 case NorthWestGravity
:
809 case SouthWestGravity
:
816 x
-= (_size
.left
+ _size
.right
) / 2;
819 case NorthEastGravity
:
820 case SouthEastGravity
:
822 x
-= _size
.left
+ _size
.right
;
832 switch (_client
->gravity()) {
834 case NorthWestGravity
:
835 case NorthEastGravity
:
842 y
-= (_size
.top
+ _size
.bottom
) / 2;
845 case SouthWestGravity
:
846 case SouthEastGravity
:
848 y
-= _size
.top
+ _size
.bottom
;
859 void Frame::frameGravity(int &x
, int &y
)
862 switch (_client
->gravity()) {
864 case NorthWestGravity
:
866 case SouthWestGravity
:
871 x
+= (_size
.left
+ _size
.right
) / 2;
873 case NorthEastGravity
:
875 case SouthEastGravity
:
876 x
+= _size
.left
+ _size
.right
;
885 switch (_client
->gravity()) {
887 case NorthWestGravity
:
889 case SouthWestGravity
:
894 y
+= (_size
.top
+ _size
.bottom
) / 2;
896 case NorthEastGravity
:
898 case SouthEastGravity
:
899 y
+= _size
.top
+ _size
.bottom
;