summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2005-03-31 16:01:24 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2005-03-31 16:01:24 +0000
commitcc593f6b647bb7aa0c283b77dc90527300becbef (patch)
tree4bbbd4dbe9ea5b2f060dad51f318ecfc0b1b0466
parent81fd6777b28786413ca990f4261f4c6a7813fd6e (diff)
Add Fl::screen_count() and Fl::screen_xywh() APIs to support multi-
screen displays (currently only X11 support with Xinerama) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4223 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES2
-rw-r--r--FL/Fl.H12
-rw-r--r--configh.in12
-rw-r--r--configure.in9
-rw-r--r--fltk.spec2
-rw-r--r--src/Makefile3
-rw-r--r--src/screen_xywh.cxx147
-rw-r--r--vcnet/fltk.lib.vcproj20
-rw-r--r--vcnet/fltkdll.vcproj18
-rw-r--r--visualc/fltk.lib.dsp4
-rw-r--r--visualc/fltkdll.dsp4
11 files changed, 229 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 8c20b445b..bd6ca27e0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.7
- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745)
+ - Added Fl::screen_count() and Fl::screen_xywh() APIs to
+ support multi-screen displays.
- FLUID now supports direct creation of widget classes.
- Fl_File_Chooser now correctly handles multiple
selections that are a mix of files and directories.
diff --git a/FL/Fl.H b/FL/Fl.H
index 2ef363588..cde76a4f9 100644
--- a/FL/Fl.H
+++ b/FL/Fl.H
@@ -20,7 +20,9 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
-// Please report all bugs and problems to "fltk-bugs@fltk.org".
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
//
#ifndef Fl_H
@@ -199,6 +201,14 @@ public:
static int w();
static int h();
+ // multi-head support:
+ static int screen_count();
+ static void screen_xywh(int &x, int &y, int &w, int &h) {
+ screen_xywh(x, y, w, h, e_x_root, e_y_root);
+ }
+ static void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my);
+ static void screen_xywh(int &x, int &y, int &w, int &h, int n);
+
// color map:
static void set_color(Fl_Color, uchar, uchar, uchar);
static void set_color(Fl_Color, unsigned);
diff --git a/configh.in b/configh.in
index 748e9dc40..4679e45c1 100644
--- a/configh.in
+++ b/configh.in
@@ -21,7 +21,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
- * Please report all bugs and problems to "fltk-bugs@fltk.org".
+ * Please report all bugs and problems on the following page:
+ *
+ * http://www.fltk.org/str.php
*/
/*
@@ -75,6 +77,14 @@
#define USE_COLORMAP 1
/*
+ * HAVE_XINERAMA
+ *
+ * Do we have the Xinerama library to support multi-head displays?
+ */
+
+#define HAVE_XINERAMA 0
+
+/*
* USE_XFT
*
* Use the new Xft library to draw anti-aliased text.
diff --git a/configure.in b/configure.in
index 7c6fad501..5fb0dc6a9 100644
--- a/configure.in
+++ b/configure.in
@@ -607,6 +607,15 @@ case $uname in
GLDEMOS=""
fi
+ dnl Check for Xinerama support unless disabled...
+ AC_ARG_ENABLE(xinerama, [ --enable-xinerama turn on Xinerama support [default=no]])
+
+ if test x$enable_xinerama = xyes; then
+ AC_CHECK_LIB(Xinerama,XineramaIsActive,
+ AC_DEFINE(HAVE_XINERAMA)
+ LIBS="-lXinerama $LIBS")
+ fi
+
dnl Check for the Xft library unless disabled...
AC_ARG_ENABLE(xft, [ --enable-xft turn on Xft support [default=no]])
diff --git a/fltk.spec b/fltk.spec
index c3dcaa578..c22d56495 100644
--- a/fltk.spec
+++ b/fltk.spec
@@ -59,7 +59,7 @@ dynamically linked applications.
%setup
%build
-CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} --mandir=%{_mandir} --enable-shared --enable-xft --enable-xdbe
+CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} --mandir=%{_mandir} --enable-shared --enable-xft --enable-xdbe --enable-xinerama
# If we got this far, all prerequisite libraries must be here.
make
diff --git a/src/Makefile b/src/Makefile
index 57544b1cb..c3ac99981 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -146,7 +146,8 @@ CPPFILES = \
fl_shortcut.cxx \
fl_show_colormap.cxx \
fl_symbols.cxx \
- fl_vertex.cxx
+ fl_vertex.cxx \
+ screen_xywh.cxx
FLCPPFILES = \
forms_compatability.cxx \
diff --git a/src/screen_xywh.cxx b/src/screen_xywh.cxx
new file mode 100644
index 000000000..947f01910
--- /dev/null
+++ b/src/screen_xywh.cxx
@@ -0,0 +1,147 @@
+//
+// "$Id$"
+//
+// Screen/monitor bounding box API for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2005 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
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+
+#include <FL/Fl.H>
+#include <FL/x.H>
+#include <config.h>
+
+#ifdef HAVE_XINERAMA
+# include <X11/extensions/Xinerama.h>
+#endif // HAVE_XINERAMA
+
+
+// Return the number of screens...
+int Fl::screen_count() {
+}
+
+// Return the screen bounding rect for the given mouse position...
+void Fl::screen_xywh(int &x, int &y, int &w, int &h, int mx, int my) {
+#ifdef WIN32
+#elif defined(__APPLE__)
+#elif defined(HAVE_XINERAMA)
+ if (!fl_display) fl_open_display();
+
+ if (XineramaIsActive(fl_display)) {
+ int i,
+ num_rects;
+ XineramaScreenInfo *rects;
+
+
+ rects = XineramaQueryScreens(fl_display, &num_rects);
+
+# ifdef DEBUG
+ printf("num_rects = %d\n", num_rects);
+ printf("window_->x_root() = %d, y_root() = %d\n",
+ window_->x_root(), window_->y_root());
+# endif // DEBUG
+
+ for (i = 0; i < num_rects; i ++) {
+# ifdef DEBUG
+ printf("rects[%d] = [%d %d %d %d]\n", i,
+ rects[i].x_org, rects[i].y_org, rects[i].width,
+ rects[i].height);
+# endif // DEBUG
+
+ if (mx >= rects[i].x_org &&
+ mx < (rects[i].x_org + rects[i].width) &&
+ my >= rects[i].y_org &&
+ my < (rects[i].y_org + rects[i].height))
+ {
+ x = rects[i].x_org;
+ y = rects[i].y_org;
+ w = rects[i].width;
+ h = rects[i].height;
+ break;
+ }
+ }
+
+ XFree(rects);
+ }
+#endif // WIN32
+
+ x = Fl::x();
+ y = Fl::y();
+ w = Fl::w();
+ h = Fl::h();
+}
+
+// Return the screen bounding rect for the given screen...
+void Fl::screen_xywh(int &x, int &y, int &w, int &h, int n) {
+#ifdef WIN32
+#elif defined(__APPLE__)
+#elif defined(HAVE_XINERAMA)
+ if (!fl_display) fl_open_display();
+
+ if (XineramaIsActive(fl_display)) {
+ int i,
+ num_rects;
+ XineramaScreenInfo *rects;
+
+
+ rects = XineramaQueryScreens(fl_display, &num_rects);
+
+# ifdef DEBUG
+ printf("num_rects = %d\n", num_rects);
+ printf("window_->x_root() = %d, y_root() = %d\n",
+ window_->x_root(), window_->y_root());
+# endif // DEBUG
+
+ for (i = 0; i < num_rects; i ++) {
+# ifdef DEBUG
+ printf("rects[%d] = [%d %d %d %d]\n", i,
+ rects[i].x_org, rects[i].y_org, rects[i].width,
+ rects[i].height);
+# endif // DEBUG
+
+ if (mx >= rects[i].x_org &&
+ mx < (rects[i].x_org + rects[i].width) &&
+ my >= rects[i].y_org &&
+ my < (rects[i].y_org + rects[i].height))
+ {
+ x = rects[i].x_org;
+ y = rects[i].y_org;
+ w = rects[i].width;
+ h = rects[i].height;
+ break;
+ }
+ }
+
+ XFree(rects);
+ }
+#endif // WIN32
+
+ x = Fl::x();
+ y = Fl::y();
+ w = Fl::w();
+ h = Fl::h();
+}
+
+
+//
+// End of "$Id$".
+//
diff --git a/vcnet/fltk.lib.vcproj b/vcnet/fltk.lib.vcproj
index 3f744f517..0be07e1f8 100644
--- a/vcnet/fltk.lib.vcproj
+++ b/vcnet/fltk.lib.vcproj
@@ -2635,6 +2635,26 @@
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\src\screen_xywh.cxx">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ FavorSizeOrSpeed="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/vcnet/fltkdll.vcproj b/vcnet/fltkdll.vcproj
index 891e7e2f9..0d6ec076e 100644
--- a/vcnet/fltkdll.vcproj
+++ b/vcnet/fltkdll.vcproj
@@ -2774,6 +2774,24 @@
PreprocessorDefinitions="FL_DLL;FL_LIBRARY;WIN32;_DEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\src\screen_xywh.cxx">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="FL_DLL;FL_LIBRARY;WIN32;NDEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="FL_DLL;FL_LIBRARY;WIN32;_DEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"/>
+ </FileConfiguration>
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/visualc/fltk.lib.dsp b/visualc/fltk.lib.dsp
index 5b3f029f0..fbae8d629 100644
--- a/visualc/fltk.lib.dsp
+++ b/visualc/fltk.lib.dsp
@@ -589,5 +589,9 @@ SOURCE=..\src\scandir.c
SOURCE=..\src\vsnprintf.c
# End Source File
+# Begin Source File
+
+SOURCE=..\src\screen_xywh.cxx
+# End Source File
# End Target
# End Project
diff --git a/visualc/fltkdll.dsp b/visualc/fltkdll.dsp
index 9a748ec3c..9d0b3dd7c 100644
--- a/visualc/fltkdll.dsp
+++ b/visualc/fltkdll.dsp
@@ -2633,5 +2633,9 @@ DEP_CPP_VSNPR=\
{$(INCLUDE)}"fl\fl_export.h"\
# End Source File
+# Begin Source File
+
+SOURCE=..\src\screen_xywh.cxx
+# End Source File
# End Target
# End Project