]>
Commit | Line | Data |
---|---|---|
1b0fb34b JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: x11/toplevel.cpp | |
3 | // Purpose: implements wxTopLevelWindow for X11 | |
83df96d6 JS |
4 | // Author: Julian Smart |
5 | // Modified by: | |
1b0fb34b | 6 | // Created: 24.09.01 |
83df96d6 | 7 | // RCS-ID: $Id$ |
1b0fb34b JS |
8 | // Copyright: (c) 2002 Julian Smart |
9 | // License: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
83df96d6 JS |
11 | |
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #ifdef __GNUG__ | |
1b0fb34b | 21 | #pragma implementation "toplevel.h" |
83df96d6 JS |
22 | #endif |
23 | ||
1b0fb34b JS |
24 | // For compilers that support precompilation, includes "wx.h". |
25 | #include "wx/wxprec.h" | |
83df96d6 | 26 | |
1b0fb34b JS |
27 | #ifdef __BORLANDC__ |
28 | #pragma hdrstop | |
83df96d6 JS |
29 | #endif |
30 | ||
1b0fb34b JS |
31 | #ifndef WX_PRECOMP |
32 | #include "wx/app.h" | |
33 | #include "wx/toplevel.h" | |
34 | #include "wx/string.h" | |
35 | #include "wx/log.h" | |
36 | #include "wx/intl.h" | |
37 | #include "wx/frame.h" | |
e5053ade JS |
38 | #include "wx/menu.h" |
39 | #include "wx/statusbr.h" | |
1b0fb34b | 40 | #endif //WX_PRECOMP |
83df96d6 | 41 | |
2034b748 | 42 | #include "wx/settings.h" |
1b0fb34b | 43 | #include "wx/x11/private.h" |
2034b748 | 44 | #include "X11/Xutil.h" |
b513212d | 45 | |
1b0b798d | 46 | bool wxMWMIsRunning(Window w); |
b513212d | 47 | |
83df96d6 | 48 | // ---------------------------------------------------------------------------- |
1b0fb34b | 49 | // wxTopLevelWindowX11 creation |
83df96d6 JS |
50 | // ---------------------------------------------------------------------------- |
51 | ||
1b0fb34b JS |
52 | void wxTopLevelWindowX11::Init() |
53 | { | |
54 | m_iconized = | |
55 | m_maximizeOnShow = FALSE; | |
83df96d6 | 56 | |
1b0fb34b JS |
57 | // unlike (almost?) all other windows, frames are created hidden |
58 | m_isShown = FALSE; | |
83df96d6 | 59 | |
1b0fb34b JS |
60 | // Data to save/restore when calling ShowFullScreen |
61 | m_fsStyle = 0; | |
62 | m_fsIsMaximized = FALSE; | |
63 | m_fsIsShowing = FALSE; | |
64 | } | |
83df96d6 | 65 | |
1b0fb34b JS |
66 | bool wxTopLevelWindowX11::Create(wxWindow *parent, |
67 | wxWindowID id, | |
68 | const wxString& title, | |
69 | const wxPoint& pos, | |
70 | const wxSize& size, | |
71 | long style, | |
72 | const wxString& name) | |
73 | { | |
74 | // init our fields | |
75 | Init(); | |
83df96d6 JS |
76 | |
77 | m_windowStyle = style; | |
b28d3abf | 78 | m_parent = parent; |
83df96d6 | 79 | |
1b0fb34b | 80 | SetName(name); |
83df96d6 | 81 | |
1b0fb34b | 82 | m_windowId = id == -1 ? NewControlId() : id; |
83df96d6 | 83 | |
b28d3abf JS |
84 | if (parent) |
85 | parent->AddChild(this); | |
86 | ||
1b0fb34b | 87 | wxTopLevelWindows.Append(this); |
952ebeba RR |
88 | |
89 | Display *xdisplay = wxGlobalDisplay(); | |
90 | int xscreen = DefaultScreen( xdisplay ); | |
91 | Visual *xvisual = DefaultVisual( xdisplay, xscreen ); | |
92 | Window xparent = RootWindow( xdisplay, xscreen ); | |
2034b748 | 93 | Colormap cm = DefaultColormap( xdisplay, xscreen ); |
952ebeba | 94 | |
7e085304 RR |
95 | if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) |
96 | m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); | |
97 | else | |
98 | m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); | |
2034b748 | 99 | m_backgroundColour.CalcPixel( (WXColormap) cm ); |
56cb684a JS |
100 | m_hasBgCol = TRUE; |
101 | ||
952ebeba RR |
102 | XSetWindowAttributes xattributes; |
103 | XSizeHints size_hints; | |
104 | XWMHints wm_hints; | |
105 | ||
106 | long xattributes_mask = | |
ea596687 | 107 | CWOverrideRedirect | |
952ebeba | 108 | CWBorderPixel | CWBackPixel; |
2034b748 | 109 | xattributes.background_pixel = m_backgroundColour.GetPixel(); |
952ebeba | 110 | xattributes.border_pixel = BlackPixel( xdisplay, xscreen ); |
5e29f97a JS |
111 | |
112 | // TODO: if we want no border, caption etc., | |
113 | // I think we set this to True to remove decorations | |
952ebeba RR |
114 | xattributes.override_redirect = False; |
115 | ||
edaf57a4 JS |
116 | wxSize size2(size); |
117 | if (size2.x == -1) | |
118 | size2.x = 100; | |
119 | if (size2.y == -1) | |
120 | size2.y = 100; | |
121 | ||
122 | wxPoint pos2(pos); | |
123 | if (pos2.x == -1) | |
124 | pos2.x = 100; | |
125 | if (pos2.y == -1) | |
126 | pos2.y = 100; | |
952ebeba | 127 | |
307be31a JS |
128 | Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, |
129 | 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); | |
130 | m_mainWidget = (WXWindow) xwindow; | |
131 | ||
132 | XSelectInput( xdisplay, xwindow, | |
256d631a JS |
133 | #if wxUSE_NANOX |
134 | GR_EVENT_MASK_CLOSE_REQ | | |
135 | #endif | |
307be31a JS |
136 | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
137 | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | | |
138 | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | | |
139 | PropertyChangeMask ); | |
140 | ||
141 | wxAddWindowToTable( xwindow, (wxWindow*) this ); | |
142 | ||
ba696cfa RR |
143 | // Set background to None which will prevent X11 from clearing the |
144 | // background completely. | |
145 | XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); | |
146 | ||
307be31a JS |
147 | // Messes up window management |
148 | // XSetTransientForHint( xdisplay, xwindow, xparent ); | |
149 | ||
952ebeba | 150 | size_hints.flags = PSize; |
edaf57a4 JS |
151 | size_hints.width = size2.x; |
152 | size_hints.height = size2.y; | |
952ebeba RR |
153 | XSetWMNormalHints( xdisplay, xwindow, &size_hints); |
154 | ||
155 | wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */; | |
156 | wm_hints.input = True; | |
157 | wm_hints.initial_state = NormalState; | |
158 | XSetWMHints( xdisplay, xwindow, &wm_hints); | |
159 | ||
160 | Atom wm_delete_window = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False); | |
161 | XSetWMProtocols( xdisplay, xwindow, &wm_delete_window, 1); | |
162 | ||
b28d3abf | 163 | wxSetWMDecorations((Window) GetMainWindow(), style); |
83df96d6 | 164 | |
b513212d | 165 | SetTitle(title); |
952ebeba RR |
166 | |
167 | return TRUE; | |
83df96d6 JS |
168 | } |
169 | ||
1b0fb34b | 170 | wxTopLevelWindowX11::~wxTopLevelWindowX11() |
83df96d6 | 171 | { |
83df96d6 | 172 | wxTopLevelWindows.DeleteObject(this); |
83df96d6 | 173 | |
1b0fb34b JS |
174 | // If this is the last top-level window, exit. |
175 | if ( wxTheApp && (wxTopLevelWindows.Number() == 0) ) | |
83df96d6 JS |
176 | { |
177 | wxTheApp->SetTopWindow(NULL); | |
178 | ||
179 | if (wxTheApp->GetExitOnFrameDelete()) | |
180 | { | |
181 | // Signal to the app that we're going to close | |
182 | wxTheApp->ExitMainLoop(); | |
183 | } | |
184 | } | |
185 | } | |
186 | ||
1b0fb34b JS |
187 | // ---------------------------------------------------------------------------- |
188 | // wxTopLevelWindowX11 showing | |
189 | // ---------------------------------------------------------------------------- | |
83df96d6 | 190 | |
1b0fb34b | 191 | bool wxTopLevelWindowX11::Show(bool show) |
83df96d6 | 192 | { |
b513212d | 193 | return wxWindowX11::Show(show); |
83df96d6 JS |
194 | } |
195 | ||
1b0fb34b JS |
196 | // ---------------------------------------------------------------------------- |
197 | // wxTopLevelWindowX11 maximize/minimize | |
198 | // ---------------------------------------------------------------------------- | |
83df96d6 | 199 | |
1b0fb34b | 200 | void wxTopLevelWindowX11::Maximize(bool maximize) |
83df96d6 | 201 | { |
1b0fb34b | 202 | // TODO |
83df96d6 JS |
203 | } |
204 | ||
1b0fb34b | 205 | bool wxTopLevelWindowX11::IsMaximized() const |
83df96d6 | 206 | { |
1b0fb34b JS |
207 | // TODO |
208 | return TRUE; | |
83df96d6 JS |
209 | } |
210 | ||
1b0fb34b | 211 | void wxTopLevelWindowX11::Iconize(bool iconize) |
83df96d6 | 212 | { |
b513212d JS |
213 | if (!m_iconized && GetMainWindow()) |
214 | { | |
215 | if (XIconifyWindow(wxGlobalDisplay(), | |
216 | (Window) GetMainWindow(), DefaultScreen(wxGlobalDisplay())) != 0) | |
217 | m_iconized = TRUE; | |
218 | } | |
83df96d6 JS |
219 | } |
220 | ||
1b0fb34b | 221 | bool wxTopLevelWindowX11::IsIconized() const |
83df96d6 | 222 | { |
1b0fb34b | 223 | return m_iconized; |
83df96d6 JS |
224 | } |
225 | ||
1b0fb34b | 226 | void wxTopLevelWindowX11::Restore() |
83df96d6 | 227 | { |
b513212d JS |
228 | // This is the way to deiconify the window, according to the X FAQ |
229 | if (m_iconized && GetMainWindow()) | |
230 | { | |
231 | XMapWindow(wxGlobalDisplay(), (Window) GetMainWindow()); | |
232 | m_iconized = FALSE; | |
233 | } | |
83df96d6 JS |
234 | } |
235 | ||
1b0fb34b JS |
236 | // ---------------------------------------------------------------------------- |
237 | // wxTopLevelWindowX11 fullscreen | |
238 | // ---------------------------------------------------------------------------- | |
83df96d6 | 239 | |
1b0fb34b | 240 | bool wxTopLevelWindowX11::ShowFullScreen(bool show, long style) |
83df96d6 | 241 | { |
1b0fb34b | 242 | if (show) |
83df96d6 | 243 | { |
1b0fb34b JS |
244 | if (IsFullScreen()) |
245 | return FALSE; | |
83df96d6 | 246 | |
1b0fb34b JS |
247 | m_fsIsShowing = TRUE; |
248 | m_fsStyle = style; | |
83df96d6 | 249 | |
1b0fb34b | 250 | // TODO |
83df96d6 | 251 | |
1b0fb34b | 252 | return TRUE; |
83df96d6 | 253 | } |
1b0fb34b | 254 | else |
83df96d6 | 255 | { |
1b0fb34b JS |
256 | if (!IsFullScreen()) |
257 | return FALSE; | |
83df96d6 | 258 | |
1b0fb34b | 259 | m_fsIsShowing = FALSE; |
83df96d6 | 260 | |
1b0fb34b JS |
261 | // TODO |
262 | return TRUE; | |
83df96d6 JS |
263 | } |
264 | } | |
265 | ||
1b0fb34b JS |
266 | // ---------------------------------------------------------------------------- |
267 | // wxTopLevelWindowX11 misc | |
268 | // ---------------------------------------------------------------------------- | |
83df96d6 | 269 | |
1b0fb34b | 270 | void wxTopLevelWindowX11::SetIcon(const wxIcon& icon) |
83df96d6 | 271 | { |
1b0fb34b JS |
272 | // this sets m_icon |
273 | wxTopLevelWindowBase::SetIcon(icon); | |
83df96d6 | 274 | |
b513212d JS |
275 | if (icon.Ok() && GetMainWindow()) |
276 | { | |
277 | XWMHints *wmHints = XAllocWMHints(); | |
6a44bffd | 278 | wmHints->icon_pixmap = (Pixmap) icon.GetPixmap(); |
b513212d | 279 | |
6a44bffd | 280 | wmHints->flags = IconPixmapHint; |
b513212d JS |
281 | |
282 | if (icon.GetMask()) | |
283 | { | |
6a44bffd | 284 | wmHints->flags |= IconMaskHint; |
a11672a4 | 285 | wmHints->icon_mask = (Pixmap) icon.GetMask()->GetBitmap(); |
b513212d JS |
286 | } |
287 | ||
1b0b798d | 288 | XSetWMHints(wxGlobalDisplay(), (Window) GetMainWindow(), wmHints); |
b513212d JS |
289 | XFree(wmHints); |
290 | } | |
291 | } | |
292 | ||
293 | void wxTopLevelWindowX11::SetTitle(const wxString& title) | |
294 | { | |
295 | m_title = title; | |
296 | if (GetMainWindow()) | |
297 | { | |
298 | XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(), | |
299 | (const char*) title); | |
300 | XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(), | |
301 | (const char*) title); | |
b28d3abf JS |
302 | |
303 | // Use this if the platform doesn't supply the above functions. | |
b513212d JS |
304 | #if 0 |
305 | XTextProperty textProperty; | |
306 | textProperty.value = (unsigned char*) title; | |
307 | textProperty.encoding = XA_STRING; | |
308 | textProperty.format = 8; | |
309 | textProperty.nitems = 1; | |
310 | ||
311 | XSetTextProperty(wxGlobalDisplay(), (Window) GetMainWindow(), | |
312 | & textProperty, WM_NAME); | |
313 | #endif | |
314 | } | |
315 | } | |
316 | ||
317 | wxString wxTopLevelWindowX11::GetTitle() const | |
318 | { | |
319 | return m_title; | |
320 | } | |
321 | ||
322 | #ifndef MWM_DECOR_BORDER | |
323 | /* bit definitions for MwmHints.flags */ | |
324 | #define MWM_HINTS_FUNCTIONS (1L << 0) | |
325 | #define MWM_HINTS_DECORATIONS (1L << 1) | |
326 | #define MWM_HINTS_INPUT_MODE (1L << 2) | |
327 | #define MWM_HINTS_STATUS (1L << 3) | |
328 | ||
329 | #define MWM_DECOR_ALL (1L << 0) | |
330 | #define MWM_DECOR_BORDER (1L << 1) | |
331 | #define MWM_DECOR_RESIZEH (1L << 2) | |
332 | #define MWM_DECOR_TITLE (1L << 3) | |
333 | #define MWM_DECOR_MENU (1L << 4) | |
334 | #define MWM_DECOR_MINIMIZE (1L << 5) | |
335 | #define MWM_DECOR_MAXIMIZE (1L << 6) | |
336 | #endif | |
337 | ||
338 | struct MwmHints { | |
339 | long flags; | |
340 | long functions; | |
341 | long decorations; | |
342 | long input_mode; | |
343 | }; | |
344 | ||
345 | #define PROP_MOTIF_WM_HINTS_ELEMENTS 5 | |
346 | ||
347 | // Set the window manager decorations according to the | |
348 | // given wxWindows style | |
b28d3abf | 349 | bool wxSetWMDecorations(Window w, long style) |
b513212d | 350 | { |
6a44bffd | 351 | if (!wxMWMIsRunning(w)) |
b513212d JS |
352 | return FALSE; |
353 | ||
354 | Atom mwm_wm_hints = XInternAtom(wxGlobalDisplay(),"_MOTIF_WM_HINTS", False); | |
355 | MwmHints hints; | |
356 | hints.flags = 0; | |
357 | hints.decorations = 0; | |
358 | ||
359 | if (style & wxRESIZE_BORDER) | |
360 | { | |
edaf57a4 | 361 | wxLogDebug("MWM_DECOR_RESIZEH"); |
b513212d JS |
362 | hints.flags |= MWM_HINTS_DECORATIONS; |
363 | hints.decorations |= MWM_DECOR_RESIZEH; | |
364 | } | |
365 | ||
366 | if (style & wxSYSTEM_MENU) | |
367 | { | |
edaf57a4 | 368 | wxLogDebug("MWM_DECOR_MENU"); |
b513212d JS |
369 | hints.flags |= MWM_HINTS_DECORATIONS; |
370 | hints.decorations |= MWM_DECOR_MENU; | |
371 | } | |
372 | ||
373 | if ((style & wxCAPTION) || | |
374 | (style & wxTINY_CAPTION_HORIZ) || | |
375 | (style & wxTINY_CAPTION_VERT)) | |
376 | { | |
edaf57a4 | 377 | wxLogDebug("MWM_DECOR_TITLE"); |
b513212d JS |
378 | hints.flags |= MWM_HINTS_DECORATIONS; |
379 | hints.decorations |= MWM_DECOR_TITLE; | |
380 | } | |
381 | ||
307be31a | 382 | if ((style & wxTHICK_FRAME) || (style & wxSIMPLE_BORDER) || (style & wxCAPTION)) |
b513212d | 383 | { |
edaf57a4 | 384 | wxLogDebug("MWM_DECOR_BORDER"); |
b513212d JS |
385 | hints.flags |= MWM_HINTS_DECORATIONS; |
386 | hints.decorations |= MWM_DECOR_BORDER; | |
387 | } | |
388 | ||
389 | if (style & wxMINIMIZE_BOX) | |
390 | { | |
edaf57a4 | 391 | wxLogDebug("MWM_DECOR_MINIMIZE"); |
b513212d JS |
392 | hints.flags |= MWM_HINTS_DECORATIONS; |
393 | hints.decorations |= MWM_DECOR_MINIMIZE; | |
394 | } | |
395 | ||
396 | if (style & wxMAXIMIZE_BOX) | |
397 | { | |
edaf57a4 | 398 | wxLogDebug("MWM_DECOR_MAXIMIZE"); |
b513212d JS |
399 | hints.flags |= MWM_HINTS_DECORATIONS; |
400 | hints.decorations |= MWM_DECOR_MAXIMIZE; | |
401 | } | |
402 | ||
403 | XChangeProperty(wxGlobalDisplay(), | |
404 | w, | |
6a44bffd | 405 | mwm_wm_hints, mwm_wm_hints, |
b513212d JS |
406 | 32, PropModeReplace, |
407 | (unsigned char *) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS); | |
408 | ||
409 | return TRUE; | |
410 | } | |
411 | ||
b28d3abf | 412 | bool wxMWMIsRunning(Window w) |
b513212d | 413 | { |
68e42278 | 414 | Display *dpy = (Display*)wxGetDisplay(); |
b513212d JS |
415 | Atom motifWmInfo = XInternAtom(dpy, "_MOTIF_WM_INFO", False); |
416 | ||
417 | unsigned long length, bytesafter; | |
418 | unsigned char value[20]; | |
68e42278 RR |
419 | unsigned char *ptr = &value[0]; |
420 | int ret, format; | |
421 | Atom type; | |
b513212d JS |
422 | |
423 | type = format = length = 0; | |
68e42278 | 424 | value[0] = 0; |
b513212d JS |
425 | |
426 | ret = XGetWindowProperty(wxGlobalDisplay(), w, motifWmInfo, | |
427 | 0L, 2, False, motifWmInfo, | |
68e42278 | 428 | &type, &format, &length, &bytesafter, &ptr); |
b513212d JS |
429 | |
430 | return (ret == Success); | |
83df96d6 | 431 | } |
6a44bffd | 432 | |
e5053ade JS |
433 | // For implementation purposes - sometimes decorations make the client area |
434 | // smaller | |
435 | wxPoint wxTopLevelWindowX11::GetClientAreaOrigin() const | |
436 | { | |
418d4918 JS |
437 | // In fact wxFrame::GetClientAreaOrigin |
438 | // does the required calculation already. | |
439 | #if 0 | |
e5053ade JS |
440 | if (this->IsKindOf(CLASSINFO(wxFrame))) |
441 | { | |
442 | wxFrame* frame = (wxFrame*) this; | |
443 | if (frame->GetMenuBar()) | |
444 | return wxPoint(0, frame->GetMenuBar()->GetSize().y); | |
445 | } | |
418d4918 | 446 | #endif |
e5053ade JS |
447 | return wxPoint(0, 0); |
448 | } | |
449 | ||
450 | void wxTopLevelWindowX11::DoGetClientSize( int *width, int *height ) const | |
451 | { | |
452 | wxWindowX11::DoGetClientSize(width, height); | |
418d4918 JS |
453 | // Done by wxTopLevelWindow |
454 | #if 0 | |
e5053ade JS |
455 | if (this->IsKindOf(CLASSINFO(wxFrame))) |
456 | { | |
457 | wxFrame* frame = (wxFrame*) this; | |
458 | if (frame->GetMenuBar()) | |
459 | (*height) -= frame->GetMenuBar()->GetSize().y; | |
460 | if (frame->GetStatusBar()) | |
461 | (*height) -= frame->GetStatusBar()->GetSize().y; | |
462 | } | |
418d4918 | 463 | #endif |
e5053ade JS |
464 | } |
465 | ||
466 | void wxTopLevelWindowX11::DoSetClientSize(int width, int height) | |
467 | { | |
e5053ade | 468 | wxWindowX11::DoSetClientSize(width, height); |
3a0b23eb | 469 | |
e5053ade JS |
470 | #if 0 |
471 | if (!GetMainWindow()) | |
472 | return; | |
473 | ||
474 | XWindowChanges windowChanges; | |
475 | int valueMask = 0; | |
476 | ||
477 | if (width != -1) | |
478 | { | |
479 | windowChanges.width = width ; | |
480 | valueMask |= CWWidth; | |
481 | } | |
482 | if (height != -1) | |
483 | { | |
484 | windowChanges.height = height ; | |
485 | valueMask |= CWHeight; | |
486 | } | |
487 | XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(), | |
488 | valueMask, & windowChanges); | |
489 | #endif | |
490 | } | |
3a0b23eb JS |
491 | |
492 | void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) | |
493 | { | |
494 | wxString msg; | |
495 | msg.Printf("Setting pos: %d, %d", x, y); | |
496 | wxLogDebug(msg); | |
497 | wxWindowX11::DoSetSize(x, y, width, height, sizeFlags); | |
498 | ||
499 | wxPoint pt = GetPosition(); | |
500 | msg.Printf("After, pos: %d, %d", pt.x, pt.y); | |
501 | wxLogDebug(msg); | |
502 | #if 0 | |
503 | XSync(wxGlobalDisplay(), False); | |
504 | int w, h; | |
505 | GetSize(& w, & h); | |
506 | wxString msg; | |
507 | msg.Printf("Before setting size: %d, %d", w, h); | |
508 | wxLogDebug(msg); | |
509 | if (!GetMainWindow()) | |
510 | return; | |
511 | ||
512 | XWindowChanges windowChanges; | |
513 | int valueMask = 0; | |
514 | ||
515 | if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
516 | { | |
517 | int yy = 0; | |
518 | AdjustForParentClientOrigin( x, yy, sizeFlags); | |
519 | windowChanges.x = x; | |
520 | valueMask |= CWX; | |
521 | } | |
522 | if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
523 | { | |
524 | int xx = 0; | |
525 | AdjustForParentClientOrigin( xx, y, sizeFlags); | |
526 | windowChanges.y = y; | |
527 | valueMask |= CWY; | |
528 | } | |
529 | if (width != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
530 | { | |
531 | windowChanges.width = width /* - m_borderSize*2 */; | |
532 | valueMask |= CWWidth; | |
533 | } | |
534 | if (height != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
535 | { | |
536 | windowChanges.height = height /* -m_borderSize*2*/; | |
537 | valueMask |= CWHeight; | |
538 | } | |
539 | ||
540 | XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(), | |
541 | valueMask, & windowChanges); | |
542 | XSync(wxGlobalDisplay(), False); | |
543 | GetSize(& w, & h); | |
544 | msg.Printf("Tried to set to %d, %d. After setting size: %d, %d", width, height, w, h); | |
545 | wxLogDebug(msg); | |
546 | #endif | |
547 | } | |
548 | ||
549 | void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const | |
550 | { | |
551 | XSync(wxGlobalDisplay(), False); | |
552 | Window window = (Window) m_mainWidget; | |
553 | if (window) | |
554 | { | |
555 | int offsetX = 0; | |
556 | int offsetY = 0; | |
557 | ||
558 | wxLogDebug("Translating..."); | |
559 | Window childWindow; | |
560 | XTranslateCoordinates(wxGlobalDisplay(), window, XDefaultRootWindow(wxGlobalDisplay()), | |
561 | 0, 0, & offsetX, & offsetY, & childWindow); | |
562 | ||
563 | wxString msg; | |
564 | msg.Printf("Offset: %d, %d", offsetX, offsetY); | |
565 | wxLogDebug(msg); | |
566 | ||
567 | XWindowAttributes attr; | |
568 | Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr); | |
569 | wxASSERT(status); | |
570 | ||
571 | if (status) | |
572 | { | |
573 | *x = attr.x + offsetX; | |
574 | *y = attr.y + offsetY; | |
575 | } | |
576 | } | |
577 | } |