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;
55 XSetWindowBorderWidth(otk::OBDisplay::display
, _window
,
56 _style
->getBorderWidth());
58 // XXX: make everything redraw
63 void OBFrame::resize()
65 XResizeWindow(otk::OBDisplay::display
, _window
,
66 _size
.left
+ _size
.right
+ _client
->area().width(),
67 _size
.top
+ _size
.bottom
+ _client
->area().height());
68 // XXX: more is gunna have to happen here
74 // XXX: if shaped, shape the frame to the client..
78 void OBFrame::grabClient()
81 XGrabServer(otk::OBDisplay::display
);
83 // select the event mask on the frame
84 XSelectInput(otk::OBDisplay::display
, _window
, SubstructureRedirectMask
);
86 // reparent the client to the frame
87 XSelectInput(otk::OBDisplay::display
, _client
->window(),
88 OBClient::event_mask
& ~StructureNotifyMask
);
89 XReparentWindow(otk::OBDisplay::display
, _client
->window(), _window
, 0, 0);
90 XSelectInput(otk::OBDisplay::display
, _client
->window(),
91 OBClient::event_mask
);
93 // raise the client above the frame
94 XRaiseWindow(otk::OBDisplay::display
, _client
->window());
95 // map the client so it maps when the frame does
96 XMapWindow(otk::OBDisplay::display
, _client
->window());
98 XUngrabServer(otk::OBDisplay::display
);
105 void OBFrame::releaseClient(bool remap
)
107 // check if the app has already reparented its window to the root window
109 if (XCheckTypedWindowEvent(otk::OBDisplay::display
, _client
->window(),
110 ReparentNotify
, &ev
)) {
111 remap
= true; // XXX: why do we remap the window if they already
112 // reparented to root?
114 // according to the ICCCM - if the client doesn't reparent to
115 // root, then we have to do it for them
116 XReparentWindow(otk::OBDisplay::display
, _client
->window(),
117 _screen
->getRootWindow(),
118 _client
->area().x(), _client
->area().y());
121 // if we want to remap the window, do so now
123 XMapWindow(otk::OBDisplay::display
, _client
->window());
127 Window
OBFrame::createFrame()
129 XSetWindowAttributes attrib_create
;
130 unsigned long create_mask
= CWBackPixmap
| CWBorderPixel
| CWColormap
|
131 CWOverrideRedirect
| CWEventMask
;
133 attrib_create
.background_pixmap
= None
;
134 attrib_create
.colormap
= _screen
->getColormap();
135 attrib_create
.override_redirect
= True
;
136 attrib_create
.event_mask
= EnterWindowMask
| LeaveWindowMask
| ButtonPress
;
138 We catch button presses because other wise they get passed down to the
139 root window, which will then cause root menus to show when you click the
143 return XCreateWindow(otk::OBDisplay::display
, _screen
->getRootWindow(),
144 0, 0, 1, 1, _style
->getBorderWidth(),
145 _screen
->getDepth(), InputOutput
, _screen
->getVisual(),
146 create_mask
, &attrib_create
);