]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/settings.cpp
[1231183] 'cleanup: mismatched indentation' and other cleanings.
[wxWidgets.git] / src / gtk / settings.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
3523b9cf 2// Name: gtk/settings.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
9b0b5ba7 5// Modified by: Mart Raudsepp (GetMetric)
f96aa4d9
RR
6// Id: $Id$
7// Copyright: (c) 1998 Robert Roebling
65571936 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
13#pragma implementation "settings.h"
14#endif
15
14f355c2
VS
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
c801d85f 19#include "wx/settings.h"
1ecc4d80 20#include "wx/debug.h"
d06b34a7 21#include "wx/cmndata.h"
2b5f62a0 22#include "wx/fontutil.h"
9b0b5ba7 23#include "wx/toplevel.h"
d06b34a7 24
aed8ac3f 25#include <gdk/gdk.h>
9b0b5ba7 26#include <gdk/gdkx.h>
d06b34a7 27#include <gdk/gdkprivate.h>
aed8ac3f 28#include <gtk/gtk.h>
83624f79 29
9b0b5ba7
RR
30#include <X11/Xatom.h>
31
c801d85f
KB
32#define SHIFT (8*(sizeof(short int)-sizeof(char)))
33
0ab5e0e8 34// ----------------------------------------------------------------------------
94a09ea5 35// wxSystemObjects
0ab5e0e8
VS
36// ----------------------------------------------------------------------------
37
94a09ea5 38struct wxSystemObjects
1ecc4d80 39{
c1ef87c3
VZ
40 wxColour m_colBtnFace,
41 m_colBtnShadow,
42 m_colBtnHighlight,
43 m_colHighlight,
44 m_colHighlightText,
45 m_colListBox,
9d6a9fdd 46 m_colBtnText,
c05cc2c7
RR
47 m_colMenuItemHighlight,
48 m_colTooltip,
49 m_colTooltipText;
c1ef87c3
VZ
50
51 wxFont m_fontSystem;
0ab5e0e8
VS
52};
53
94a09ea5 54static wxSystemObjects gs_objects;
c1ef87c3 55
0ab5e0e8
VS
56// ----------------------------------------------------------------------------
57// wxSystemSettings implementation
58// ----------------------------------------------------------------------------
a3622daa 59
643ccf62 60// kind of widget to use in GetColourFromGTKWidget
dbcbe229 61enum wxGtkWidgetType
643ccf62 62{
dbcbe229 63 wxGTK_BUTTON,
9d6a9fdd
RR
64 wxGTK_LIST,
65 wxGTK_MENUITEM
dbcbe229
VZ
66};
67
68// the colour we need
69enum wxGtkColourType
70{
71 wxGTK_FG,
72 wxGTK_BG,
73 wxGTK_BASE
643ccf62
VZ
74};
75
984152a6 76// wxSystemSettings::GetColour() helper: get the colours from a GTK+
643ccf62 77// widget style, return true if we did get them, false to use defaults
dbcbe229
VZ
78static bool GetColourFromGTKWidget(int& red, int& green, int& blue,
79 wxGtkWidgetType type = wxGTK_BUTTON,
80 GtkStateType state = GTK_STATE_NORMAL,
81 wxGtkColourType colour = wxGTK_BG)
643ccf62 82{
dbcbe229
VZ
83 GtkWidget *widget;
84 switch ( type )
85 {
86 default:
87 wxFAIL_MSG( _T("unexpected GTK widget type") );
88 // fall through
89
90 case wxGTK_BUTTON:
91 widget = gtk_button_new();
92 break;
93
94 case wxGTK_LIST:
95 widget = gtk_list_new();
e24b680c
VZ
96 break;
97
9d6a9fdd
RR
98 case wxGTK_MENUITEM:
99 widget = gtk_menu_item_new();
dbcbe229
VZ
100 }
101
643ccf62
VZ
102 GtkStyle *def = gtk_rc_get_style( widget );
103 if ( !def )
104 def = gtk_widget_get_default_style();
105
106 bool ok;
107 if ( def )
108 {
dbcbe229
VZ
109 GdkColor *col;
110 switch ( colour )
111 {
112 default:
113 wxFAIL_MSG( _T("unexpected GTK colour type") );
114 // fall through
115
116 case wxGTK_FG:
117 col = def->fg;
118 break;
119
120 case wxGTK_BG:
121 col = def->bg;
122 break;
123
124 case wxGTK_BASE:
125 col = def->base;
126 break;
127 }
128
3523b9cf
VZ
129 red = col[state].red;
130 green = col[state].green;
131 blue = col[state].blue;
643ccf62
VZ
132
133 ok = TRUE;
134 }
135 else
136 {
137 ok = FALSE;
138 }
139
140 gtk_widget_destroy( widget );
141
142 return ok;
143}
144
c05cc2c7
RR
145static void GetTooltipColors()
146{
147 GtkTooltips* tooltips = gtk_tooltips_new();
148 gtk_tooltips_force_window(tooltips);
149 gtk_widget_ensure_style(tooltips->tip_window);
150 GdkColor c = tooltips->tip_window->style->bg[GTK_STATE_NORMAL];
151 gs_objects.m_colTooltip = wxColor(c.red >> SHIFT, c.green >> SHIFT, c.blue >> SHIFT);
152 c = tooltips->tip_window->style->fg[GTK_STATE_NORMAL];
153 gs_objects.m_colTooltipText = wxColor(c.red >> SHIFT, c.green >> SHIFT, c.blue >> SHIFT);
154 gtk_object_sink(wx_reinterpret_cast(GtkObject*, tooltips));
155}
156
0ab5e0e8 157wxColour wxSystemSettingsNative::GetColour( wxSystemColour index )
c801d85f 158{
db434467 159 switch (index)
c801d85f 160 {
db434467
RR
161 case wxSYS_COLOUR_SCROLLBAR:
162 case wxSYS_COLOUR_BACKGROUND:
db434467
RR
163 case wxSYS_COLOUR_INACTIVECAPTION:
164 case wxSYS_COLOUR_MENU:
165 case wxSYS_COLOUR_WINDOWFRAME:
166 case wxSYS_COLOUR_ACTIVEBORDER:
167 case wxSYS_COLOUR_INACTIVEBORDER:
168 case wxSYS_COLOUR_BTNFACE:
221ed576 169 case wxSYS_COLOUR_MENUBAR:
5b211fbf 170 case wxSYS_COLOUR_3DLIGHT:
94a09ea5 171 if (!gs_objects.m_colBtnFace.Ok())
37d403aa 172 {
643ccf62 173 int red, green, blue;
dbcbe229 174 if ( !GetColourFromGTKWidget(red, green, blue) )
37d403aa 175 {
643ccf62
VZ
176 red =
177 green = 0;
178 blue = 0x9c40;
37d403aa 179 }
37d403aa 180
94a09ea5 181 gs_objects.m_colBtnFace = wxColour( red >> SHIFT,
c1ef87c3
VZ
182 green >> SHIFT,
183 blue >> SHIFT );
37d403aa 184 }
94a09ea5 185 return gs_objects.m_colBtnFace;
643ccf62 186
db434467 187 case wxSYS_COLOUR_WINDOW:
db434467 188 return *wxWHITE;
643ccf62 189
37d403aa 190 case wxSYS_COLOUR_3DDKSHADOW:
37d403aa 191 return *wxBLACK;
643ccf62 192
db434467
RR
193 case wxSYS_COLOUR_GRAYTEXT:
194 case wxSYS_COLOUR_BTNSHADOW:
37d403aa 195 //case wxSYS_COLOUR_3DSHADOW:
94a09ea5 196 if (!gs_objects.m_colBtnShadow.Ok())
37d403aa 197 {
984152a6 198 wxColour faceColour(GetColour(wxSYS_COLOUR_3DFACE));
94a09ea5 199 gs_objects.m_colBtnShadow =
c1ef87c3
VZ
200 wxColour((unsigned char) (faceColour.Red() * 0.666),
201 (unsigned char) (faceColour.Green() * 0.666),
202 (unsigned char) (faceColour.Blue() * 0.666));
db434467 203 }
643ccf62 204
94a09ea5 205 return gs_objects.m_colBtnShadow;
643ccf62 206
37d403aa
JS
207 case wxSYS_COLOUR_3DHIGHLIGHT:
208 //case wxSYS_COLOUR_BTNHIGHLIGHT:
37d403aa 209 return * wxWHITE;
643ccf62 210
db434467 211 case wxSYS_COLOUR_HIGHLIGHT:
94a09ea5 212 if (!gs_objects.m_colHighlight.Ok())
db434467 213 {
643ccf62 214 int red, green, blue;
dbcbe229
VZ
215 if ( !GetColourFromGTKWidget(red, green, blue,
216 wxGTK_BUTTON,
217 GTK_STATE_SELECTED) )
e6527f9d 218 {
643ccf62
VZ
219 red =
220 green = 0;
221 blue = 0x9c40;
e6527f9d 222 }
db434467 223
94a09ea5 224 gs_objects.m_colHighlight = wxColour( red >> SHIFT,
643ccf62
VZ
225 green >> SHIFT,
226 blue >> SHIFT );
db434467 227 }
94a09ea5 228 return gs_objects.m_colHighlight;
643ccf62 229
74f55195 230 case wxSYS_COLOUR_LISTBOX:
94a09ea5 231 if (!gs_objects.m_colListBox.Ok())
74f55195 232 {
643ccf62 233 int red, green, blue;
dbcbe229
VZ
234 if ( GetColourFromGTKWidget(red, green, blue,
235 wxGTK_LIST,
236 GTK_STATE_NORMAL,
237 wxGTK_BASE) )
74f55195 238 {
94a09ea5 239 gs_objects.m_colListBox = wxColour( red >> SHIFT,
643ccf62
VZ
240 green >> SHIFT,
241 blue >> SHIFT );
74f55195
VS
242 }
243 else
643ccf62 244 {
94a09ea5 245 gs_objects.m_colListBox = wxColour(*wxWHITE);
643ccf62 246 }
74f55195 247 }
94a09ea5 248 return gs_objects.m_colListBox;
643ccf62
VZ
249
250 case wxSYS_COLOUR_MENUTEXT:
251 case wxSYS_COLOUR_WINDOWTEXT:
252 case wxSYS_COLOUR_CAPTIONTEXT:
253 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
254 case wxSYS_COLOUR_BTNTEXT:
94a09ea5 255 if (!gs_objects.m_colBtnText.Ok())
37d403aa 256 {
dbcbe229
VZ
257 int red, green, blue;
258 if ( !GetColourFromGTKWidget(red, green, blue,
259 wxGTK_BUTTON,
260 GTK_STATE_NORMAL,
261 wxGTK_FG) )
37d403aa 262 {
dbcbe229
VZ
263 red =
264 green =
265 blue = 0;
37d403aa 266 }
dbcbe229 267
94a09ea5 268 gs_objects.m_colBtnText = wxColour( red >> SHIFT,
dbcbe229
VZ
269 green >> SHIFT,
270 blue >> SHIFT );
37d403aa 271 }
94a09ea5 272 return gs_objects.m_colBtnText;
643ccf62 273
17d61cbf 274 case wxSYS_COLOUR_INFOBK:
c05cc2c7
RR
275 if (!gs_objects.m_colTooltip.Ok()) {
276 GetTooltipColors();
277 }
278 return gs_objects.m_colTooltip;
279
280 case wxSYS_COLOUR_INFOTEXT:
281 if (!gs_objects.m_colTooltipText.Ok()) {
282 GetTooltipColors();
283 }
284 return gs_objects.m_colTooltipText;
17d61cbf 285
643ccf62 286 case wxSYS_COLOUR_HIGHLIGHTTEXT:
94a09ea5 287 if (!gs_objects.m_colHighlightText.Ok())
643ccf62 288 {
984152a6 289 wxColour hclr = GetColour(wxSYS_COLOUR_HIGHLIGHT);
643ccf62 290 if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200)
94a09ea5 291 gs_objects.m_colHighlightText = wxColour(*wxBLACK);
643ccf62 292 else
94a09ea5 293 gs_objects.m_colHighlightText = wxColour(*wxWHITE);
643ccf62 294 }
94a09ea5 295 return gs_objects.m_colHighlightText;
643ccf62 296
643ccf62
VZ
297 case wxSYS_COLOUR_APPWORKSPACE:
298 return *wxWHITE; // ?
221ed576 299
9d6a9fdd
RR
300 case wxSYS_COLOUR_ACTIVECAPTION:
301 case wxSYS_COLOUR_MENUHILIGHT:
302 if (!gs_objects.m_colMenuItemHighlight.Ok())
303 {
304 int red, green, blue;
305 if ( !GetColourFromGTKWidget(red, green, blue,
306 wxGTK_MENUITEM,
307 GTK_STATE_SELECTED,
308 wxGTK_BG) )
309 {
310 red =
311 green =
312 blue = 0;
313 }
314
315 gs_objects.m_colMenuItemHighlight = wxColour( red >> SHIFT,
316 green >> SHIFT,
317 blue >> SHIFT );
318 }
319 return gs_objects.m_colMenuItemHighlight;
320
221ed576
VZ
321 case wxSYS_COLOUR_HOTLIGHT:
322 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
323 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
221ed576
VZ
324 // TODO
325 return *wxBLACK;
326
327 case wxSYS_COLOUR_MAX:
328 default:
329 wxFAIL_MSG( _T("unknown system colour index") );
e24b680c 330 }
643ccf62 331
e24b680c 332 return *wxWHITE;
ff7b1510 333}
c801d85f 334
0ab5e0e8 335wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
c801d85f 336{
2d17d68f 337 switch (index)
c801d85f 338 {
2d17d68f
RR
339 case wxSYS_OEM_FIXED_FONT:
340 case wxSYS_ANSI_FIXED_FONT:
341 case wxSYS_SYSTEM_FIXED_FONT:
342 {
343 return *wxNORMAL_FONT;
344 }
345 case wxSYS_ANSI_VAR_FONT:
346 case wxSYS_SYSTEM_FONT:
347 case wxSYS_DEVICE_DEFAULT_FONT:
348 case wxSYS_DEFAULT_GUI_FONT:
349 {
94a09ea5 350 if (!gs_objects.m_fontSystem.Ok())
d06b34a7 351 {
2b5f62a0 352#ifdef __WXGTK20__
e7370dac
VS
353 GtkWidget *widget = gtk_button_new();
354 GtkStyle *def = gtk_rc_get_style( widget );
2269ff56 355 if ( !def || !def->font_desc )
e7370dac 356 def = gtk_widget_get_default_style();
2269ff56 357 if ( def && def->font_desc )
e7370dac
VS
358 {
359 wxNativeFontInfo info;
fdf7514a
VS
360 info.description =
361 pango_font_description_copy(def->font_desc);
94a09ea5 362 gs_objects.m_fontSystem = wxFont(info);
e7370dac
VS
363 }
364 else
365 {
119cd341
RR
366 GtkSettings *settings = gtk_settings_get_default();
367 gchar *font_name = NULL;
368 g_object_get ( settings,
369 "gtk-font-name",
370 &font_name,
371 NULL);
372 if (!font_name)
373 gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
374 else
375 gs_objects.m_fontSystem = wxFont(wxString::FromAscii(font_name));
376 g_free (font_name);
e7370dac
VS
377 }
378 gtk_widget_destroy( widget );
2b5f62a0 379#else
94a09ea5 380 gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
2b5f62a0 381#endif
d06b34a7 382 }
94a09ea5 383 return gs_objects.m_fontSystem;
2d17d68f 384 }
c801d85f 385
0ab5e0e8
VS
386 default:
387 return wxNullFont;
388 }
c801d85f 389}
c801d85f 390
9b0b5ba7 391int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
c801d85f 392{
9b0b5ba7 393#ifdef __WXGTK20__
5ac8ce9e
RR
394 bool success = false;
395
9b0b5ba7
RR
396 guchar *data = NULL;
397 GdkWindow *window = NULL;
398 if(win && GTK_WIDGET_REALIZED(win->GetHandle()))
399 window = win->GetHandle()->window;
400#endif
401
1ecc4d80
RR
402 switch (index)
403 {
8e27732a 404#ifdef __WXGTK20__
9b0b5ba7
RR
405 case wxSYS_BORDER_X:
406 case wxSYS_BORDER_Y:
407 case wxSYS_EDGE_X:
408 case wxSYS_EDGE_Y:
409 case wxSYS_FRAMESIZE_X:
410 case wxSYS_FRAMESIZE_Y:
411 // If a window is specified/realized, and it is a toplevel window, we can query from wm.
412 // The returned border thickness is outside the client area in that case.
413 if (window)
414 {
415 wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow);
416 if (!tlw)
417 return -1; // not a tlw, not sure how to approach
418 else
419 {
420 // Check if wm supports frame extents - we can't know
421 // the border widths if it does not.
422#if GTK_CHECK_VERSION(2,2,0)
423 if (!gtk_check_version(2,2,0))
424 {
425 if (!gdk_x11_screen_supports_net_wm_hint(
426 gdk_drawable_get_screen(window),
427 gdk_atom_intern("_NET_FRAME_EXTENTS", false) ) )
428 return -1;
429 }
430 else
431#endif
432 {
433 if (!gdk_net_wm_supports(gdk_atom_intern("_NET_FRAME_EXTENTS", false)))
434 return -1;
435 }
436
437 // Get the frame extents from the windowmanager.
438 // In most cases the top extent is the titlebar, so we use the bottom extent
439 // for the heights.
440
441 Atom type;
442 gint format;
443 gulong nitems;
5ac8ce9e
RR
444
445#if GTK_CHECK_VERSION(2,2,0)
446 if (!gtk_check_version(2,2,0))
447 {
448 gulong bytes_after;
449 success = (XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_drawable_get_display(window)),
9b0b5ba7
RR
450 GDK_WINDOW_XWINDOW(window),
451 gdk_x11_get_xatom_by_name_for_display (
452 gdk_drawable_get_display(window),
453 "_NET_FRAME_EXTENTS" ),
454 0, // left, right, top, bottom, CARDINAL[4]/32
455 G_MAXLONG, // size of long
456 false, // do not delete property
457 XA_CARDINAL, // 32 bit
458 &type, &format, &nitems, &bytes_after, &data
5ac8ce9e
RR
459 ) == Success);
460 }
461#endif
462 if (success)
9b0b5ba7
RR
463 {
464 int border_return = -1;
465
466 if ((type == XA_CARDINAL) && (format == 32) && (nitems >= 4) && (data))
467 {
468 long *borders;
469 borders = (long*)data;
470 switch(index)
471 {
472 case wxSYS_BORDER_X:
473 case wxSYS_EDGE_X:
474 case wxSYS_FRAMESIZE_X:
475 border_return = borders[1]; // width of right extent
476 break;
477 default:
478 border_return = borders[3]; // height of bottom extent
479 break;
480 }
481 }
482
483 if (data)
484 XFree(data);
485
486 return border_return;
487 }
488 }
489 }
490
491 return -1; // no window specified
8e27732a 492#endif // gtk2
9b0b5ba7
RR
493
494 case wxSYS_CURSOR_X:
495 case wxSYS_CURSOR_Y:
496#ifdef __WXGTK24__
497 if (!gtk_check_version(2,4,0))
498 {
499 if (window)
500 return gdk_display_get_default_cursor_size(gdk_drawable_get_display(window));
501 else
502 return gdk_display_get_default_cursor_size(gdk_display_get_default());
503 }
504 else
505#endif
506 return 16;
17d61cbf 507
9b0b5ba7 508#ifdef __WXGTK20__
44fd6f72
VS
509 case wxSYS_DCLICK_X:
510 case wxSYS_DCLICK_Y:
511 gint dclick_distance;
9b0b5ba7
RR
512#if GTK_CHECK_VERSION(2,2,0)
513 if (window && !gtk_check_version(2,2,0))
514 g_object_get(gtk_settings_get_for_screen(gdk_drawable_get_screen(window)),
515 "gtk-double-click-distance", &dclick_distance, NULL);
516 else
44fd6f72 517#endif
9b0b5ba7
RR
518 g_object_get(gtk_settings_get_default(),
519 "gtk-double-click-distance", &dclick_distance, NULL);
520
521 return dclick_distance * 2;
522#endif // gtk2
44fd6f72 523
9b0b5ba7 524#ifdef __WXGTK20__
44fd6f72
VS
525 case wxSYS_DRAG_X:
526 case wxSYS_DRAG_Y:
527 gint drag_threshold;
9b0b5ba7
RR
528#if GTK_CHECK_VERSION(2,2,0)
529 if (window && !gtk_check_version(2,2,0))
530 {
531 g_object_get(
532 gtk_settings_get_for_screen(gdk_drawable_get_screen(window)),
533 "gtk-dnd-drag-threshold",
534 &drag_threshold, NULL);
535 }
536 else
44fd6f72 537#endif
9b0b5ba7
RR
538 {
539 g_object_get(gtk_settings_get_default(),
540 "gtk-dnd-drag-threshold", &drag_threshold, NULL);
541 }
44fd6f72 542
9b0b5ba7 543 return drag_threshold * 2;
44fd6f72 544#endif
9b0b5ba7 545
f618020a
MB
546 // MBN: ditto for icons
547 case wxSYS_ICON_X: return 32;
548 case wxSYS_ICON_Y: return 32;
9b0b5ba7
RR
549
550 case wxSYS_SCREEN_X:
551#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0)
552 if (window && !gtk_check_version(2,2,0))
553 return gdk_screen_get_width(gdk_drawable_get_screen(window));
554 else
555#endif
556 return gdk_screen_width();
557
558 case wxSYS_SCREEN_Y:
559#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,2,0)
560 if (window && !gtk_check_version(2,2,0))
561 return gdk_screen_get_height(gdk_drawable_get_screen(window));
562 else
563#endif
564 return gdk_screen_height();
565
566 case wxSYS_HSCROLL_Y: return 15;
567 case wxSYS_VSCROLL_X: return 15;
568
569// a gtk1 implementation should be possible too if gtk2 efficiency/convenience functions aren't used
570#ifdef __WXGTK20__
571 case wxSYS_CAPTION_Y:
572 if (!window)
573 // No realized window specified, and no implementation for that case yet.
574 return -1;
575
576 // Check if wm supports frame extents - we can't know the caption height if it does not.
577#if GTK_CHECK_VERSION(2,2,0)
578 if (!gtk_check_version(2,2,0))
579 {
580 if (!gdk_x11_screen_supports_net_wm_hint(
581 gdk_drawable_get_screen(window),
582 gdk_atom_intern("_NET_FRAME_EXTENTS", false) ) )
583 return -1;
584 }
585 else
586#endif
587 {
588 if (!gdk_net_wm_supports(gdk_atom_intern("_NET_FRAME_EXTENTS", false)))
589 return -1;
590 }
591
592 wxASSERT_MSG( wxDynamicCast(win, wxTopLevelWindow),
593 wxT("Asking for caption height of a non toplevel window") );
594
595 // Get the height of the top windowmanager border.
596 // This is the titlebar in most cases. The titlebar might be elsewhere, and
597 // we could check which is the thickest wm border to decide on which side the
598 // titlebar is, but this might lead to interesting behaviours in used code.
599 // Reconsider when we have a way to report to the user on which side it is.
600
601 Atom type;
602 gint format;
603 gulong nitems;
9b0b5ba7 604
5ac8ce9e
RR
605#if GTK_CHECK_VERSION(2,2,0)
606 if (!gtk_check_version(2,2,0))
607 {
608 gulong bytes_after;
609 success = (XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_drawable_get_display(window)),
9b0b5ba7
RR
610 GDK_WINDOW_XWINDOW(window),
611 gdk_x11_get_xatom_by_name_for_display (
612 gdk_drawable_get_display(window),
613 "_NET_FRAME_EXTENTS" ),
614 0, // left, right, top, bottom, CARDINAL[4]/32
615 G_MAXLONG, // size of long
616 false, // do not delete property
617 XA_CARDINAL, // 32 bit
618 &type, &format, &nitems, &bytes_after, &data
5ac8ce9e
RR
619 ) == Success);
620 }
621#endif
622 if (success)
9b0b5ba7
RR
623 {
624 int caption_height = -1;
625
626 if ((type == XA_CARDINAL) && (format == 32) && (nitems >= 3) && (data))
627 {
628 long *borders;
629 borders = (long*)data;
630 caption_height = borders[2]; // top frame extent
631 }
632
633 if (data)
634 XFree(data);
635
636 return caption_height;
637 }
638
639 // Try a default approach without a window pointer, if possible
640 // ...
641
642 return -1;
643#endif // gtk2
644
645 case wxSYS_PENWINDOWS_PRESENT:
646 // No MS Windows for Pen computing extension available in X11 based gtk+.
647 return 0;
648
649 default:
1d451c5b 650 return -1; // metric is unknown
1ecc4d80 651 }
c67daf87 652}
253293c1 653
0ab5e0e8 654bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
253293c1
VS
655{
656 switch (index)
657 {
658 case wxSYS_CAN_ICONIZE_FRAME:
0ab5e0e8
VS
659 return FALSE;
660 break;
253293c1 661 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
0ab5e0e8
VS
662 return TRUE;
663 break;
253293c1
VS
664 default:
665 return FALSE;
666 }
667}