DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2636
Version: 1.4-feature
Attached file "fltk-1_v2.3.x-clipboard-xfixes.patch"...
Link: http://www.fltk.org/str.php?L2636
Version: 1.4-feature
diff -up fltk-1.3.x-r8659/configh.in.clp-xfixes fltk-1.3.x-r8659/configh.in
--- fltk-1.3.x-r8659/configh.in.clp-xfixes 2011-03-06 17:54:58.000000000
+0100
+++ fltk-1.3.x-r8659/configh.in 2011-05-19 16:55:27.986364764 +0200
@@ -117,6 +117,14 @@
#define USE_XDBE HAVE_XDBE
/*
+ * HAVE_XFIXES:
+ *
+ * Do we have the X fixes extension?
+ */
+
+#define HAVE_XFIXES 0
+
+/*
* __APPLE_QUARTZ__:
*
* All Apple implementations are now based on Quartz and Cocoa,
diff -up fltk-1.3.x-r8659/configure.in.clp-xfixes fltk-1.3.x-r8659/configure.in
--- fltk-1.3.x-r8659/configure.in.clp-xfixes 2011-05-19 16:55:27.976363265
+0200
+++ fltk-1.3.x-r8659/configure.in 2011-05-19 16:55:27.987364914 +0200
@@ -1008,6 +1008,16 @@ case $uname_GUI in
LIBS="-lXext $LIBS")
fi
+ dnl Check for the Xfixes extension unless disabled...
+ AC_ARG_ENABLE(xfixes, [ --enable-xfixes turn on Xfixes support
[default=yes]])
+
+ if test x$enable_xfixes != xno; then
+ AC_CHECK_HEADER(X11/extensions/Xfixes.h, AC_DEFINE(HAVE_XFIXES),,
+ [#include <X11/Xlib.h>])
+ AC_CHECK_LIB(Xfixes, XFixesQueryExtension,
+ LIBS="-lXfixes $LIBS")
+ fi
+
dnl Check for overlay visuals...
AC_PATH_PROG(XPROP, xprop)
AC_CACHE_CHECK(for X overlay visuals, ac_cv_have_overlay,
diff -up fltk-1.3.x-r8659/src/Fl_x.cxx.clp-xfixes fltk-1.3.x-r8659/src/Fl_x.cxx
--- fltk-1.3.x-r8659/src/Fl_x.cxx.clp-xfixes 2011-05-19 16:55:27.984364466
+0200
+++ fltk-1.3.x-r8659/src/Fl_x.cxx 2011-05-19 16:58:06.156112039 +0200
@@ -53,6 +53,10 @@
# include <X11/Xlib.h>
# include <X11/keysym.h>
+# ifdef HAVE_XFIXES
+# include <X11/extensions/Xfixes.h>
+# endif
+
static Fl_Xlib_Graphics_Driver fl_xlib_driver;
static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver =
(Fl_Graphics_Driver*)&fl_xlib_driver; // the current target device of graphics
operations
@@ -303,6 +307,8 @@ XIC fl_xim_ic = 0;
Window fl_xim_win = 0;
char fl_is_over_the_spot = 0;
static XRectangle status_area;
+static bool have_xfixes = false;
+static int xfixes_event_base = 0;
static Atom WM_DELETE_WINDOW;
static Atom WM_PROTOCOLS;
@@ -726,6 +732,14 @@ void fl_open_display(Display* d) {
#if !USE_COLORMAP
Fl::visual(FL_RGB);
#endif
+
+#ifdef HAVE_XFIXES
+ int error_base;
+ if (XFixesQueryExtension(d, &xfixes_event_base, &error_base))
+ have_xfixes = true;
+ else
+ have_xfixes = false;
+#endif
}
void fl_close_display() {
@@ -878,6 +892,10 @@ extern void fl_trigger_clipboard_notify(
static void poll_clipboard_owner(void) {
Window xid;
+ // No polling needed with Xfixes
+ if (have_xfixes)
+ return;
+
// No one is interested, so no point polling
if (fl_clipboard_notify_empty())
return;
@@ -916,10 +934,12 @@ static void handle_clipboard_timestamp(i
timestamp = clipboard ? &clipboard_timestamp : &primary_timestamp;
- // Initial scan, just store the value
- if (*timestamp == (Time)-1) {
- *timestamp = time;
- return;
+ if (!have_xfixes) {
+ // Initial scan, just store the value
+ if (*timestamp == (Time)-1) {
+ *timestamp = time;
+ return;
+ }
}
// Same selection
@@ -939,10 +959,12 @@ void fl_clipboard_notify_change() {
primary_timestamp = -1;
clipboard_timestamp = -1;
} else {
- poll_clipboard_owner();
+ if (!have_xfixes) {
+ poll_clipboard_owner();
- if (!Fl::has_timeout(clipboard_timeout))
- Fl::add_timeout(0.5, clipboard_timeout);
+ if (!Fl::has_timeout(clipboard_timeout))
+ Fl::add_timeout(0.5, clipboard_timeout);
+ }
}
}
@@ -1638,6 +1660,25 @@ int fl_handle(const XEvent& thisevent)
}
}
+#ifdef HAVE_XFIXES
+ switch (xevent.type - xfixes_event_base) {
+ case XFixesSelectionNotify: {
+ // Someone feeding us bogus events?
+ if (!have_xfixes)
+ return true;
+
+ XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent
*)&xevent;
+
+ if ((selection_notify->selection == XA_PRIMARY) && !fl_i_own_selection[0])
+ handle_clipboard_timestamp(0, selection_notify->selection_timestamp);
+ else if ((selection_notify->selection == CLIPBOARD) &&
!fl_i_own_selection[1])
+ handle_clipboard_timestamp(1, selection_notify->selection_timestamp);
+
+ return true;
+ }
+ }
+#endif
+
return Fl::handle(event, window);
}
@@ -1871,6 +1912,16 @@ void Fl_X::make_xid(Fl_Window* win, XVis
XChangeProperty(fl_display, xp->xid, net_wm_type, XA_ATOM, 32,
PropModeReplace, (unsigned char*)&net_wm_type_kind, 1);
}
+#ifdef HAVE_XFIXES
+ // register for clipboard change notifications
+ if (have_xfixes && !win->parent()) {
+ XFixesSelectSelectionInput(fl_display, xp->xid, XA_PRIMARY,
+ XFixesSetSelectionOwnerNotifyMask);
+ XFixesSelectSelectionInput(fl_display, xp->xid, CLIPBOARD,
+ XFixesSetSelectionOwnerNotifyMask);
+ }
+#endif
+
XMapWindow(fl_display, xp->xid);
if (showit) {
win->set_visible();
_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev