summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2006-10-30 14:16:08 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2006-10-30 14:16:08 +0000
commit3ebd631cf09a3d04f7c9606b33dca40176928445 (patch)
tree13ce6fd15d13d9c88bcd8a4ecb3df8ac6be99445
parent117e22670d08fb4b865ebe84fa779ae1acb16b1d (diff)
Fl::x(), Fl::y(), Fl::w(), and Fl::h() did not report the desktop
work area on X11 (STR #1482) Fix another "missing sentinel" warning in the Xft code. FL/Fl.H: - Remove in-line x() and y() implementation for X11. src/Fl_x.cxx: - Fl::x(), Fl::y(): Added. - fl_init_workarea(): Added to get _NET_WORKAREA property from the root window; if none, is available, the code falls back to 0, 0, DisplayWidth, and DisplayHeight. src/fl_font_xft.cxx: - Missing sentinel needs cast to void *. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5535 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES2
-rw-r--r--FL/Fl.H7
-rw-r--r--src/Fl_x.cxx49
-rw-r--r--src/fl_font_xft.cxx2
4 files changed, 49 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index 8024b1189..a0d167d18 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.8
- Documentation fixes (STR #1454, STR #1455, STR #1456,
STR #1457, STR #1458, STR #1460, STR #1481)
+ - Fl::x(), Fl::y(), Fl::w(), and Fl::h() did not report
+ the desktop work area on X11 (STR #1482)
- Shortcut events could be sent to the wrong window (STR
#1451)
- Fl_Spinner did not handle the arrow keys properly (STR
diff --git a/FL/Fl.H b/FL/Fl.H
index 72086ccd2..13a24a6c5 100644
--- a/FL/Fl.H
+++ b/FL/Fl.H
@@ -3,7 +3,7 @@
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2005 by Bill Spitzak and others.
+// Copyright 1998-2006 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -194,13 +194,8 @@ public:
static void paste(Fl_Widget &receiver);
// screen size:
-#if defined(WIN32) || defined(__APPLE__)
static int x();
static int y();
-#else
- static int x() {return 0;}
- static int y() {return 0;}
-#endif /* WIN32 || __APPLE__ */
static int w();
static int h();
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index 57c1719c8..85a43def0 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -367,14 +367,55 @@ void fl_close_display() {
XCloseDisplay(fl_display);
}
-int Fl::h() {
+static int fl_workarea_xywh[4] = { -1, -1, -1, -1 };
+
+static void fl_init_workarea() {
fl_open_display();
- return DisplayHeight(fl_display,fl_screen);
+
+ Atom _NET_WORKAREA = XInternAtom(fl_display, "_NET_WORKAREA", 0);
+ Atom actual;
+ unsigned long count, remaining;
+ int format;
+ unsigned *xywh;
+
+ if (XGetWindowProperty(fl_display, RootWindow(fl_display, fl_screen),
+ _NET_WORKAREA, 0, 4 * sizeof(unsigned), False,
+ XA_CARDINAL, &actual, &format, &count, &remaining,
+ (unsigned char **)&xywh))
+ {
+ fl_workarea_xywh[0] = 0;
+ fl_workarea_xywh[1] = 0;
+ fl_workarea_xywh[2] = DisplayWidth(fl_display, fl_screen);
+ fl_workarea_xywh[3] = DisplayHeight(fl_display, fl_screen);
+ }
+ else
+ {
+ fl_workarea_xywh[0] = (int)xywh[0];
+ fl_workarea_xywh[1] = (int)xywh[1];
+ fl_workarea_xywh[2] = (int)xywh[2];
+ fl_workarea_xywh[3] = (int)xywh[3];
+ XFree(xywh);
+ }
+}
+
+int Fl::x() {
+ if (fl_workarea_xywh[0] < 0) fl_init_workarea();
+ return fl_workarea_xywh[0];
+}
+
+int Fl::y() {
+ if (fl_workarea_xywh[0] < 0) fl_init_workarea();
+ return fl_workarea_xywh[1];
}
int Fl::w() {
- fl_open_display();
- return DisplayWidth(fl_display,fl_screen);
+ if (fl_workarea_xywh[0] < 0) fl_init_workarea();
+ return fl_workarea_xywh[2];
+}
+
+int Fl::h() {
+ if (fl_workarea_xywh[0] < 0) fl_init_workarea();
+ return fl_workarea_xywh[3];
}
void Fl::get_mouse(int &xx, int &yy) {
diff --git a/src/fl_font_xft.cxx b/src/fl_font_xft.cxx
index 4c87ca23a..d84af32d6 100644
--- a/src/fl_font_xft.cxx
+++ b/src/fl_font_xft.cxx
@@ -145,7 +145,7 @@ static XftFont* fontopen(const char* name, bool core) {
XFT_PIXEL_SIZE, XftTypeDouble, (double)fl_size_,
core ? XFT_CORE : 0, XftTypeBool, true,
XFT_RENDER, XftTypeBool, false,
- 0);
+ (void *)0);
}
Fl_FontSize::Fl_FontSize(const char* name) {