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.3-feature
Attached file "fltk-1.3.x-clipboard-xfixes.patch"...
Link: http://www.fltk.org/str.php?L2636
Version: 1.3-feature
diff -up fltk-1.3.x-r8659/configh.in.orig fltk-1.3.x-r8659/configh.in
--- fltk-1.3.x-r8659/configh.in.orig 2011-05-18 13:59:25.377439742 +0200
+++ fltk-1.3.x-r8659/configh.in 2011-05-18 14:00:04.627333345 +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.orig fltk-1.3.x-r8659/configure.in
--- fltk-1.3.x-r8659/configure.in.orig 2011-05-18 13:57:43.227101129 +0200
+++ fltk-1.3.x-r8659/configure.in 2011-05-18 13:59:39.329534702 +0200
@@ -1006,6 +1006,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.orig fltk-1.3.x-r8659/src/Fl_x.cxx
--- fltk-1.3.x-r8659/src/Fl_x.cxx.orig 2011-05-18 14:23:00.792967025 +0200
+++ fltk-1.3.x-r8659/src/Fl_x.cxx 2011-05-18 14:54:02.679508925 +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() {
@@ -893,6 +893,10 @@ static void poll_clipboard_owner(void) {
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;
@@ -928,10 +932,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
@@ -951,10 +957,12 @@ int 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);
+ }
}
}
@@ -1678,6 +1700,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)
+ handle_clipboard_timestamp(0, selection_notify->selection_timestamp);
+ else if (selection_notify->selection == CLIPBOARD)
+ handle_clipboard_timestamp(1, selection_notify->selection_timestamp);
+
+ return true;
+ }
+ }
+#endif
+
return Fl::handle(event, window);
}
@@ -1911,6 +1952,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