1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
9 #include "otk/display.hh"
13 OBFrame::OBFrame(const OBClient
*client
, const otk::Style
*style
)
15 _screen(otk::OBDisplay::screenInfo(client
->screen()))
23 _window
= createFrame();
36 void OBFrame::loadStyle(const otk::Style
*style
)
40 // if a style was previously set, then 'replace' is true, cause we're
42 // NOTE: if this is false, then DO NOT DO SHIT WITH _window, it doesnt exist
43 bool replace
= (_style
);
46 // XXX: do shit here whatever
51 // XXX: load shit like this from the style!
52 _size
.left
= _size
.top
= _size
.bottom
= _size
.right
= 2;
57 XSetWindowBorderWidth(otk::OBDisplay::display
, _window
,
58 _style
->getBorderWidth());
60 XMoveWindow(otk::OBDisplay::display
, _client
->window(),
61 _size
.left
, _size
.top
);
63 // XXX: make everything redraw
68 void OBFrame::resize()
70 XResizeWindow(otk::OBDisplay::display
, _window
,
71 _size
.left
+ _size
.right
+ _client
->area().width(),
72 _size
.top
+ _size
.bottom
+ _client
->area().height());
73 // XXX: more is gunna have to happen here
79 // XXX: if shaped, shape the frame to the client..
83 void OBFrame::grabClient()
86 XGrabServer(otk::OBDisplay::display
);
88 // select the event mask on the frame
89 XSelectInput(otk::OBDisplay::display
, _window
, SubstructureRedirectMask
);
91 // reparent the client to the frame
92 XSelectInput(otk::OBDisplay::display
, _client
->window(),
93 OBClient::event_mask
& ~StructureNotifyMask
);
94 XReparentWindow(otk::OBDisplay::display
, _client
->window(), _window
,
95 _size
.left
, _size
.top
);
96 XSelectInput(otk::OBDisplay::display
, _client
->window(),
97 OBClient::event_mask
);
99 // raise the client above the frame
100 XRaiseWindow(otk::OBDisplay::display
, _client
->window());
101 // map the client so it maps when the frame does
102 XMapWindow(otk::OBDisplay::display
, _client
->window());
104 XUngrabServer(otk::OBDisplay::display
);
111 void OBFrame::releaseClient(bool remap
)
113 // check if the app has already reparented its window to the root window
115 if (XCheckTypedWindowEvent(otk::OBDisplay::display
, _client
->window(),
116 ReparentNotify
, &ev
)) {
117 remap
= true; // XXX: why do we remap the window if they already
118 // reparented to root?
120 // according to the ICCCM - if the client doesn't reparent to
121 // root, then we have to do it for them
122 XReparentWindow(otk::OBDisplay::display
, _client
->window(),
123 _screen
->getRootWindow(),
124 _client
->area().x(), _client
->area().y());
127 // if we want to remap the window, do so now
129 XMapWindow(otk::OBDisplay::display
, _client
->window());
133 Window
OBFrame::createFrame()
135 XSetWindowAttributes attrib_create
;
136 unsigned long create_mask
= CWBackPixmap
| CWBorderPixel
| CWColormap
|
137 CWOverrideRedirect
| CWEventMask
;
139 attrib_create
.background_pixmap
= None
;
140 attrib_create
.colormap
= _screen
->getColormap();
141 attrib_create
.override_redirect
= True
;
142 attrib_create
.event_mask
= EnterWindowMask
| LeaveWindowMask
| ButtonPress
;
144 We catch button presses because other wise they get passed down to the
145 root window, which will then cause root menus to show when you click the
149 return XCreateWindow(otk::OBDisplay::display
, _screen
->getRootWindow(),
150 0, 0, 1, 1, _style
->getBorderWidth(),
151 _screen
->getDepth(), InputOutput
, _screen
->getVisual(),
152 create_mask
, &attrib_create
);