[fltk.development] Minor patch: build fullscreen test even without GL

2012-06-13 Thread Peter Åstrand


Currently, the fullscreen test is only built if FLTK is built with OpenGL. 
However, just like the "cube" demo etc, the fullscreen demo works fine and 
is useful even without GL. So I'm suggesting this patch:


--- test/Makefile   (revision 9591)
+++ test/Makefile   (arbetskopia)
@@ -159,6 +159,7 @@
tree$(EXEEXT) \
valuators$(EXEEXT) \
cairotest$(EXEEXT) \
+   fullscreen$(EXEEXT) \
utf8$(EXEEXT)


@@ -166,7 +167,6 @@
cube$(EXEEXT) \
CubeView$(EXEEXT) \
fractals$(EXEEXT) \
-   fullscreen$(EXEEXT) \
gl_overlay$(EXEEXT) \
glpuzzle$(EXEEXT) \
shape$(EXEEXT)

Rgds, 
---

Peter Åstrand   ThinLinc Chief Developer
Cendio AB   http://cendio.com
Teknikringen 8  http://twitter.com/ThinLinc
583 30 Linköpinghttp://facebook.com/ThinLinc
Phone: +46-13-214600http://plus.google.com/112509906846170010689___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


[fltk.development] [RFE] STR #2856: extend "fullscreen" test app for verifying screens and workarea

2012-06-14 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2856
Version: 1.3-feature


Historically, there has been many bugs related to the screen and workarea
functions, including Fl::w() and the screen_xywh functions. It's difficult
to verify correct behaviour because you need to test on many different
platforms and also with different monitor configurations, window managers
etc. We need some tool for this. I figured that it made sense to extend
the "fullscreen" test program for this. The attached patch extends the
test program to display:

* Main screen work area (ie Fl::w() et al)
* Mouse screen work area: Fl::screen_work_area(x, y, w, h)
* Screen and workarea information for all detected screens


Link: http://www.fltk.org/str.php?L2856
Version: 1.3-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2856: extend "fullscreen" test app for verifying screens and workarea

2012-06-14 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2856
Version: 1.3-feature


Attached file "fullscreen-screeninfo1.patch"...


Link: http://www.fltk.org/str.php?L2856
Version: 1.3-featureIndex: test/fullscreen.cxx
===
--- test/fullscreen.cxx (revision 9598)
+++ test/fullscreen.cxx (arbetskopia)
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #if HAVE_GL
@@ -190,13 +191,36 @@
   }
 }
 
+void update_screeninfo(Fl_Widget *b, void *p) {
+Fl_Browser *browser = (Fl_Browser *)p;
+int x, y, w, h;
+char line[128];
+browser->clear();
+
+sprintf(line, "Main screen work area: %dx%d@%d,%d", Fl::w(), Fl::h(), 
Fl::x(), Fl::y());
+browser->add(line);
+Fl::screen_work_area(x, y, w, h);
+sprintf(line, "Mouse screen work area: %dx%d@%d,%d", w, h, x, y);
+browser->add(line);
+for (int n = 0; n < Fl::screen_count(); n++) {
+   int x, y, w, h;
+   Fl::screen_xywh(x, y, w, h, n);
+   sprintf(line, "Screen %d: %dx%d@%d,%d", n, w, h, x, y);
+   browser->add(line);
+   Fl::screen_work_area(x, y, w, h, n);
+   sprintf(line, "Work area %d: %dx%d@%d,%d", n, w, h, x, y);
+   browser->add(line);
+}
+}
+
+
 #include 
 
 void exit_cb(Fl_Widget *, void *) {
   exit(0);
 }
 
-#define NUMB 6
+#define NUMB 7
 
 int twowindow = 0;
 int initfull = 0;
@@ -212,9 +236,9 @@
   if (Fl::args(argc,argv,i,arg) < argc)
 Fl::fatal("Options are:\n -2 = 2 windows\n -f = startup 
fullscreen\n%s",Fl::help);
 
-  fullscreen_window window(300,300+30*NUMB); window.end();
+  fullscreen_window window(400,400+30*NUMB); window.end();
 
-  shape_window sw(10,10,window.w()-20,window.h()-30*NUMB-20);
+  shape_window sw(10,10,window.w()-20,window.h()-30*NUMB-120);
 
 #if HAVE_GL
   sw.mode(FL_RGB);
@@ -235,7 +259,7 @@
 
   window.begin();
 
-  int y = window.h()-30*NUMB-5;
+  int y = window.h()-30*NUMB-105;
   Fl_Hor_Slider slider(50,y,window.w()-60,30,"Sides:");
   slider.align(FL_ALIGN_LEFT);
   slider.callback(sides_cb,&sw);
@@ -265,6 +289,14 @@
   eb.callback(exit_cb);
   y+=30;
 
+  Fl_Browser *browser = new Fl_Browser(50,y,window.w()-60,100);
+  update_screeninfo(0, browser);
+  y+=100;
+
+  Fl_Button update(50,y,window.w()-60,30,"Update");
+  update.callback(update_screeninfo, browser);
+  y+=30;
+
   if (initfull) {window.b3->set(); window.b3->do_callback();}
 
   window.end();
___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2856: extend "fullscreen" test app for verifying screens and workarea

2012-06-17 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Pending]

Link: http://www.fltk.org/str.php?L2856
Version: 1.3-feature
Fix Version: 1.3-current (r9605)


Ok now, thanks for applying my patch.


Link: http://www.fltk.org/str.php?L2856
Version: 1.3-feature
Fix Version: 1.3-current (r9605)

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2644: Horizontal wheel movement on X11 and Win32

2012-06-19 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2644
Version: 1.4-feature


Can we re-consider this patch for 1.3.x? The patch is small and clean, and
it still applies cleanly to the latest trunk.


Link: http://www.fltk.org/str.php?L2644
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2599: expose dead keys to applications

2012-06-19 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2599
Version: 1.4-feature


Attached file "fltk-1_v6.3.x-keyboard-osx.patch"...


Link: http://www.fltk.org/str.php?L2599
Version: 1.4-featurediff -ur fltk-1.3.0r9619.org/configure.in fltk-1.3.0r9619/configure.in
--- fltk-1.3.0r9619.org/configure.in2012-04-22 04:45:09.0 +0200
+++ fltk-1.3.0r9619/configure.in2012-06-18 13:47:33.290447462 +0200
@@ -865,6 +865,8 @@
 Darwin*)
 # MacOS X uses Cocoa for graphics.
 LIBS="$LIBS -framework Cocoa"
+# And some Carbon for keyboard handling
+LIBS="$LIBS -framework Carbon"
 
if test x$have_pthread = xyes; then
AC_DEFINE(HAVE_PTHREAD)
diff -ur fltk-1.3.0r9619.org/src/Fl_cocoa.mm fltk-1.3.0r9619/src/Fl_cocoa.mm
--- fltk-1.3.0r9619.org/src/Fl_cocoa.mm 2012-06-16 10:49:52.0 +0200
+++ fltk-1.3.0r9619/src/Fl_cocoa.mm 2012-06-18 13:47:42.944910782 +0200
@@ -53,6 +53,7 @@
 #include 
 
 #import 
+#import 
 
 #ifndef NSINTEGER_DEFINED // appears with 10.5 in NSObjCRuntime.h
 #if defined(__LP64__) && __LP64__
@@ -114,6 +115,8 @@
 extern Fl_Window* fl_xmousewin;
 #endif
 
+bool use_simple_keyboard = false;
+
 enum { FLTKTimerEvent = 1, FLTKDataReadyEvent };
 
 
@@ -130,6 +133,39 @@
 {
 }
 
+// Undocumented voodoo. Taken from Mozilla.
+#define ENABLE_ROMAN_KYBDS_ONLY -23
+
+void fl_update_focus(void)
+{
+  Fl_Widget *focus;
+
+  focus = Fl::grab();
+  if (!focus)
+focus = Fl::focus();
+  if (!focus)
+return;
+
+  if (focus->simple_keyboard())
+use_simple_keyboard = true;
+  else
+use_simple_keyboard = false;
+
+  // Force a "Roman" or "ASCII" keyboard, which both the Mozilla and
+  // Safari people seem to think implies turning off advanced IME stuff
+  // (see nsTSMManager::SyncKeyScript in Mozilla and enableSecureTextInput
+  // in Safari/Webcore). Should be good enough for us then...
+#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
+  CFArrayRef inputSources = TISCreateASCIICapableInputSourceList();
+  TSMSetDocumentProperty(TSMGetActiveDocument(),
+ kTSMDocumentEnabledInputSourcesPropertyTag,
+ sizeof(CFArrayRef), &inputSources);
+  CFRelease(inputSources);
+#else
+  KeyScript(use_simple_keyboard ? ENABLE_ROMAN_KYBDS_ONLY : smKeyEnableKybds);
+#endif  
+}
+
 /*
  * Mac keyboard lookup table
  */
@@ -908,6 +944,25 @@
 }
 @end
 
+static const char* cocoaDead2FLTK(const char *in)
+{
+  if (strcmp(in, "\140") == 0)  // GRAVE ACCENT
+return "\314\200";  // COMBINING GRAVE ACCENT
+  if (strcmp(in, "\302\264") == 0)  // ACUTE ACCENT
+return "\314\201";  // COMBINING ACUTE ACCENT
+  if (strcmp(in, "\136") == 0)  // CIRCUMFLEX ACCENT
+return "\314\202";  // COMBINING CIRCUMFLEX ACCENT
+  if (strcmp(in, "\176") == 0)  // TILDE
+return "\314\203";  // COMBINING TILDE
+  if (strcmp(in, "\302\250") == 0)  // DIAERESIS
+return "\314\210";  // COMBINING DIAERESIS
+  // FIXME: OS X dead key behaviour isn't documented and I don't have
+  //any more keyboards to test with...
+
+  // hope that OS X gave us something proper to begin with
+  return in;
+}
+
 /*
 Handle cocoa keyboard events
 Events during a character composition sequence:
@@ -1648,6 +1703,7 @@
 - (void)rightMouseDragged:(NSEvent *)theEvent;
 - (void)otherMouseDragged:(NSEvent *)theEvent;
 - (void)scrollWheel:(NSEvent *)theEvent;
++ (NSString *)keyTranslate:(UInt16)keyCode 
withModifierFlags:(UInt32)modifierFlags;
 - (BOOL)handleKeyDown:(NSEvent *)theEvent;
 - (void)keyDown:(NSEvent *)theEvent;
 - (void)keyUp:(NSEvent *)theEvent;
@@ -1726,6 +1782,130 @@
 - (void)scrollWheel:(NSEvent *)theEvent {
   cocoaMouseWheelHandler(theEvent);
 }
++ (NSString *)keyTranslate:(UInt16)keyCode 
withModifierFlags:(UInt32)modifierFlags {
+  const UCKeyboardLayout *layout;
+  OSStatus err;
+
+  layout = NULL;
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
+  TISInputSourceRef keyboard;
+  CFDataRef uchr;
+
+  keyboard = TISCopyCurrentKeyboardInputSource();
+  uchr = (CFDataRef)TISGetInputSourceProperty(keyboard,
+  
kTISPropertyUnicodeKeyLayoutData);
+  if (uchr == NULL)
+return nil;
+
+  layout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
+#else
+  KeyboardLayoutRef old_layout;
+  int kind;
+
+  err = KLGetCurrentKeyboardLayout(&old_layout);
+  if (err != noErr)
+return nil;
+
+  err = KLGetKeyboardLayoutProperty(old_layout, kKLKind,
+(const void**)&kind);
+  if (err != noErr)
+return nil;
+
+  // Old, crufty layout format?
+  if (kind == kKLKCHRKind) {
+void *kchr_layout;
+
+UInt32 chars, state;
+char buf[3];
+
+unichar result[16];
+ByteCount in_len, out_len;
+
+err = KLGetKeyboardLayoutProperty(old_layout, kKLKCHRData,
+  

Re: [fltk.development] [RFE] STR #2599: expose dead keys to applications

2012-06-19 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2599
Version: 1.4-feature


Attached file "fltk-1_v4.3.x-keyboard-x11.patch"...


Link: http://www.fltk.org/str.php?L2599
Version: 1.4-featurediff -ur fltk-1.3.0r9619.org/FL/Fl_Widget.H fltk-1.3.0r9619/FL/Fl_Widget.H
--- fltk-1.3.0r9619.org/FL/Fl_Widget.H  2012-04-23 22:12:06.0 +0200
+++ fltk-1.3.0r9619/FL/Fl_Widget.H  2012-06-18 13:46:07.302320825 +0200
@@ -171,6 +171,7 @@
 GROUP_RELATIVE  = 1<<16,  ///< position this widget relative to the 
parent group, not to the window
 COPIED_TOOLTIP  = 1<<17,  ///< the widget tooltip is internally 
copied, its destruction is handled by the widget
 FULLSCREEN  = 1<<18,  ///< a fullscreen window (Fl_Window)
+SIMPLE_KEYBOARD = 1<<19,  ///< the widget wants simple, consistent 
keypresses and not advanced input (like character composition and CJK input)
 // (space for more flags)
 USERFLAG3   = 1<<29,  ///< reserved for 3rd party extensions
 USERFLAG2   = 1<<30,  ///< reserved for 3rd party extensions
@@ -776,6 +777,35 @@
*/
   void clear_changed() {flags_ &= ~CHANGED;}
 
+  /** 
+  Returns if the widget sees a simplified keyboard model or not.
+
+  Normally widgets get a full-featured keyboard model that is geared
+  towards text input. This includes support for compose sequences and
+  advanced input methods, commonly used for asian writing system. This
+  system however has downsides in that extra graphic can be presented
+  to the user and that a physical key press doesn't correspond directly
+  to a FLTK event.
+
+  Widgets that need a direct correspondence between actual key events
+  and those seen by the widget can swith to the simplified keyboard
+  model.
+
+ \retval 0 if the widget uses the normal keyboard model
+ \see set_changed(), clear_changed()
+   */
+  unsigned int simple_keyboard() const {return flags_&SIMPLE_KEYBOARD;}
+
+  /** Marks a widget to use the simple keyboard model.
+  \see changed(), clear_changed()
+   */
+  void set_simple_keyboard() {flags_ |= SIMPLE_KEYBOARD;}
+
+  /** Marks a widget to use the normal keyboard model.
+  \see changed(), set_changed()
+   */
+  void set_normal_keyboard() {flags_ &= ~SIMPLE_KEYBOARD;}
+
   /** Gives the widget the keyboard focus.
   Tries to make this widget be the Fl::focus() widget, by first sending 
   it an FL_FOCUS event, and if it returns non-zero, setting 
diff -ur fltk-1.3.0r9619.org/src/Fl.cxx fltk-1.3.0r9619/src/Fl.cxx
--- fltk-1.3.0r9619.org/src/Fl.cxx  2012-03-23 17:47:53.0 +0100
+++ fltk-1.3.0r9619/src/Fl.cxx  2012-06-18 13:46:07.303320877 +0200
@@ -70,6 +70,8 @@
 extern double fl_mac_flush_and_wait(double time_to_wait, char in_idle);
 #endif // WIN32
 
+extern void fl_update_focus(void);
+
 //
 // Globals...
 //
@@ -876,6 +878,8 @@
   fl_oldfocus = p;
 }
 e_number = old_event;
+// let the platform code do what it needs
+fl_update_focus();
   }
 }
 
diff -ur fltk-1.3.0r9619.org/src/Fl_grab.cxx fltk-1.3.0r9619/src/Fl_grab.cxx
--- fltk-1.3.0r9619.org/src/Fl_grab.cxx 2012-03-23 17:47:53.0 +0100
+++ fltk-1.3.0r9619/src/Fl_grab.cxx 2012-06-18 13:46:07.303320877 +0200
@@ -29,6 +29,7 @@
 // override_redirect, it does similar things on WIN32.
 
 extern void fl_fix_focus(); // in Fl.cxx
+void fl_update_focus(void);
 
 #ifdef WIN32
 // We have to keep track of whether we have captured the mouse, since
@@ -80,6 +81,7 @@
 #endif
 }
 grab_ = win;
+fl_update_focus();
   } else {
 if (grab_) {
 #ifdef WIN32
@@ -98,6 +100,7 @@
   XFlush(fl_display);
 #endif
   grab_ = 0;
+  fl_update_focus();
   fl_fix_focus();
 }
   }
diff -ur fltk-1.3.0r9619.org/src/Fl_x.cxx fltk-1.3.0r9619/src/Fl_x.cxx
--- fltk-1.3.0r9619.org/src/Fl_x.cxx2012-06-18 13:46:07.205316173 +0200
+++ fltk-1.3.0r9619/src/Fl_x.cxx2012-06-18 13:46:18.216844629 +0200
@@ -298,6 +298,7 @@
 Colormap fl_colormap;
 XIM fl_xim_im = 0;
 XIC fl_xim_ic = 0;
+Window fl_xim_win = 0;
 char fl_is_over_the_spot = 0;
 static XRectangle status_area;
 
@@ -583,6 +584,65 @@
   if(xim_styles) XFree(xim_styles);
 }
 
+void fl_xim_deactivate(void);
+
+void fl_xim_activate(Window xid)
+{
+  if (!fl_xim_im)
+return;
+
+  // If the focused window has changed, then use the brute force method
+  // of completely recreating the input context.
+  if (fl_xim_win != xid) {
+fl_xim_deactivate();
+
+fl_new_ic();
+fl_xim_win = xid;
+
+XSetICValues(fl_xim_ic,
+ XNFocusWindow, fl_xim_win,
+ XNClientWindow, fl_xim_win,
+ NULL);
+  }
+
+  fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
+}
+
+void fl_xim_deactivate(void)
+{
+  if (!fl_xim_ic)
+return;
+
+  XDestroyIC(fl_xim_ic);
+  fl_xim_ic = NULL;
+
+  fl_xim_win = 0;
+}
+
+extern Fl_Win

Re: [fltk.development] [RFE] STR #2599: expose dead keys to applications

2012-06-19 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2599
Version: 1.4-feature


Attached file "fltk-1_v4.3.x-keyboard-win32.patch"...


Link: http://www.fltk.org/str.php?L2599
Version: 1.4-featurediff -ur fltk-1.3.0r9293.org/src/Fl_win32.cxx fltk-1.3.0r9293/src/Fl_win32.cxx
--- fltk-1.3.0r9293.org/src/Fl_win32.cxx2012-06-18 09:07:56.522314557 
+0200
+++ fltk-1.3.0r9293/src/Fl_win32.cxx2012-06-18 09:08:07.392836285 +0200
@@ -87,6 +87,8 @@
 static Fl_Display_Device fl_gdi_display(&fl_gdi_driver);
 Fl_Display_Device *Fl_Display_Device::_display = &fl_gdi_display; // the 
platform display
 
+bool use_simple_keyboard = false;
+
 // dynamic wsock dll handling api:
 #if defined(__CYGWIN__) && !defined(SOCKET)
 # define SOCKET int
@@ -120,6 +122,8 @@
  * size and link dependencies.
  */
 static HMODULE s_imm_module = 0;
+typedef BOOL (WINAPI* flTypeImmAssociateContextEx)(HWND, HIMC, DWORD);
+static flTypeImmAssociateContextEx flImmAssociateContextEx = 0;
 typedef HIMC (WINAPI* flTypeImmGetContext)(HWND);
 static flTypeImmGetContext flImmGetContext = 0;
 typedef BOOL (WINAPI* flTypeImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
@@ -135,6 +139,7 @@
 if (!s_imm_module)
   Fl::fatal("FLTK Lib Error: IMM32.DLL file not found!\n\n"
 "Please check your input method manager library accessibility.");
+flImmAssociateContextEx = 
(flTypeImmAssociateContextEx)GetProcAddress(s_imm_module, 
"ImmAssociateContextEx");
 flImmGetContext = (flTypeImmGetContext)GetProcAddress(s_imm_module, 
"ImmGetContext");
 flImmSetCompositionWindow = 
(flTypeImmSetCompositionWindow)GetProcAddress(s_imm_module, 
"ImmSetCompositionWindow");
 flImmReleaseContext = 
(flTypeImmReleaseContext)GetProcAddress(s_imm_module, "ImmReleaseContext");
@@ -413,7 +418,12 @@
 }
   }
 
-  TranslateMessage(&fl_msg);
+  // Don't bother with key to character translation as we do
+  // it manually for simpley keyboard widgets. In fact, calling
+  // TranslateMessage() just makes it more difficult as it sets
+  // a bunch of internal state.
+  if (!use_simple_keyboard)
+TranslateMessage(&fl_msg);
   DispatchMessageW(&fl_msg);
   have_message = PeekMessageW(&fl_msg, NULL, 0, 0, PM_REMOVE);
 }
@@ -638,6 +648,49 @@
   }
 }
 
+void fl_update_focus(void)
+{
+  Fl_Widget *focus;
+  Fl_Window *win;
+
+  get_imm_module();
+
+  focus = Fl::grab();
+  if (!focus)
+focus = Fl::focus();
+  if (!focus)
+return;
+
+  // Grabs are special in that events are sent to the first
+  // available window
+  if (focus == Fl::grab())
+win = Fl::first_window();
+  else {
+win = focus->as_window();
+if (!win)
+  win = focus->window();
+  }
+
+  if (!win) {
+Fl::warning("Cannot find window for widget receiving focus");
+return;
+  }
+
+  // No Win32 window created yet
+  if (!Fl_X::i(win) || !fl_xid(win))
+return;
+
+  if (focus->simple_keyboard()) {
+use_simple_keyboard = true;
+if (flImmGetContext(fl_xid(win)) != 0)
+  flImmAssociateContextEx(fl_xid(win), 0, 0);
+  } else {
+use_simple_keyboard = false;
+if (flImmGetContext(fl_xid(win)) == 0)
+  flImmAssociateContextEx(fl_xid(win), 0, IACE_DEFAULT);
+  }
+}
+
 HWND fl_capture;
 
 static int mouse_event(Fl_Window *window, int what, int button,
@@ -785,6 +838,27 @@
   return extended ? extendedlut[vk] : vklut[vk];
 }
 
+static xchar msdead2fltk(xchar in)
+{
+  switch (in) {
+  case 0x0060:  // GRAVE ACCENT
+return 0x0300;  // COMBINING GRAVE ACCENT
+  case 0x00b4:  // ACUTE ACCENT
+return 0x0301;  // COMBINING ACUTE ACCENT
+  case 0x005e:  // CIRCUMFLEX ACCENT
+return 0x0302;  // COMBINING CIRCUMFLEX ACCENT
+  case 0x007e:  // TILDE
+return 0x0303;  // COMBINING TILDE
+  case 0x00a8:  // DIAERESIS
+return 0x0308;  // COMBINING DIAERESIS
+  // FIXME: Windows dead key behaviour isn't documented and I don't have
+  //any more keyboards to test with...
+  }
+
+  // hope that Windows gave us something proper to begin with
+  return in;
+}
+
 #if USE_COLORMAP
 extern HPALETTE fl_select_palette(void); // in fl_color_win32.cxx
 #endif
@@ -846,6 +920,8 @@
   //fl_msg.pt = ???
   //fl_msg.lPrivate = ???
 
+  MSG fl_orig_msg = fl_msg;
+
   Fl_Window *window = fl_find(hWnd);
 
   if (window) switch (uMsg) {
@@ -1025,23 +1101,82 @@
 if (GetKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK;
 Fl::e_state = state;
 static char buffer[1024];
-if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) {
 
+if (use_simple_keyboard) {
+  BYTE keystate[256];
+  WCHAR wbuf[8];
+  int ret;
+
+  // I'm not sure if we ever get WM_CHAR (& friends) without an initial
+  // WM_KEYDOWN (& friends), but if we do then we should not send such
+  // side band events to simple keyboard widgets.
+  if ((fl_orig_msg.message != WM_KEYDOWN) &&
+  (fl_orig_msg.message != 

Re: [fltk.development] [RFE] STR #2599: expose dead keys to applications

2012-06-19 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2599
Version: 1.4-feature


Posted updated patches, which applies to latest trunk. 

My suggestion is that we reconsider them for the 1.3.x branch.


Link: http://www.fltk.org/str.php?L2599
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-06-19 Thread Peter Åstrand
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.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -up fltk-1.3.x-r8659/FL/Fl.H.orig fltk-1.3.x-r8659/FL/Fl.H
--- fltk-1.3.x-r8659/FL/Fl.H.orig   2011-05-17 16:25:56.671744548 +0200
+++ fltk-1.3.x-r8659/FL/Fl.H2011-05-17 16:26:05.709101536 +0200
@@ -108,6 +108,9 @@ typedef int (*Fl_Args_Handler)(int argc,
 \see Fl::event_dispatch(Fl_Event_Dispatch) */
 typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
 
+/** Signature of add_clipboard_notify functions passed as parameters */
+typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data);
+
 /** @} */ /* group callback_functions */
 
 
@@ -744,6 +747,19 @@ public:
   */
   static void paste(Fl_Widget &receiver, int source /*=0*/); // platform 
dependent
   /**
+  FLTK will call the registered callback whenever there is a change to the
+  selection buffer or the clipboard. The source argument indicates which
+  of the two has changed. Only changes by other applications are reported.
+  \note Some systems require polling to monitor the clipboard and may
+  therefore have some delay in detecting changes.
+  */
+  static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data);
+  /**
+  Stop calling the specified callback when there are changes to the selection
+  buffer or the clipboard.
+  */
+  static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h);
+  /**
 Initiate a Drag And Drop operation. The selection buffer should be
 filled with relevant data before calling this method. FLTK will
 then initiate the system wide drag and drop handling. Dropped data
diff -up fltk-1.3.x-r8659/src/Fl.cxx.orig fltk-1.3.x-r8659/src/Fl.cxx
--- fltk-1.3.x-r8659/src/Fl.cxx.orig2011-05-18 15:20:26.667291459 +0200
+++ fltk-1.3.x-r8659/src/Fl.cxx 2011-05-18 16:31:15.522026086 +0200
@@ -430,6 +430,69 @@ static char in_idle;
 #endif
 
 
+// Clipboard notifications
+
+struct Clipboard_Notify {
+  Fl_Clipboard_Notify_Handler handler;
+  void *data;
+  struct Clipboard_Notify *next;
+};
+
+static struct Clipboard_Notify *clip_notify_list = NULL;
+
+extern void fl_clipboard_notify_change(); // in Fl_.cxx
+
+void Fl::add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data) {
+  struct Clipboard_Notify *node;
+
+  remove_clipboard_notify(h);
+
+  node = new Clipboard_Notify;
+
+  node->handler = h;
+  node->data = data;
+  node->next = clip_notify_list;
+
+  clip_notify_list = node;
+
+  fl_clipboard_notify_change();
+}
+
+void Fl::remove_clipboard_notify(Fl_Clipboard_Notify_Handler h) {
+  struct Clipboard_Notify *node, **prev;
+
+  node = clip_notify_list;
+  prev = &clip_notify_list;
+  while (node != NULL) {
+if (node->handler == h) {
+  *prev = node->next;
+  delete node;
+
+  fl_clipboard_notify_change();
+
+  return;
+}
+
+prev = &node->next;
+node = node->next;
+  }
+}
+
+bool fl_clipboard_notify_empty(void) {
+  return clip_notify_list == NULL;
+}
+
+void fl_trigger_clipboard_notify(int source) {
+  struct Clipboard_Notify *node;
+
+  node = clip_notify_list;
+  while (node != NULL) {
+node->handler(source, node->data);
+node = node->next;
+  }
+}
+
+
 // wait/run/check/ready:
 
 void (*Fl::idle)(); // see Fl::add_idle.cxx for the add/remove functions
___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-06-19 Thread Peter Åstrand
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-x11.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -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-17 16:37:11.092011814 +0200
+++ fltk-1.3.x-r8659/src/Fl_x.cxx   2011-05-18 13:51:06.135475325 +0200
@@ -309,6 +309,9 @@ static Atom WM_PROTOCOLS;
 static Atom fl_MOTIF_WM_HINTS;
 static Atom TARGETS;
 static Atom CLIPBOARD;
+static Atom TIMESTAMP;
+static Atom PRIMARY_TIMESTAMP;
+static Atom CLIPBOARD_TIMESTAMP;
 Atom fl_XdndAware;
 Atom fl_XdndSelection;
 Atom fl_XdndEnter;
@@ -678,6 +681,9 @@ void fl_open_display(Display* d) {
   fl_MOTIF_WM_HINTS = XInternAtom(d, "_MOTIF_WM_HINTS", 0);
   TARGETS   = XInternAtom(d, "TARGETS", 0);
   CLIPBOARD = XInternAtom(d, "CLIPBOARD",   0);
+  TIMESTAMP = XInternAtom(d, "TIMESTAMP",   0);
+  PRIMARY_TIMESTAMP = XInternAtom(d, "PRIMARY_TIMESTAMP",   0);
+  CLIPBOARD_TIMESTAMP   = XInternAtom(d, "CLIPBOARD_TIMESTAMP", 0);
   fl_XdndAware  = XInternAtom(d, "XdndAware",   0);
   fl_XdndSelection  = XInternAtom(d, "XdndSelection",   0);
   fl_XdndEnter  = XInternAtom(d, "XdndEnter",   0);
@@ -861,6 +881,86 @@ void Fl::copy(const char *stuff, int len
 }
 
 
+// Code for tracking clipboard changes:
+
+static Time primary_timestamp = -1;
+static Time clipboard_timestamp = -1;
+
+extern bool fl_clipboard_notify_empty(void);
+extern void fl_trigger_clipboard_notify(int source);
+
+static void poll_clipboard_owner(void) {
+  Window xid;
+
+  // No one is interested, so no point polling
+  if (fl_clipboard_notify_empty())
+return;
+
+  // We need a window for this to work
+  if (!Fl::first_window())
+return;
+  xid = fl_xid(Fl::first_window());
+  if (!xid)
+return;
+
+  // Request an update of the selection time for both the primary and
+  // clipboard selections. Magic continues when we get a SelectionNotify.
+  if (!fl_i_own_selection[0])
+XConvertSelection(fl_display, XA_PRIMARY, TIMESTAMP, PRIMARY_TIMESTAMP,
+  xid, fl_event_time);
+  if (!fl_i_own_selection[1])
+XConvertSelection(fl_display, CLIPBOARD, TIMESTAMP, CLIPBOARD_TIMESTAMP,
+  xid, fl_event_time);
+}
+
+static void clipboard_timeout(void *data)
+{
+  // No one is interested, so stop polling
+  if (fl_clipboard_notify_empty())
+return;
+
+  poll_clipboard_owner();
+
+  Fl::repeat_timeout(0.5, clipboard_timeout);
+}
+
+static void handle_clipboard_timestamp(int clipboard, Time time)
+{
+  Time *timestamp;
+
+  timestamp = clipboard ? &clipboard_timestamp : &primary_timestamp;
+
+  // Initial scan, just store the value
+  if (*timestamp == (Time)-1) {
+*timestamp = time;
+return;
+  }
+
+  // Same selection
+  if (time == *timestamp)
+return;
+
+  *timestamp = time;
+
+  // Something happened! Let's tell someone!
+  fl_trigger_clipboard_notify(clipboard);
+}
+
+void fl_clipboard_notify_change() {
+  // Reset the timestamps if we've going idle so that you don't
+  // get a bogus immediate trigger next time they're activated.
+  if (fl_clipboard_notify_empty()) {
+primary_timestamp = -1;
+clipboard_timestamp = -1;
+  } else {
+poll_clipboard_owner();
+
+if (!Fl::has_timeout(clipboard_timeout))
+  Fl::add_timeout(0.5, clipboard_timeout);
+  }
+}
+
+
 
 const XEvent* fl_xevent; // the current x event
 ulong fl_event_time; // the last timestamp from an x event
@@ -976,7 +1102,6 @@ int fl_handle(const XEvent& thisevent)
 return 0;
 
   case SelectionNotify: {
-if (!fl_selection_requestor) return 0;
 static unsigned char* buffer = 0;
 if (buffer) {XFree(buffer); buffer = 0;}
 long bytesread = 0;
@@ -992,6 +1117,19 @@ int fl_handle(const XEvent& thisevent)
  bytesread/4, 65536, 1, 0,
  &actual, &format, &count, &remaining,
  &portion)) break; // quit on error
+
+  if ((fl_xevent->xselection.property == PRIMARY_TIMESTAMP) ||
+  (fl_xevent->xselection.property == CLIPBOARD_TIMESTAMP)) {
+if (portion && format == 32 && count == 1) {
+  Time t = *(unsigned int*)portion;
+  if (fl_xevent->xselection.property == CLIPBOARD_TIMESTAMP)
+handle_clipboard_timestamp(1, t);
+  else
+handle_clipboard_timestamp(0, t);
+}
+return true;
+  }
+
   if (actual == TARGETS || actual == XA_ATOM) {
Atom type = XA_STRING;
for (unsigned i = 0; ixselectionclear.selection == CLIPBOARD;
 fl_i_own_selection[clipboard] = 

Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-06-19 Thread Peter Åstrand
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_v3.3.x-clipboard-xfixes.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -ur fltk-1.3.0r9619.org/configh.in fltk-1.3.0r9619/configh.in
--- fltk-1.3.0r9619.org/configh.in  2011-10-04 11:21:47.0 +0200
+++ fltk-1.3.0r9619/configh.in  2012-06-18 16:14:05.012277003 +0200
@@ -108,6 +108,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 -ur fltk-1.3.0r9619.org/configure.in fltk-1.3.0r9619/configure.in
--- fltk-1.3.0r9619.org/configure.in2012-06-18 16:13:38.744017220 +0200
+++ fltk-1.3.0r9619/configure.in2012-06-18 16:14:05.013277050 +0200
@@ -999,6 +999,16 @@
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 ])
+   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 -ur fltk-1.3.0r9619.org/src/Fl_x.cxx fltk-1.3.0r9619/src/Fl_x.cxx
--- fltk-1.3.0r9619.org/src/Fl_x.cxx2012-06-18 16:13:38.749017460 +0200
+++ fltk-1.3.0r9619/src/Fl_x.cxx2012-06-18 16:13:24.0 +0200
@@ -53,6 +53,12 @@
 static int randrEventBase;  // base of RandR-defined events
 #endif
 
+#  ifdef HAVE_XFIXES
+#  include 
+static int xfixes_event_base = 0;
+static bool have_xfixes = false;
+#  endif
+
 static Fl_Xlib_Graphics_Driver fl_xlib_driver;
 static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
 Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the 
platform display
@@ -197,6 +203,14 @@
 Fl::handle(FL_MOVE, fl_xmousewin);
   }
 #endif
+
+#ifdef HAVE_XFIXES
+  int error_base;
+  if (XFixesQueryExtension(fl_display, &xfixes_event_base, &error_base))
+have_xfixes = true;
+  else
+have_xfixes = false;
+#endif
 }
 
 // these pointers are set by the Fl::lock() function:
@@ -917,6 +931,10 @@
 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;
@@ -955,10 +973,12 @@
 
   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
@@ -978,10 +998,12 @@
 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);
+}
   }
 }
 
@@ -1780,6 +1802,25 @@
 }
   }
 
+#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);
 }
 
@@ -2100,6 +2141,16 @@
 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:/

Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-06-19 Thread Peter Åstrand
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_v3.3.x-clipboard-win32-fix.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -ur fltk-1.3.0r9110.org/src/Fl_win32.cxx fltk-1.3.0r9110/src/Fl_win32.cxx
--- fltk-1.3.0r9110.org/src/Fl_win32.cxx2012-06-17 19:42:02.169422400 
+0200
+++ fltk-1.3.0r9110/src/Fl_win32.cxx2012-06-17 19:43:38.286031455 +0200
@@ -543,6 +543,37 @@
   const char* GetValue() const { return(out); }
 };
 
+void fl_update_clipboard(void) {
+  Fl_Window *w1 = Fl::first_window();
+  if (!w1)
+return;
+
+  HWND hwnd = fl_xid(w1);
+
+  if (!OpenClipboard(hwnd))
+return;
+
+  EmptyClipboard();
+
+  int utf16_len = fl_utf8toUtf16(fl_selection_buffer[1],
+ fl_selection_length[1], 0, 0);
+
+  HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and zero'ed 
mem alloc.
+  LPVOID memLock = GlobalLock(hMem);
+
+  fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1],
+ (unsigned short*) memLock, utf16_len + 1);
+
+  GlobalUnlock(hMem);
+  SetClipboardData(CF_UNICODETEXT, hMem);
+
+  CloseClipboard();
+
+  // In case Windows managed to lob of a WM_DESTROYCLIPBOARD during
+  // the above.
+  fl_i_own_selection[1] = 1;
+}
+
 // call this when you create a selection:
 void Fl::copy(const char *stuff, int len, int clipboard) {
   if (!stuff || len<0) return;
@@ -560,25 +591,9 @@
   memcpy(fl_selection_buffer[clipboard], stuff, len);
   fl_selection_buffer[clipboard][len] = 0; // needed for direct paste
   fl_selection_length[clipboard] = len;
-  if (clipboard) {
-// set up for "delayed rendering":
-if (OpenClipboard(NULL)) {
-  // if the system clipboard works, use it
-  int utf16_len = fl_utf8toUtf16(fl_selection_buffer[clipboard], 
fl_selection_length[clipboard], 0, 0);
-  EmptyClipboard();
-  HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and 
zero'ed mem alloc.
-  LPVOID memLock = GlobalLock(hMem);
-  fl_utf8toUtf16(fl_selection_buffer[clipboard], 
fl_selection_length[clipboard], (unsigned short*) memLock, utf16_len + 1);
-  GlobalUnlock(hMem);
-  SetClipboardData(CF_UNICODETEXT, hMem);
-  CloseClipboard();
-  GlobalFree(hMem);
-  fl_i_own_selection[clipboard] = 0;
-} else {
-  // only if it fails, instruct paste() to use the internal buffers
-  fl_i_own_selection[clipboard] = 1;
-}
-  }
+  fl_i_own_selection[clipboard] = 1;
+  if (clipboard)
+fl_update_clipboard();
 }
 
 // Call this when a "paste" operation happens:
@@ -1307,33 +1322,6 @@
 fl_i_own_selection[1] = 0;
 return 1;
 
-  case WM_RENDERALLFORMATS:
-fl_i_own_selection[1] = 0;
-// Windoze seems unhappy unless I do these two steps. Documentation
-// seems to vary on whether opening the clipboard is necessary or
-// is in fact wrong:
-CloseClipboard();
-OpenClipboard(NULL);
-// fall through...
-  case WM_RENDERFORMAT: {
-HANDLE h;
-
-//  int l = fl_utf_nb_char((unsigned char*)fl_selection_buffer[1], 
fl_selection_length[1]);
-int l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], 
NULL, 0); // Pass NULL buffer to query length required
-h = GlobalAlloc(GHND, (l+1) * sizeof(unsigned short));
-if (h) {
-  unsigned short *g = (unsigned short*) GlobalLock(h);
-//fl_utf2unicode((unsigned char *)fl_selection_buffer[1], 
fl_selection_length[1], (xchar*)g);
-  l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], g, 
(l+1));
-  g[l] = 0;
-  GlobalUnlock(h);
-  SetClipboardData(CF_UNICODETEXT, h);
-}
-
-// Windoze also seems unhappy if I don't do this. Documentation very
-// unclear on what is correct:
-if (fl_msg.message == WM_RENDERALLFORMATS) CloseClipboard();
-return 1;}
   case WM_DISPLAYCHANGE: // occurs when screen configuration (number, 
position) changes
 Fl::call_screen_init();
 Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL);
diff -ur fltk-1.3.0r9110.org/src/Fl.cxx fltk-1.3.0r9110/src/Fl.cxx
--- fltk-1.3.0r9110.org/src/Fl.cxx  2012-06-17 19:42:02.173422595 +0200
+++ fltk-1.3.0r9110/src/Fl.cxx  2012-06-17 19:42:02.317429497 +0200
@@ -1420,7 +1420,9 @@
 
 // hide() destroys the X window, it does not do unmap!
 
-#if !defined(WIN32) && USE_XFT
+#if defined(WIN32)
+extern void fl_update_clipboard(void);
+#elif USE_XFT
 extern void fl_destroy_xft_draw(Window);
 #endif
 
@@ -1467,14 +1469,8 @@
 #if defined(WIN32)
   // this little trick keeps the current clipboard alive, even if we are about
   // to destroy the window that owns the selection.
-  if (GetClipboardOwner()==ip->xid) {
-Fl_Window *w1 = Fl::first_window();
-if (w1 && OpenClipboard(fl_xid(w1))) {
-  EmptyClipboard();
-  SetClipboardData(CF_TEXT, NULL

Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-06-19 Thread Peter Åstrand
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-win32.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -ur fltk-1.3.0r9110.org/src/Fl.cxx fltk-1.3.0r9110/src/Fl.cxx
--- fltk-1.3.0r9110.org/src/Fl.cxx  2012-06-17 19:47:09.988183253 +0200
+++ fltk-1.3.0r9110/src/Fl.cxx  2012-06-17 19:47:10.127189919 +0200
@@ -1421,6 +1421,7 @@
 // hide() destroys the X window, it does not do unmap!
 
 #if defined(WIN32)
+extern void fl_clipboard_notify_untarget(HWND wnd);
 extern void fl_update_clipboard(void);
 #elif USE_XFT
 extern void fl_destroy_xft_draw(Window);
@@ -1471,6 +1472,8 @@
   // to destroy the window that owns the selection.
   if (GetClipboardOwner()==ip->xid)
 fl_update_clipboard();
+  // Make sure we unlink this window from the clipboard chain
+  fl_clipboard_notify_untarget(ip->xid);
   // Send a message to myself so that I'll get out of the event loop...
   PostMessage(ip->xid, WM_APP, 0, 0);
   if (ip->private_dc) fl_release_dc(ip->xid, ip->private_dc);
diff -ur fltk-1.3.0r9110.org/src/Fl_win32.cxx fltk-1.3.0r9110/src/Fl_win32.cxx
--- fltk-1.3.0r9110.org/src/Fl_win32.cxx2012-06-17 19:47:09.987183205 
+0200
+++ fltk-1.3.0r9110/src/Fl_win32.cxx2012-06-17 19:47:19.069618739 +0200
@@ -646,6 +646,38 @@
   }
 }
 
+static HWND clipboard_wnd = 0;
+static HWND next_clipboard_wnd = 0;
+
+static bool initial_clipboard = true;
+
+void fl_clipboard_notify_change() {
+  // No need to do anything here...
+}
+
+void fl_clipboard_notify_target(HWND wnd) {
+  if (clipboard_wnd)
+return;
+
+  // We get one fake WM_DRAWCLIPBOARD immediately, which we therefore
+  // need to ignore.
+  initial_clipboard = true;
+
+  clipboard_wnd = wnd;
+  next_clipboard_wnd = SetClipboardViewer(wnd);
+}
+
+void fl_clipboard_notify_untarget(HWND wnd) {
+  if (wnd != clipboard_wnd)
+return;
+
+  ChangeClipboardChain(wnd, next_clipboard_wnd);
+  clipboard_wnd = next_clipboard_wnd = 0;
+
+  if (Fl::first_window())
+fl_clipboard_notify_target(fl_xid(Fl::first_window()));
+}
+
 
 char fl_is_ime = 0;
 void fl_get_codepage()
@@ -1327,6 +1359,27 @@
 Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL);
 return 0;
 
+  case WM_CHANGECBCHAIN:
+if ((hWnd == clipboard_wnd) &&
+(next_clipboard_wnd == (HWND)wParam)) {
+  next_clipboard_wnd = (HWND)lParam;
+  return 0;
+}
+break;
+
+  case WM_DRAWCLIPBOARD:
+// When the clipboard moves between two FLTK windows,
+// fl_i_own_selection will temporarily be false as we are
+// processing this message. Hence the need to use fl_find().
+if (!initial_clipboard && !fl_find(GetClipboardOwner()))
+  fl_trigger_clipboard_notify(1);
+initial_clipboard = false;
+
+if (next_clipboard_wnd)
+  SendMessage(next_clipboard_wnd, WM_DRAWCLIPBOARD, wParam, lParam);
+
+return 0;
+
   default:
 if (Fl::handle(0,0)) return 0;
 break;
@@ -1685,6 +1738,8 @@
   x->next = Fl_X::first;
   Fl_X::first = x;
 
+  fl_clipboard_notify_target(x->xid);
+
   x->wait_for_expose = 1;
   if (fl_show_iconic) {showit = 0; fl_show_iconic = 0;}
   if (showit) {
___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-06-19 Thread Peter Åstrand
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-osx.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -bur fltk-1.3.0r9619.org/src/Fl_cocoa.mm fltk-1.3.0r9619/src/Fl_cocoa.mm
--- fltk-1.3.0r9619.org/src/Fl_cocoa.mm 2012-06-18 19:24:30.971688769 +0200
+++ fltk-1.3.0r9619/src/Fl_cocoa.mm 2012-06-18 19:25:25.700310375 +0200
@@ -1319,9 +1319,13 @@
 }
 @end
 
+static void clipboard_check(void);
+
 @implementation FLApplication
 + (void)sendEvent:(NSEvent *)theEvent
 {
+  // update clipboard status
+  clipboard_check();
   NSEventType type = [theEvent type];  
   if (type == NSLeftMouseDown) {
 fl_lock_function();
@@ -2790,6 +2794,26 @@
 PasteboardCreate(kPasteboardClipboard, &myPasteboard);
 }
 
+extern void fl_trigger_clipboard_notify(int source);
+
+void fl_clipboard_notify_change() {
+  // No need to do anything here...
+}
+
+static void clipboard_check(void)
+{
+  PasteboardSyncFlags flags;
+
+  allocatePasteboard();
+  flags = PasteboardSynchronize(myPasteboard);
+
+  if (!(flags & kPasteboardModified))
+return;
+  if (flags & kPasteboardClientIsOwner)
+return;
+
+  fl_trigger_clipboard_notify(1);
+}
 
 /*
  * create a selection
___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-06-19 Thread Peter Åstrand

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


Updated patches for latest trunk. Suggesting that we consider them for
1.3.x.


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2659: support conversion from Fl_Pixmap to Fl_RGB_Image

2012-06-19 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2659
Version: 1.4-feature


Attached file "fltk-1_v2.3.x-pixmap.patch"...


Link: http://www.fltk.org/str.php?L2659
Version: 1.4-featurediff -ur fltk-1.3.0r9619.org/src/Fl_Image.cxx fltk-1.3.0r9619/src/Fl_Image.cxx
--- fltk-1.3.0r9619.org/src/Fl_Image.cxx2012-03-18 19:48:29.0 
+0100
+++ fltk-1.3.0r9619/src/Fl_Image.cxx2012-06-18 15:53:37.058387483 +0200
@@ -163,6 +163,19 @@
 //
 // RGB image class...
 //
+
+int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg);
+
+/** The constructor creates a new RGBA image from the specified Fl_Pixmap. */
+Fl_RGB_Image::Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg):
+  Fl_Image(pxm->w(), pxm->h(), 4), id_(0), mask_(0)
+{
+  array = new uchar[w() * h() * d()];
+  alloc_array = 1;
+  fl_convert_pixmap(pxm->data(), (uchar*)array, bg);
+  data((const char **)&array, 1);
+}
+
 /**  The destructor free all memory and server resources that are used by  the 
image. */
 Fl_RGB_Image::~Fl_RGB_Image() {
   uncache();
diff -ur fltk-1.3.0r9619.org/FL/Fl_Image.H fltk-1.3.0r9619/FL/Fl_Image.H
--- fltk-1.3.0r9619.org/FL/Fl_Image.H   2012-06-13 19:47:03.0 +0200
+++ fltk-1.3.0r9619/FL/Fl_Image.H   2012-06-18 15:53:51.176064518 +0200
@@ -25,6 +25,7 @@
 #  include "Enumerations.H"
 
 class Fl_Widget;
+class Fl_Pixmap;
 struct Fl_Menu_Item;
 struct Fl_Label;
 
@@ -201,6 +202,7 @@
   */
   Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
 Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) 
{data((const char **)&array, 1); ld(LD);}
+  Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
   virtual ~Fl_RGB_Image();
   virtual Fl_Image *copy(int W, int H);
   Fl_Image *copy() { return copy(w(), h()); }
diff -ur fltk-1.3.0r9619.org/src/fl_draw_pixmap.cxx 
fltk-1.3.0r9619/src/fl_draw_pixmap.cxx
--- fltk-1.3.0r9619.org/src/fl_draw_pixmap.cxx  2012-04-22 05:09:31.0 
+0200
+++ fltk-1.3.0r9619/src/fl_draw_pixmap.cxx  2012-06-18 15:54:07.656854873 
+0200
@@ -58,99 +58,6 @@
   return 1;
 }
 
-#ifdef U64
-
-// The callback from fl_draw_image to get a row of data passes this:
-struct pixmap_data {
-  int w, h;
-  const uchar*const* data;
-  union {
-U64 colors[256];
-U64* byte1[256];
-  };
-};
-
-// callback for 1 byte per pixel:
-static void cb1(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+x;
-  U64* q = (U64*)buf;
-  for (int X=w; X>0; X-=2, p += 2) {
-if (X>1) {
-#  if WORDS_BIGENDIAN
-  *q++ = (d.colors[p[0]]<<32) | d.colors[p[1]];
-#  else
-  *q++ = (d.colors[p[1]]<<32) | d.colors[p[0]];
-#  endif
-} else {
-#  if WORDS_BIGENDIAN
-  *q++ = d.colors[p[0]]<<32;
-#  else
-  *q++ = d.colors[p[0]];
-#  endif
-}
-  }
-}
-
-// callback for 2 bytes per pixel:
-static void cb2(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+2*x;
-  U64* q = (U64*)buf;
-  for (int X=w; X>0; X-=2) {
-U64* colors = d.byte1[*p++];
-int index = *p++;
-if (X>1) {
-  U64* colors1 = d.byte1[*p++];
-  int index1 = *p++;
-#  if WORDS_BIGENDIAN
-  *q++ = (colors[index]<<32) | colors1[index1];
-#  else
-  *q++ = (colors1[index1]<<32) | colors[index];
-#  endif
-} else {
-#  if WORDS_BIGENDIAN
-  *q++ = colors[index]<<32;
-#  else
-  *q++ = colors[index];
-#  endif
-}
-  }
-}
-
-#else // U32
-
-// The callback from fl_draw_image to get a row of data passes this:
-struct pixmap_data {
-  int w, h;
-  const uchar*const* data;
-  union {
-U32 colors[256];
-U32* byte1[256];
-  };
-};
-
-// callback for 1 byte per pixel:
-static void cb1(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+x;
-  U32* q = (U32*)buf;
-  for (int X=w; X--;) *q++ = d.colors[*p++];
-}
-
-// callback for 2 bytes per pixel:
-static void cb2(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+2*x;
-  U32* q = (U32*)buf;
-  for (int X=w; X--;) {
-U32* colors = d.byte1[*p++];
-*q++ = colors[*p++];
-  }
-}
-
-#endif // U64 else U32
-
 uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here
 
 /**
@@ -200,34 +107,33 @@
 }
 #endif
 
-/**
-  Draw XPM image data, with the top-left corner at the given position.
-  \see fl_draw_pixmap(char* const* data, int x, int y, Fl_Color bg)
-  */
-int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) {
-  pixmap_data d;
-  if (!fl_measure_pixmap(cdata, d.w, d.h)) return 0;
+int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) {
+  int w, h;
   const uchar*const* data = (const uchar*const*)(cdata+1);
   int transparent_index = -1;
+
+  if (!fl_measure_pixmap(cdata, w, h))
+return 0;
+
+  if ((chars_per_pixel < 1) || (cha

Re: [fltk.development] [RFE] STR #2659: support conversion from Fl_Pixmap to Fl_RGB_Image

2012-06-19 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2659
Version: 1.4-feature


Updated patch for latest trunk. I think we should consider this patch for
1.3.x. It actually simplifies a lot of things, see diffstat:

 FL/Fl_Image.H  |2 
 src/Fl_Image.cxx   |   13 ++
 src/fl_draw_pixmap.cxx |  307
++---
 3 files changed, 105 insertions(+), 217 deletions(-)


Link: http://www.fltk.org/str.php?L2659
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2660: support for custom (image) cursors

2012-06-19 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2660
Version: 1.4-feature


Attached file "fltk-1_v4.3.x-cursor.patch"...


Link: http://www.fltk.org/str.php?L2660
Version: 1.4-featurediff -ur fltk-1.3.0r9619.org/configh.in fltk-1.3.0r9619/configh.in
--- fltk-1.3.0r9619.org/configh.in  2012-06-18 16:16:16.674591310 +0200
+++ fltk-1.3.0r9619/configh.in  2012-06-18 16:16:16.826598600 +0200
@@ -116,6 +116,14 @@
 #define HAVE_XFIXES 0
 
 /*
+ * HAVE_XCURSOR:
+ *
+ * Do we have the X cursor library?
+ */
+
+#define HAVE_XCURSOR 0
+
+/*
  * __APPLE_QUARTZ__:
  *
  * All Apple implementations are now based on Quartz and Cocoa,
diff -ur fltk-1.3.0r9619.org/configure.in fltk-1.3.0r9619/configure.in
--- fltk-1.3.0r9619.org/configure.in2012-06-18 16:16:16.674591310 +0200
+++ fltk-1.3.0r9619/configure.in2012-06-18 16:16:16.826598600 +0200
@@ -1009,6 +1009,16 @@
LIBS="-lXfixes $LIBS")
fi
 
+   dnl Check for the Xcursor library unless disabled...
+AC_ARG_ENABLE(xcursor, [  --enable-xcursorturn on Xcursor 
support [default=yes]])
+
+   if test x$enable_xcursor != xno; then
+   AC_CHECK_HEADER(X11/Xcursor/Xcursor.h, AC_DEFINE(HAVE_XCURSOR),,
+   [#include ])
+   AC_CHECK_LIB(Xcursor, XcursorImageCreate,
+   LIBS="-lXcursor $LIBS")
+   fi
+
dnl Check for overlay visuals...
AC_PATH_PROG(XPROP, xprop)
AC_CACHE_CHECK(for X overlay visuals, ac_cv_have_overlay,
diff -ur fltk-1.3.0r9619.org/FL/Enumerations.H fltk-1.3.0r9619/FL/Enumerations.H
--- fltk-1.3.0r9619.org/FL/Enumerations.H   2012-03-26 18:54:54.0 
+0200
+++ fltk-1.3.0r9619/FL/Enumerations.H   2012-06-18 16:16:16.827598648 +0200
@@ -879,35 +879,36 @@
 
 /** The following constants define the mouse cursors that are available in 
FLTK.
 
-The double-headed arrows are bitmaps provided by FLTK on X, the others
-are provided by system-defined cursors.
+Cursors are provided by the system when available, or bitmaps built into
+FLTK as a fallback.
 
 \todo enum Fl_Cursor needs maybe an image.
 */
 enum Fl_Cursor {
   FL_CURSOR_DEFAULT=  0, /**< the default cursor, usually an arrow. */
-  FL_CURSOR_ARROW  = 35, /**< an arrow pointer. */
-  FL_CURSOR_CROSS  = 66, /**< crosshair. */
-  FL_CURSOR_WAIT   = 76, /**< watch or hourglass. */
-  FL_CURSOR_INSERT = 77, /**< I-beam. */
-  FL_CURSOR_HAND   = 31, /**< hand (uparrow on MSWindows). */
-  FL_CURSOR_HELP   = 47, /**< question mark. */
-  FL_CURSOR_MOVE   = 27, /**< 4-pointed arrow. */
-  // fltk provides bitmaps for these:
-  FL_CURSOR_NS = 78, /**< up/down arrow. */
-  FL_CURSOR_WE = 79, /**< left/right arrow. */
-  FL_CURSOR_NWSE   = 80, /**< diagonal arrow. */
-  FL_CURSOR_NESW   = 81, /**< diagonal arrow. */
-  FL_CURSOR_NONE   =255, /**< invisible. */
-  // for back compatibility (non MSWindows ones):
-  FL_CURSOR_N  = 70, /**< for back compatibility. */
-  FL_CURSOR_NE = 69, /**< for back compatibility. */
-  FL_CURSOR_E  = 49, /**< for back compatibility. */
-  FL_CURSOR_SE =  8, /**< for back compatibility. */
-  FL_CURSOR_S  =  9, /**< for back compatibility. */
-  FL_CURSOR_SW =  7, /**< for back compatibility. */
-  FL_CURSOR_W  = 36, /**< for back compatibility. */
-  FL_CURSOR_NW = 68 /**< for back compatibility. */
+  FL_CURSOR_ARROW   = 1,/**< an arrow pointer. */
+  FL_CURSOR_CROSS   = 2,/**< crosshair. */
+  FL_CURSOR_WAIT= 3,/**< busy indicator (e.g. hourglass). */
+  FL_CURSOR_INSERT  = 4,/**< I-beam. */
+  FL_CURSOR_HAND= 5,/**< pointing hand. */
+  FL_CURSOR_HELP= 6,/**< question mark pointer. */
+  FL_CURSOR_MOVE= 7,/**< 4-pointed arrow or hand. */
+
+  /* Resize indicators */
+  FL_CURSOR_NS  = 101,  /**< up/down resize. */
+  FL_CURSOR_WE  = 102,  /**< left/right resize. */
+  FL_CURSOR_NWSE= 103,  /**< diagonal resize. */
+  FL_CURSOR_NESW= 104,  /**< diagonal resize. */
+  FL_CURSOR_NE  = 110,  /**< upwards, right resize. */
+  FL_CURSOR_N   = 111,  /**< upwards resize. */
+  FL_CURSOR_NW  = 112,  /**< upwards, left resize. */
+  FL_CURSOR_E   = 113,  /**< leftwards resize. */
+  FL_CURSOR_W   = 114,  /**< rightwards resize. */
+  FL_CURSOR_SE  = 115,  /**< downwards, right resize. */
+  FL_CURSOR_S   = 116,  /**< downwards resize. */
+  FL_CURSOR_SW  = 117,  /**< downwards, left resize. */
+
+  FL_CURSOR_NONE= 255,  /**< invisible. */
 };
 /*@}*/ // group: Cursors  
 
diff -ur fltk-1.3.0r9619.org/FL/fl_draw.H fltk-1.3.0r9619/FL/fl_draw.H
--- fltk-1.3.0r9619.org/FL/fl_draw.H2012-05-08 18:15:34.0 +0200
+++ fltk-1.3.0r9619/FL/fl_draw.H2012-06-18 16:16:16.827598648 +0200
@@ -751,7 +751,8 @@
 FL_EXPORT unsigned int fl_old_short

Re: [fltk.development] [RFE] STR #2660: support for custom (image) cursors

2012-06-19 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2660
Version: 1.4-feature


Updated patch for latest trunk. Nominating for 1.3.x.


Link: http://www.fltk.org/str.php?L2660
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2816: Add ability to set proper window icons

2012-06-19 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2816
Version: 1.3-feature


Attached file "fltk-1_v2.3.0-icons.patch"...


Link: http://www.fltk.org/str.php?L2816
Version: 1.3-featurediff -ur fltk-1.3.0r9619.org/FL/Fl_Window.H fltk-1.3.0r9619/FL/Fl_Window.H
--- fltk-1.3.0r9619.org/FL/Fl_Window.H  2012-06-18 16:02:15.133232753 +0200
+++ fltk-1.3.0r9619/FL/Fl_Window.H  2012-06-18 16:02:15.282239896 +0200
@@ -22,6 +22,10 @@
 #ifndef Fl_Window_H
 #define Fl_Window_H
 
+#ifdef WIN32
+#include 
+#endif
+
 #include "Fl_Group.H"
 
 #define FL_WINDOW 0xF0 ///< window type id all subclasses have type() 
>= this
@@ -73,9 +77,19 @@
   friend class Fl_X;
   Fl_X *i; // points at the system-specific stuff
 
+  struct icon_data {
+const void *legacy_icon;
+Fl_RGB_Image **icons;
+int count;
+#ifdef WIN32
+HICON big_icon;
+HICON small_icon;
+#endif
+  };
+
   const char* iconlabel_;
   char* xclass_;
-  const void* icon_;
+  struct icon_data *icon_;
   // size_range stuff:
   int minw, minh, maxw, maxh;
   int dw, dh, aspect;
@@ -121,6 +135,8 @@
   */
   int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
 
+  void free_icons();
+
 public:
 
   /**
@@ -342,6 +358,18 @@
   static const char *default_xclass();
   const char* xclass() const;
   void xclass(const char* c);
+
+  static void default_icon(const Fl_RGB_Image*);
+  static void default_icons(const Fl_RGB_Image*[], int);
+  void icon(const Fl_RGB_Image*);
+  void icons(const Fl_RGB_Image*[], int);
+
+#ifdef WIN32
+  static void default_icons(HICON big_icon, HICON small_icon);
+  void icons(HICON big_icon, HICON small_icon);
+#endif
+
+  /* for legacy compatibility */
   const void* icon() const;
   void icon(const void * ic);
 
diff -ur fltk-1.3.0r9619.org/FL/mac.H fltk-1.3.0r9619/FL/mac.H
--- fltk-1.3.0r9619.org/FL/mac.H2012-06-18 16:02:15.133232753 +0200
+++ fltk-1.3.0r9619/FL/mac.H2012-06-18 16:02:15.282239896 +0200
@@ -120,6 +120,9 @@
   void collapse(void);
   WindowRef window_ref(void);
   void set_key_window(void);
+  // OS X doesn't have per window icons
+  static void set_default_icons(const Fl_RGB_Image*[], int) {};
+  void set_icons() {};
   int set_cursor(Fl_Cursor);
   int set_cursor(const Fl_RGB_Image*, int, int);
   static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int 
w, int h);
diff -ur fltk-1.3.0r9619.org/FL/win32.H fltk-1.3.0r9619/FL/win32.H
--- fltk-1.3.0r9619.org/FL/win32.H  2012-06-18 16:02:15.133232753 +0200
+++ fltk-1.3.0r9619/FL/win32.H  2012-06-18 16:02:15.282239896 +0200
@@ -84,6 +84,9 @@
   void flush() {w->flush();}
   void set_minmax(LPMINMAXINFO minmax);
   void mapraise();
+  static void set_default_icons(const Fl_RGB_Image*[], int);
+  static void set_default_icons(HICON, HICON);
+  void set_icons();
   int set_cursor(Fl_Cursor);
   int set_cursor(const Fl_RGB_Image*, int, int);
   static Fl_X* make(Fl_Window*);
diff -ur fltk-1.3.0r9619.org/FL/x.H fltk-1.3.0r9619/FL/x.H
--- fltk-1.3.0r9619.org/FL/x.H  2012-06-18 16:02:15.133232753 +0200
+++ fltk-1.3.0r9619/FL/x.H  2012-06-18 16:02:15.282239896 +0200
@@ -154,6 +154,8 @@
   static Fl_X* i(const Fl_Window* wi) {return wi->i;}
   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
   void sendxjunk();
+  static void set_default_icons(const Fl_RGB_Image*[], int);
+  void set_icons();
   int set_cursor(Fl_Cursor);
   int set_cursor(const Fl_RGB_Image*, int, int);
   static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, 
Colormap=fl_colormap);
diff -ur fltk-1.3.0r9619.org/src/Fl.cxx fltk-1.3.0r9619/src/Fl.cxx
--- fltk-1.3.0r9619.org/src/Fl.cxx  2012-06-18 16:02:15.125232369 +0200
+++ fltk-1.3.0r9619/src/Fl.cxx  2012-06-18 16:02:15.282239896 +0200
@@ -1530,6 +1530,8 @@
   if (xclass_) {
 free(xclass_);
   }
+  free_icons();
+  delete icon_;
 }
 
 // FL_SHOW and FL_HIDE are called whenever the visibility of this widget
diff -ur fltk-1.3.0r9619.org/src/Fl_win32.cxx fltk-1.3.0r9619/src/Fl_win32.cxx
--- fltk-1.3.0r9619.org/src/Fl_win32.cxx2012-06-18 16:02:15.139233034 
+0200
+++ fltk-1.3.0r9619/src/Fl_win32.cxx2012-06-18 16:02:54.100101492 +0200
@@ -1804,6 +1804,8 @@
   );
   if (lab) free(lab);
 
+  x->set_icons();
+
   if (w->fullscreen_active()) {
   /* We need to make sure that the fullscreen is created on the
  default monitor, ie the desktop where the shortcut is located
@@ -2034,71 +2036,19 @@
 
 
 
-#ifndef IDC_HAND
-#  define IDC_HAND  MAKEINTRESOURCE(32649)
-#endif // !IDC_HAND
-
-int Fl_X::set_cursor(Fl_Cursor c) {
-  LPSTR n;
-  HCURSOR new_cursor;
-
-  if (c == FL_CURSOR_NONE)
-new_cursor = NULL;
-  else {
-switch (c) {
-case FL_CURSOR_ARROW:   n = IDC_ARROW; break;
-case FL_CURSOR_CROSS:   n = IDC_CROSS; break;
-case FL_CURSOR_WAIT:n = IDC_WAIT; break;
-case FL_CURSOR_INSERT:  n = IDC_IBEAM; break;

Re: [fltk.development] [RFE] STR #2816: Add ability to set proper window icons

2012-06-19 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2816
Version: 1.3-feature


Updated patch for latest trunk. I think this patch is important because it
means that FLTK apps can look better, and people cares about that.


Link: http://www.fltk.org/str.php?L2816
Version: 1.3-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-10-24 Thread Peter Åstrand
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-xfixes-xcursor-cmake.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featureIndex: fltk-1.3.0r9619/configh.cmake.in
===
--- fltk-1.3.0r9619/configh.cmake.in(revision 9619)
+++ fltk-1.3.0r9619/configh.cmake.in(arbetskopia)
@@ -108,6 +108,22 @@
 #define USE_XDBE HAVE_XDBE
 
 /*
+ * HAVE_XFIXES:
+ *
+ * Do we have the X fixes extension?
+ */
+
+#define HAVE_XFIXES 0
+
+/*
+ * HAVE_XCURSOR:
+ *
+ * Do we have the X cursor library?
+ */
+
+#define HAVE_XCURSOR 0
+
+/*
  * __APPLE_QUARTZ__:
  *
  * If __APPLE_QUARTZ__ is defined, FLTK will be
___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-10-24 Thread Peter Åstrand

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


fltk-xfixes-xcursor-cmake.patch is necessary when building with cmake
rather than autotools.


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2012-10-24 Thread Peter Åstrand
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-xfixes-xcursor-cmake.2.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featureIndex: CMakeLists.txt
===
--- CMakeLists.txt  (revision 9619)
+++ CMakeLists.txt  (arbetskopia)
@@ -515,6 +515,20 @@
 endif(OPTION_USE_XINERAMA)
 
 ###
+if(X11_Xfixes_FOUND)
+   option(OPTION_USE_XFIXES "use lib XFIXES" ON)
+endif(X11_Xfixes_FOUND)
+
+if(OPTION_USE_XFIXES)
+   set(HAVE_XFIXES ${X11_Xfixes_FOUND})
+   include_directories(${X11_Xfixes_INCLUDE_PATH})
+   list(APPEND FLTK_LDLIBS -lXfixes)
+   set(FLTK_XFIXES_FOUND TRUE)
+else()
+   set(FLTK_XFIXES_FOUND FALSE)
+endif(OPTION_USE_XFIXES)
+
+###
 if(X11_Xft_FOUND)
option(OPTION_USE_XFT "use lib Xft" ON)
 endif(X11_Xft_FOUND)
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt (revision 9619)
+++ test/CMakeLists.txt (arbetskopia)
@@ -45,6 +45,10 @@
   target_link_libraries(${NAME} ${X11_Xinerama_LIB})
endif(HAVE_XINERAMA)
 
+   if(HAVE_XFIXES)
+  target_link_libraries(${NAME} ${X11_Xfixes_LIB})
+   endif(HAVE_XFIXES)
+
install(TARGETS ${NAME}
   DESTINATION ${PREFIX_DOC}/examples
   )
Index: fluid/CMakeLists.txt
===
--- fluid/CMakeLists.txt(revision 9619)
+++ fluid/CMakeLists.txt(arbetskopia)
@@ -42,6 +42,10 @@
target_link_libraries(fluid ${X11_Xinerama_LIB})
 endif(HAVE_XINERAMA)
 
+if(HAVE_XFIXES)
+   target_link_libraries(fluid ${X11_Xfixes_LIB})
+endif(HAVE_XFIXES)
+
 install(TARGETS fluid
EXPORT fltk-install
DESTINATION ${PREFIX_BIN}
Index: configh.cmake.in
===
--- configh.cmake.in(revision 9619)
+++ configh.cmake.in(arbetskopia)
@@ -108,6 +108,22 @@
 #define USE_XDBE HAVE_XDBE
 
 /*
+ * HAVE_XFIXES:
+ *
+ * Do we have the X fixes extension?
+ */
+
+#define HAVE_XFIXES 0
+
+/*
+ * HAVE_XCURSOR:
+ *
+ * Do we have the X cursor library?
+ */
+
+#define HAVE_XCURSOR 0
+
+/*
  * __APPLE_QUARTZ__:
  *
  * If __APPLE_QUARTZ__ is defined, FLTK will be
___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2013-01-16 Thread Peter Åstrand
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_v3.3.x-clipboard-x11.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -urp fltk-1.3.2.org/configh.in fltk-1.3.2/configh.in
--- fltk-1.3.2.org/configh.in   2011-10-04 11:21:47.0 +0200
+++ fltk-1.3.2/configh.in   2013-01-16 14:13:43.326105799 +0100
@@ -108,6 +108,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 -urp fltk-1.3.2.org/configure.in fltk-1.3.2/configure.in
--- fltk-1.3.2.org/configure.in 2013-01-16 14:12:55.837228707 +0100
+++ fltk-1.3.2/configure.in 2013-01-16 14:13:43.327105989 +0100
@@ -999,6 +999,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 ])
+   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 -urp fltk-1.3.2.org/src/Fl_x.cxx fltk-1.3.2/src/Fl_x.cxx
--- fltk-1.3.2.org/src/Fl_x.cxx 2013-01-16 14:12:55.833230463 +0100
+++ fltk-1.3.2/src/Fl_x.cxx 2013-01-16 14:13:43.328105596 +0100
@@ -53,6 +53,12 @@ static XRRUpdateConfiguration_type XRRUp
 static int randrEventBase;  // base of RandR-defined events
 #endif
 
+#  ifdef HAVE_XFIXES
+#  include 
+static int xfixes_event_base = 0;
+static bool have_xfixes = false;
+#  endif
+
 static Fl_Xlib_Graphics_Driver fl_xlib_driver;
 static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
 Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the 
platform display
@@ -307,6 +313,9 @@ static Atom WM_PROTOCOLS;
 static Atom fl_MOTIF_WM_HINTS;
 static Atom TARGETS;
 static Atom CLIPBOARD;
+static Atom TIMESTAMP;
+static Atom PRIMARY_TIMESTAMP;
+static Atom CLIPBOARD_TIMESTAMP;
 Atom fl_XdndAware;
 Atom fl_XdndSelection;
 Atom fl_XdndEnter;
@@ -667,6 +676,9 @@ void fl_open_display(Display* d) {
   fl_MOTIF_WM_HINTS = XInternAtom(d, "_MOTIF_WM_HINTS", 0);
   TARGETS   = XInternAtom(d, "TARGETS", 0);
   CLIPBOARD = XInternAtom(d, "CLIPBOARD",   0);
+  TIMESTAMP = XInternAtom(d, "TIMESTAMP",   0);
+  PRIMARY_TIMESTAMP = XInternAtom(d, "PRIMARY_TIMESTAMP",   0);
+  CLIPBOARD_TIMESTAMP   = XInternAtom(d, "CLIPBOARD_TIMESTAMP", 0);
   fl_XdndAware  = XInternAtom(d, "XdndAware",   0);
   fl_XdndSelection  = XInternAtom(d, "XdndSelection",   0);
   fl_XdndEnter  = XInternAtom(d, "XdndEnter",   0);
@@ -713,6 +725,15 @@ void fl_open_display(Display* d) {
 #if !USE_COLORMAP
   Fl::visual(FL_RGB);
 #endif
+
+#ifdef HAVE_XFIXES
+  int error_base;
+  if (XFixesQueryExtension(fl_display, &xfixes_event_base, &error_base))
+have_xfixes = true;
+  else
+have_xfixes = false;
+#endif
+
 #if USE_XRANDR
   void *libxrandr_addr = dlopen("libXrandr.so.2", RTLD_LAZY);
   if (!libxrandr_addr)  libxrandr_addr = dlopen("libXrandr.so", RTLD_LAZY);
@@ -901,6 +922,94 @@ void Fl::copy(const char *stuff, int len
 }
 
 
+// Code for tracking clipboard changes:
+
+static Time primary_timestamp = -1;
+static Time clipboard_timestamp = -1;
+
+extern bool fl_clipboard_notify_empty(void);
+extern void fl_trigger_clipboard_notify(int source);
+
+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;
+
+  // We need a window for this to work
+  if (!Fl::first_window())
+return;
+  xid = fl_xid(Fl::first_window());
+  if (!xid)
+return;
+
+  // Request an update of the selection time for both the primary and
+  // clipboard selections. Magic continues when we get a SelectionNotify.
+  if (!fl_i_own_selection[0])
+XConvertSelection(fl_display, XA_PRIMARY, TIMESTAMP, PRIMARY_TIMESTAMP,
+  xid, fl_event_time);
+  if (!fl_i_own_selection[1])
+XConvertSelection(fl_display, CLIPBOARD, TIMESTAMP, CLIPBOARD_TIMESTAMP,
+  xid, fl_event_time);
+}
+
+static void clipboard_timeout(void *data)
+{
+  // No one is interested, so stop polling
+  if (fl_clipboard_notify_empty())
+return;
+
+  poll_clipboard_owner();
+
+  Fl::repeat_timeout(0.5, cl

Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2013-01-16 Thread Peter Åstrand

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


The patches "clipboard-x11" and "clipboard-xfixes" has been adapted for
FLTK 1.3.2 and merged into a single file:
fltk-1_v3.3.x-clipboard-x11.patch. The other patches (clipboard,
clipboard-win32-fix, clipboard-win32, and clipboard-osx) has been verified
to work with 1.3.2 and needs no update. 

Please note: The clipboard-win32-fix.patch is separate because it only
contains bug fixes to the existing functionality. We would like it to be
merged as soon as possible. Should we create a new STR for this?


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2659: support conversion from Fl_Pixmap to Fl_RGB_Image

2013-01-16 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2659
Version: 1.4-feature


Attached file "pixmap_v2.patch"...


Link: http://www.fltk.org/str.php?L2659
Version: 1.4-featurediff -ur fltk-1.3.2.org/FL/Fl_Image.H fltk-1.3.2/FL/Fl_Image.H
--- fltk-1.3.2.org/FL/Fl_Image.H2012-11-09 17:02:08.0 +0100
+++ fltk-1.3.2/FL/Fl_Image.H2013-01-16 14:40:51.543230638 +0100
@@ -26,6 +26,7 @@
 #include 
 
 class Fl_Widget;
+class Fl_Pixmap;
 struct Fl_Menu_Item;
 struct Fl_Label;
 
@@ -203,6 +204,7 @@
   */
   Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
 Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) 
{data((const char **)&array, 1); ld(LD);}
+  Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
   virtual ~Fl_RGB_Image();
   virtual Fl_Image *copy(int W, int H);
   Fl_Image *copy() { return copy(w(), h()); }
diff -ur fltk-1.3.2.org/src/fl_draw_pixmap.cxx fltk-1.3.2/src/fl_draw_pixmap.cxx
--- fltk-1.3.2.org/src/fl_draw_pixmap.cxx   2012-04-22 05:09:31.0 
+0200
+++ fltk-1.3.2/src/fl_draw_pixmap.cxx   2013-01-16 14:40:51.542230588 +0100
@@ -58,99 +58,6 @@
   return 1;
 }
 
-#ifdef U64
-
-// The callback from fl_draw_image to get a row of data passes this:
-struct pixmap_data {
-  int w, h;
-  const uchar*const* data;
-  union {
-U64 colors[256];
-U64* byte1[256];
-  };
-};
-
-// callback for 1 byte per pixel:
-static void cb1(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+x;
-  U64* q = (U64*)buf;
-  for (int X=w; X>0; X-=2, p += 2) {
-if (X>1) {
-#  if WORDS_BIGENDIAN
-  *q++ = (d.colors[p[0]]<<32) | d.colors[p[1]];
-#  else
-  *q++ = (d.colors[p[1]]<<32) | d.colors[p[0]];
-#  endif
-} else {
-#  if WORDS_BIGENDIAN
-  *q++ = d.colors[p[0]]<<32;
-#  else
-  *q++ = d.colors[p[0]];
-#  endif
-}
-  }
-}
-
-// callback for 2 bytes per pixel:
-static void cb2(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+2*x;
-  U64* q = (U64*)buf;
-  for (int X=w; X>0; X-=2) {
-U64* colors = d.byte1[*p++];
-int index = *p++;
-if (X>1) {
-  U64* colors1 = d.byte1[*p++];
-  int index1 = *p++;
-#  if WORDS_BIGENDIAN
-  *q++ = (colors[index]<<32) | colors1[index1];
-#  else
-  *q++ = (colors1[index1]<<32) | colors[index];
-#  endif
-} else {
-#  if WORDS_BIGENDIAN
-  *q++ = colors[index]<<32;
-#  else
-  *q++ = colors[index];
-#  endif
-}
-  }
-}
-
-#else // U32
-
-// The callback from fl_draw_image to get a row of data passes this:
-struct pixmap_data {
-  int w, h;
-  const uchar*const* data;
-  union {
-U32 colors[256];
-U32* byte1[256];
-  };
-};
-
-// callback for 1 byte per pixel:
-static void cb1(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+x;
-  U32* q = (U32*)buf;
-  for (int X=w; X--;) *q++ = d.colors[*p++];
-}
-
-// callback for 2 bytes per pixel:
-static void cb2(void*v, int x, int y, int w, uchar* buf) {
-  pixmap_data& d = *(pixmap_data*)v;
-  const uchar* p = d.data[y]+2*x;
-  U32* q = (U32*)buf;
-  for (int X=w; X--;) {
-U32* colors = d.byte1[*p++];
-*q++ = colors[*p++];
-  }
-}
-
-#endif // U64 else U32
-
 uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here
 
 /**
@@ -200,34 +107,33 @@
 }
 #endif
 
-/**
-  Draw XPM image data, with the top-left corner at the given position.
-  \see fl_draw_pixmap(char* const* data, int x, int y, Fl_Color bg)
-  */
-int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) {
-  pixmap_data d;
-  if (!fl_measure_pixmap(cdata, d.w, d.h)) return 0;
+int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) {
+  int w, h;
   const uchar*const* data = (const uchar*const*)(cdata+1);
   int transparent_index = -1;
+
+  if (!fl_measure_pixmap(cdata, w, h))
+return 0;
+
+  if ((chars_per_pixel < 1) || (chars_per_pixel > 2))
+return 0;
+
+  uchar colors[1<<(chars_per_pixel*8)][4];
+
 #ifdef WIN32
   uchar *transparent_c = (uchar *)0; // such that transparent_c[0,1,2] are the 
RGB of the transparent color
   color_count = 0;
   used_colors = (uchar *)malloc(abs(ncolors)*3*sizeof(uchar));
 #endif
 
-  if (ncolors < 0) {   // FLTK (non standard) compressed colormap
+  if (ncolors < 0) {
+// FLTK (non standard) compressed colormap
 ncolors = -ncolors;
 const uchar *p = *data++;
 // if first color is ' ' it is transparent (put it later to make
 // it not be transparent):
 if (*p == ' ') {
-  uchar* c = (uchar*)&d.colors[(int)' '];
-#ifdef U64
-  *(U64*)c = 0;
-#  if WORDS_BIGENDIAN
-  c += 4;
-#  endif
-#endif
+  uchar* c = colors[(int)' '];
   transparent_index = ' ';
   Fl::get_color(bg, c[0], c[1], c[2]); c[3] = 0;
 #ifdef WIN32
@@ -238,13 +144,7 @@
 }
 // re

Re: [fltk.development] [RFE] STR #2659: support conversion from Fl_Pixmap to Fl_RGB_Image

2013-01-16 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2659
Version: 1.4-feature


Yes, please apply. The pixmap_v2.patch has been adapted to FLTK 1.3.2.
Hopefully applies to trunk as well.


Link: http://www.fltk.org/str.php?L2659
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2816: Add ability to set proper window icons

2013-01-16 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2816
Version: 1.3-feature


Attached file "fltk-1_v3.3.0-icons.patch"...


Link: http://www.fltk.org/str.php?L2816
Version: 1.3-featurediff -ur fltk-1.3.2.org/FL/Fl_Window.H fltk-1.3.2/FL/Fl_Window.H
--- fltk-1.3.2.org/FL/Fl_Window.H   2013-01-16 10:49:40.904228200 +0100
+++ fltk-1.3.2/FL/Fl_Window.H   2013-01-16 10:49:55.554353925 +0100
@@ -22,6 +22,10 @@
 #ifndef Fl_Window_H
 #define Fl_Window_H
 
+#ifdef WIN32
+#include 
+#endif
+
 #include "Fl_Group.H"
 
 #define FL_WINDOW 0xF0 ///< window type id all subclasses have type() 
>= this
@@ -73,9 +77,19 @@
   friend class Fl_X;
   Fl_X *i; // points at the system-specific stuff
 
+  struct icon_data {
+const void *legacy_icon;
+Fl_RGB_Image **icons;
+int count;
+#ifdef WIN32
+HICON big_icon;
+HICON small_icon;
+#endif
+  };
+
   const char* iconlabel_;
   char* xclass_;
-  const void* icon_;
+  struct icon_data *icon_;
   // size_range stuff:
   int minw, minh, maxw, maxh;
   int dw, dh, aspect;
@@ -121,6 +135,8 @@
   */
   int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
 
+  void free_icons();
+
 public:
 
   /**
@@ -350,6 +366,18 @@
   static const char *default_xclass();
   const char* xclass() const;
   void xclass(const char* c);
+
+  static void default_icon(const Fl_RGB_Image*);
+  static void default_icons(const Fl_RGB_Image*[], int);
+  void icon(const Fl_RGB_Image*);
+  void icons(const Fl_RGB_Image*[], int);
+
+#ifdef WIN32
+  static void default_icons(HICON big_icon, HICON small_icon);
+  void icons(HICON big_icon, HICON small_icon);
+#endif
+
+  /* for legacy compatibility */
   const void* icon() const;
   void icon(const void * ic);
 
diff -ur fltk-1.3.2.org/FL/mac.H fltk-1.3.2/FL/mac.H
--- fltk-1.3.2.org/FL/mac.H 2013-01-16 10:49:40.904228200 +0100
+++ fltk-1.3.2/FL/mac.H 2013-01-16 10:49:55.554353925 +0100
@@ -120,6 +120,9 @@
   void collapse(void);
   WindowRef window_ref(void);
   void set_key_window(void);
+  // OS X doesn't have per window icons
+  static void set_default_icons(const Fl_RGB_Image*[], int) {};
+  void set_icons() {};
   int set_cursor(Fl_Cursor);
   int set_cursor(const Fl_RGB_Image*, int, int);
   static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int 
w, int h);
diff -ur fltk-1.3.2.org/FL/win32.H fltk-1.3.2/FL/win32.H
--- fltk-1.3.2.org/FL/win32.H   2013-01-16 10:49:40.904228200 +0100
+++ fltk-1.3.2/FL/win32.H   2013-01-16 10:49:55.555355617 +0100
@@ -84,6 +84,9 @@
   void flush() {w->flush();}
   void set_minmax(LPMINMAXINFO minmax);
   void mapraise();
+  static void set_default_icons(const Fl_RGB_Image*[], int);
+  static void set_default_icons(HICON, HICON);
+  void set_icons();
   int set_cursor(Fl_Cursor);
   int set_cursor(const Fl_RGB_Image*, int, int);
   static Fl_X* make(Fl_Window*);
diff -ur fltk-1.3.2.org/FL/x.H fltk-1.3.2/FL/x.H
--- fltk-1.3.2.org/FL/x.H   2013-01-16 10:49:40.904228200 +0100
+++ fltk-1.3.2/FL/x.H   2013-01-16 10:49:55.555355617 +0100
@@ -154,6 +154,8 @@
   static Fl_X* i(const Fl_Window* wi) {return wi->i;}
   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
   void sendxjunk();
+  static void set_default_icons(const Fl_RGB_Image*[], int);
+  void set_icons();
   int set_cursor(Fl_Cursor);
   int set_cursor(const Fl_RGB_Image*, int, int);
   static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, 
Colormap=fl_colormap);
diff -ur fltk-1.3.2.org/src/Fl.cxx fltk-1.3.2/src/Fl.cxx
--- fltk-1.3.2.org/src/Fl.cxx   2013-01-16 10:49:40.895228113 +0100
+++ fltk-1.3.2/src/Fl.cxx   2013-01-16 10:49:55.556137979 +0100
@@ -1530,6 +1530,8 @@
   if (xclass_) {
 free(xclass_);
   }
+  free_icons();
+  delete icon_;
 }
 
 // FL_SHOW and FL_HIDE are called whenever the visibility of this widget
diff -ur fltk-1.3.2.org/src/Fl_win32.cxx fltk-1.3.2/src/Fl_win32.cxx
--- fltk-1.3.2.org/src/Fl_win32.cxx 2013-01-16 10:49:40.911227539 +0100
+++ fltk-1.3.2/src/Fl_win32.cxx 2013-01-16 10:49:55.556137979 +0100
@@ -1804,6 +1804,8 @@
   );
   if (lab) free(lab);
 
+  x->set_icons();
+
   if (w->fullscreen_active()) {
   /* We need to make sure that the fullscreen is created on the
  default monitor, ie the desktop where the shortcut is located
@@ -2034,71 +2036,19 @@
 
 
 
-#ifndef IDC_HAND
-#  define IDC_HAND  MAKEINTRESOURCE(32649)
-#endif // !IDC_HAND
-
-int Fl_X::set_cursor(Fl_Cursor c) {
-  LPSTR n;
-  HCURSOR new_cursor;
-
-  if (c == FL_CURSOR_NONE)
-new_cursor = NULL;
-  else {
-switch (c) {
-case FL_CURSOR_ARROW:   n = IDC_ARROW; break;
-case FL_CURSOR_CROSS:   n = IDC_CROSS; break;
-case FL_CURSOR_WAIT:n = IDC_WAIT; break;
-case FL_CURSOR_INSERT:  n = IDC_IBEAM; break;
-case FL_CURSOR_HAND:n = IDC_HAND; break;
-case FL_CURSOR_HELP:n = IDC_HELP; break;
-case FL_CURSOR_MOVE

Re: [fltk.development] [RFE] STR #2816: Add ability to set proper window icons

2013-01-16 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2816
Version: 1.3-feature


fltk-1_v3.3.0-icons.patch has been adapted for FLTK 1.3.2. Only offset
changes.


Link: http://www.fltk.org/str.php?L2816
Version: 1.3-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2860: Multi-head full screen support

2013-01-16 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2860
Version: 1.3-feature


Attached file "fltk-1_v3.3.x-multihead.patch"...


Link: http://www.fltk.org/str.php?L2860
Version: 1.3-featurediff -urp fltk-1.3.2.org/FL/Fl_Window.H fltk-1.3.2/FL/Fl_Window.H
--- fltk-1.3.2.org/FL/Fl_Window.H   2013-01-16 10:52:33.017228122 +0100
+++ fltk-1.3.2/FL/Fl_Window.H   2013-01-16 10:52:47.876478968 +0100
@@ -54,7 +54,7 @@ class Fl_RGB_Image;
 class FL_EXPORT Fl_Window : public Fl_Group {
 
   static char *default_xclass_;
-  // Note: we must use separate statements for each of the following 4 
variables,
+  // Note: we must use separate statements for each of the following 8 
variables,
   // with the static attribute, otherwise MS VC++ 2008/2010 complains :-(
   // AlbrechtS 04/2012
 #if FLTK_ABI_VERSION < 10301
@@ -73,6 +73,22 @@ class FL_EXPORT Fl_Window : public Fl_Gr
   static // when these members are static, ABI compatibility with 1.3.0 is 
respected
 #endif
   int no_fullscreen_h;
+#if FLTK_ABI_VERSION < 10302
+  static // when these members are static, ABI compatibility with 1.3.0 is 
respected
+#endif
+  int fullscreen_screen_top;
+#if FLTK_ABI_VERSION < 10302
+  static // when these members are static, ABI compatibility with 1.3.0 is 
respected
+#endif
+  int fullscreen_screen_bottom;
+#if FLTK_ABI_VERSION < 10302
+  static // when these members are static, ABI compatibility with 1.3.0 is 
respected
+#endif
+  int fullscreen_screen_left;
+#if FLTK_ABI_VERSION < 10302
+  static // when these members are static, ABI compatibility with 1.3.0 is 
respected
+#endif
+  int fullscreen_screen_right;
 
   friend class Fl_X;
   Fl_X *i; // points at the system-specific stuff
@@ -430,13 +446,15 @@ public:
   */
   void show(int argc, char **argv);
   /**
-Makes the window completely fill the screen, without any window
-manager border visible.  You must use fullscreen_off() to undo
-this. 
+Makes the window completely fill one or more screens, without any
+window manager border visible.  You must use fullscreen_off() to
+undo this. 
 
 \note On some platforms, this can result in the keyboard being
 grabbed. The window may also be recreated, meaning hide() and
 show() will be called.
+
+\see void Fl_Window::fullscreen_screens()
   */
   void fullscreen();
   /**
@@ -453,6 +471,17 @@ public:
   */
   unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
   /**
+Sets which screens should be used when this window is in fullscreen
+mode. The window will be resized to the top of the screen with index
+\p top, the bottom of the screen with index \p bottom, etc. 
+
+If this method is never called, or if any argument is < 0, then the
+window will be resized to fill the screen it is currently on.
+
+\see void Fl_Window::fullscreen()
+*/
+  void fullscreen_screens(int top, int bottom, int left, int right);
+  /**
 Iconifies the window.  If you call this when shown() is false
 it will show() it as an icon.  If the window is already
 iconified this does nothing.
diff -urp fltk-1.3.2.org/FL/win32.H fltk-1.3.2/FL/win32.H
--- fltk-1.3.2.org/FL/win32.H   2013-01-16 10:52:33.017228122 +0100
+++ fltk-1.3.2/FL/win32.H   2013-01-16 10:52:47.876478968 +0100
@@ -80,6 +80,7 @@ public:
   static Fl_X* i(const Fl_Window* w) {return w->i;}
   static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
 int &bt,int &bx,int &by);
+  void make_fullscreen(int X, int Y, int W, int H);
   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
   void flush() {w->flush();}
   void set_minmax(LPMINMAXINFO minmax);
diff -urp fltk-1.3.2.org/src/Fl_cocoa.mm fltk-1.3.2/src/Fl_cocoa.mm
--- fltk-1.3.2.org/src/Fl_cocoa.mm  2013-01-16 10:52:33.014229574 +0100
+++ fltk-1.3.2/src/Fl_cocoa.mm  2013-01-16 10:52:47.877480606 +0100
@@ -2438,9 +2438,32 @@ void Fl_X::make(Fl_Window* w)
  
 NSRect crect;
 if (w->fullscreen_active()) {
-  int sx, sy, sw, sh;
-  Fl::screen_xywh(sx, sy, sw, sh, w->x(), w->y(), w->w(), w->h());
-  w->resize(sx, sy, sw, sh);
+  int top, bottom, left, right;
+  int sx, sy, sw, sh, X, Y, W, H;
+
+  top = w->fullscreen_screen_top;
+  bottom = w->fullscreen_screen_bottom;
+  left = w->fullscreen_screen_left;
+  right = w->fullscreen_screen_right;
+
+  if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
+top = Fl::screen_num(w->x(), w->y(), w->w(), w->h());
+bottom = top;
+left = top;
+right = top;
+  }
+
+  Fl::screen_xywh(sx, sy, sw, sh, top);
+  Y = sy;
+  Fl::screen_xywh(sx, sy, sw, sh, bottom);
+  H = sy + sh - Y;
+  Fl::screen_xywh(sx, sy, sw, sh, left);
+  X = sx;
+  Fl::screen_xywh(sx, sy, sw, sh, right);
+  W = sx + sw - X;
+
+  w->resize(X, Y, W, H);
+
   winstyle = NSBorderlessWindowMask;

Re: [fltk.development] [RFE] STR #2860: Multi-head full screen support

2013-01-16 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2860
Version: 1.3-feature


fltk-1_v3.3.x-multihead.patch has been adapted for FLTK 1.3.2. Thus, you
should apply:

1) fltk-1.3.x-screen_num.patch

2) fltk-1_v3.3.x-multihead.patch

The first patch is smaller, perhaps we can start with applying this?


Link: http://www.fltk.org/str.php?L2860
Version: 1.3-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


[fltk.development] Strange build error on Mac OS X

2013-01-17 Thread Peter Åstrand


When building a shared library of FLTK 1.3.2 on Mac OS X 10.4 (Linux cross 
compilation), we get this exotic error message:


Linking CXX shared library ../lib/libfltk.dylib
/usr/lib/gcc/i686-apple-darwin8/4.5.3/../../../../i686-apple-darwin8/bin/ld:
CMakeFiles/fltk_SHARED.dir/Fl_Native_File_Chooser_MAC.mm.o literal pointer 
section (__OBJC,__cls_refs) does not have is exactly one relocation entry for 
each pointer

collect2: ld returned 1 exit status

Indeed, this strange sentence can be found in 
http://www.opensource.apple.com/source/cctools/cctools-499/ld/mod_sections.c, 
but it's not obvious what the problem is. There are some warnings though:


[ 78%] Building CXX object 
src/CMakeFiles/fltk.dir/Fl_Native_File_Chooser_MAC.mm.o

/local/home/astrand/rpm/BUILD/fltk-1.3.2/src/Fl_Native_File_Chooser_MAC.mm: In 
member function 'int Fl_Native_File_Chooser::runmodal()':
/local/home/astrand/rpm/BUILD/fltk-1.3.2/src/Fl_Native_File_Chooser_MAC.mm:504:79:
 warning: 'NSSavePanel' may not respond to '-setDirectoryURL:'
/local/home/astrand/rpm/BUILD/fltk-1.3.2/src/Fl_Native_File_Chooser_MAC.mm:504:79:
 warning: (Messages without a matching method signature
/local/home/astrand/rpm/BUILD/fltk-1.3.2/src/Fl_Native_File_Chooser_MAC.mm:504:79:
 warning: will be assumed to return 'id' and accept
/local/home/astrand/rpm/BUILD/fltk-1.3.2/src/Fl_Native_File_Chooser_MAC.mm:504:79:
 warning: '...' as arguments.)
/local/home/astrand/rpm/BUILD/fltk-1.3.2/src/Fl_Native_File_Chooser_MAC.mm:505:67:
 warning: 'NSSavePanel' may not respond to '-setNameFieldStringValue:'

If anyone has a clue... In the mean time, we're disabling the shared 
library.



Rgds, 
---

Peter Åstrand   ThinLinc Chief Developer
Cendio AB   http://cendio.com
Teknikringen 8  http://twitter.com/ThinLinc
583 30 Linköpinghttp://facebook.com/ThinLinc
Phone: +46-13-214600http://plus.google.com/112509906846170010689___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] Strange build error on Mac OS X

2013-01-17 Thread Peter Åstrand

On Thu, 17 Jan 2013, MacArthur, Ian (Selex ES, UK) wrote:


So... from that, I understand that you are building fltk dylibs for an OSX 
target system, on a linux host system?


Yes. With Autotools we can successfully build the dylibs. However, we have 
never tried to actually use them; we are always linking FLTK statically.



Well, that is an interesting idea... I have some code for which I need 
to maintain an OSX 10.4 build (for x86 and ppc32) and the current Apple 
tools don't really want to do that anymore (unless I stare at them very 
sternly for a while!)... but if it is possible to build this target from 
a non-Apple host, well that opens up some new possibilities indeed...!


Yes, it's very nice. We are btw building all our binaries on Linux, also 
binaries for Windows and Solaris. But we have spent a lot of time on our 
build system...


Rgds, 
---

Peter Åstrand   ThinLinc Chief Developer
Cendio AB   http://cendio.com
Teknikringen 8  http://twitter.com/ThinLinc
583 30 Linköpinghttp://facebook.com/ThinLinc
Phone: +46-13-214600http://plus.google.com/112509906846170010689___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] Strange build error on Mac OS X

2013-01-21 Thread Peter Åstrand

On Thu, 17 Jan 2013, Peter Åstrand wrote:

When building a shared library of FLTK 1.3.2 on Mac OS X 10.4 (Linux cross 
compilation), we get this exotic error message:


Linking CXX shared library ../lib/libfltk.dylib
/usr/lib/gcc/i686-apple-darwin8/4.5.3/../../../../i686-apple-darwin8/bin/ld:
CMakeFiles/fltk_SHARED.dir/Fl_Native_File_Chooser_MAC.mm.o literal pointer 
section (__OBJC,__cls_refs) does not have is exactly one relocation entry for 
each pointer


It turns out that this error only occurs when using -O3. Thus, one 
solution is to use DCMAKE_BUILD_TYPE=Debug. I decided to use this method 
instead:


-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-Os" 
-DCMAKE_CXX_FLAGS_RELEASE="-Os"

The problem with -O3 may very well be specific to our combination of 
compiler, binutils etc. We are using GCC 4.5.3.


Rgds, 
---

Peter Åstrand   ThinLinc Chief Developer
Cendio AB   http://cendio.com
Teknikringen 8  http://twitter.com/ThinLinc
583 30 Linköpinghttp://facebook.com/ThinLinc
Phone: +46-13-214600http://plus.google.com/112509906846170010689___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2013-01-21 Thread Peter Åstrand
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_v4.3.x-clipboard-x11.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featurediff -urp fltk-1.3.2.org/CMakeLists.txt fltk-1.3.2/CMakeLists.txt
--- fltk-1.3.2.org/CMakeLists.txt   2012-09-13 16:19:01.0 +0200
+++ fltk-1.3.2/CMakeLists.txt   2013-01-21 15:04:20.808353056 +0100
@@ -515,6 +515,20 @@ else()
 endif(OPTION_USE_XINERAMA)
 
 ###
+if(X11_Xfixes_FOUND)
+   option(OPTION_USE_XFIXES "use lib XFIXES" ON)
+endif(X11_Xfixes_FOUND)
+
+if(OPTION_USE_XFIXES)
+   set(HAVE_XFIXES ${X11_Xfixes_FOUND})
+   include_directories(${X11_Xfixes_INCLUDE_PATH})
+   list(APPEND FLTK_LDLIBS -lXfixes)
+   set(FLTK_XFIXES_FOUND TRUE)
+else()
+   set(FLTK_XFIXES_FOUND FALSE)
+endif(OPTION_USE_XFIXES)
+
+###
 if(X11_Xft_FOUND)
option(OPTION_USE_XFT "use lib Xft" ON)
 endif(X11_Xft_FOUND)
diff -urp fltk-1.3.2.org/configh.cmake.in fltk-1.3.2/configh.cmake.in
--- fltk-1.3.2.org/configh.cmake.in 2011-07-19 06:49:30.0 +0200
+++ fltk-1.3.2/configh.cmake.in 2013-01-21 15:04:20.809352676 +0100
@@ -108,6 +108,22 @@
 #define USE_XDBE HAVE_XDBE
 
 /*
+ * HAVE_XFIXES:
+ *
+ * Do we have the X fixes extension?
+ */
+
+#define HAVE_XFIXES 0
+
+/*
+ * HAVE_XCURSOR:
+ *
+ * Do we have the X cursor library?
+ */
+
+#define HAVE_XCURSOR 0
+
+/*
  * __APPLE_QUARTZ__:
  *
  * If __APPLE_QUARTZ__ is defined, FLTK will be
diff -urp fltk-1.3.2.org/configh.in fltk-1.3.2/configh.in
--- fltk-1.3.2.org/configh.in   2011-10-04 11:21:47.0 +0200
+++ fltk-1.3.2/configh.in   2013-01-21 15:03:47.557352862 +0100
@@ -108,6 +108,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 -urp fltk-1.3.2.org/configure.in fltk-1.3.2/configure.in
--- fltk-1.3.2.org/configure.in 2013-01-21 15:03:47.486103076 +0100
+++ fltk-1.3.2/configure.in 2013-01-21 15:03:47.558353440 +0100
@@ -999,6 +999,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 ])
+   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 -urp fltk-1.3.2.org/fluid/CMakeLists.txt fltk-1.3.2/fluid/CMakeLists.txt
--- fltk-1.3.2.org/fluid/CMakeLists.txt 2011-01-06 11:24:58.0 +0100
+++ fltk-1.3.2/fluid/CMakeLists.txt 2013-01-21 15:04:20.809352676 +0100
@@ -42,6 +42,10 @@ if(HAVE_XINERAMA)
target_link_libraries(fluid ${X11_Xinerama_LIB})
 endif(HAVE_XINERAMA)
 
+if(HAVE_XFIXES)
+   target_link_libraries(fluid ${X11_Xfixes_LIB})
+endif(HAVE_XFIXES)
+
 install(TARGETS fluid
EXPORT fltk-install
DESTINATION ${PREFIX_BIN}
diff -urp fltk-1.3.2.org/src/Fl_x.cxx fltk-1.3.2/src/Fl_x.cxx
--- fltk-1.3.2.org/src/Fl_x.cxx 2013-01-21 15:03:47.481103255 +0100
+++ fltk-1.3.2/src/Fl_x.cxx 2013-01-21 15:03:47.559355892 +0100
@@ -53,6 +53,12 @@ static XRRUpdateConfiguration_type XRRUp
 static int randrEventBase;  // base of RandR-defined events
 #endif
 
+#  ifdef HAVE_XFIXES
+#  include 
+static int xfixes_event_base = 0;
+static bool have_xfixes = false;
+#  endif
+
 static Fl_Xlib_Graphics_Driver fl_xlib_driver;
 static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
 Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the 
platform display
@@ -307,6 +313,9 @@ static Atom WM_PROTOCOLS;
 static Atom fl_MOTIF_WM_HINTS;
 static Atom TARGETS;
 static Atom CLIPBOARD;
+static Atom TIMESTAMP;
+static Atom PRIMARY_TIMESTAMP;
+static Atom CLIPBOARD_TIMESTAMP;
 Atom fl_XdndAware;
 Atom fl_XdndSelection;
 Atom fl_XdndEnter;
@@ -667,6 +676,9 @@ void fl_open_display(Display* d) {
   fl_MOTIF_WM_HINTS = XInternAtom(d, "_MOTIF_WM_HINTS", 0);
   TARGETS   = XInternAtom(d, "TARGETS", 0);
   CLIPBOARD = XInternAtom(d, "CLIPBOARD",   0);
+  TIMESTAMP = XInternAtom(d, "TIMESTAMP",   0);
+  PRIMARY_TIMESTAMP = XInternAtom(d, "PRIMARY_TIMESTAMP",   0);
+  CLIPBOARD_TIMESTAMP   = XInternAtom(d, "CLIPBOARD_TIMESTAMP", 0);
   fl_XdndAware  = XInternAtom(d, "XdndAware",   0);
   fl_XdndSelection  = XInternAtom(d, "XdndSelection",   0);
  

Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2013-01-21 Thread Peter Åstrand

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


fltk-1_v4.3.x-clipboard-x11.patch is an updated patch which integrates
fltk-xfixes-xcursor-cmake.2.patch.


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] Fl::event_key() inconsistency between X and OS X

2013-01-28 Thread Peter Åstrand


Do you see any improvement if you apply the 3 latest patches from 
http://www.fltk.org/str.php?L2599 ?


Rgds,
Peter

On Mon, 28 Jan 2013, Evan Laforge wrote:


I recently switched back to using Fl::event_key() instead of
Fl::event_text(), it seems to be much more reliable than it was
before.  However, there's still an inconsistency.  A shifted letter
yields the lowercase letter plus the shift modifier.  A shifted digit
also yields the digit plus shift.  However, a shifted symbol (like
'/') yields the shifted alternate (like '?') plus shift.  This is
inconsistent with the others, and probably also makes it hard to map
keys consistently, since those symbol mappings vary per keyboard.

Also, the X version always emits shift + unshifted keycap.  So it's
presumably just a bug in the OS X version.  I know Manolo's been doing
a lot of work in the key handling lately, so presumably it's still
fresh in his mind :)

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev




---
Peter Åstrand   ThinLinc Chief Developer
Cendio AB   http://cendio.com
Teknikringen 8  http://twitter.com/ThinLinc
583 30 Linköpinghttp://facebook.com/ThinLinc
Phone: +46-13-214600http://plus.google.com/112509906846170010689___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] Fl::event_key() inconsistency between X and OS X

2013-01-30 Thread Peter Åstrand



On Mon, Jan 28, 2013 at 11:39 PM, Peter Åstrand  wrote:


Do you see any improvement if you apply the 3 latest patches from
http://www.fltk.org/str.php?L2599 ?


They don't apply to fltk HEAD, and it doesn't look very easy to apply
by hand.  Fl_cocoa.mm has seen some major changes lately that probably
broke the patches.  Can you update them?


We recently updated the patches for 1.3.2. Sorry to hear that they no 
longer apply to HEAD.


Would it be possible for you to test with 1.3.2 and see if our patches 
does what you want? I haven't read through all the details, but you might 
want to set the SIMPLE_KEYBOARD flag to get the desired behaviour.


Manolo Gouy, do you know if the keyboard related changes you have done to 
Fl_cocoa.mm overlaps with the patches from STR 2599 somehow?


Rgds, 
---

Peter Åstrand   ThinLinc Chief Developer
Cendio AB   http://cendio.com
Teknikringen 8  http://twitter.com/ThinLinc
583 30 Linköpinghttp://facebook.com/ThinLinc
Phone: +46-13-214600http://plus.google.com/112509906846170010689___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] FLTK version number update and release process [WAS: Re: [fltk.bugs] [MOD] STR #2932: 1.3.2 tarball not packaged properly]

2013-03-01 Thread Peter Åstrand

On Fri, 1 Mar 2013, MacArthur, Ian (Selex ES, UK) wrote:


Oh, and another question: WHEN do we upgrade the version number(s)?

  (a) immediately after one release, for the next release, or


What Mike said: As soon as *anything* in SVN changes after a release, we need to 
"bump" the version numbers in some way.

Ideally, I suppose, we might bump it to a "temporary" number, then 
change that to the "formal" number for the next release, so that folks 
can determine if the build they have is a formal release or some svn 
checkout or something...? (I sort of have this in some of my own builds,


Suggestion: After the release is done, append "post" to the version 
number.


Rgds, 
---

Peter Åstrand   ThinLinc Chief Developer
Cendio AB   http://cendio.com
Teknikringen 8  http://twitter.com/ThinLinc
583 30 Linköpinghttp://facebook.com/ThinLinc
Phone: +46-13-214600http://plus.google.com/112509906846170010689___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #1903: Add UTF-8 support

2008-10-02 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L1903
Version: 1.3-feature


fltk118-utf8-2008-02-24.tar.bz2 was easy to build and the utf8 test looks
good. Is this version supposed to work on all major platforms
(Solaris/Linux/Windows/OS X)? Any known stability problems?


Link: http://www.fltk.org/str.php?L1903
Version: 1.3-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2641: Implement proper fullscreen support

2011-05-26 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2641
Version: 1.4-feature


Attached file "fullscreen16.patch"...


Link: http://www.fltk.org/str.php?L2641
Version: 1.4-featureIndex: src/Fl_Window_fullscreen.cxx
===
--- src/Fl_Window_fullscreen.cxx(revision 8739)
+++ src/Fl_Window_fullscreen.cxx(arbetskopia)
@@ -60,39 +60,48 @@
 #endif
 }
 
+void fullscreen_x(Fl_Window *w);
+void fullscreen_off_x();
+void fullscreen_off_x(Fl_Window *w, int X, int Y, int W, int H);
+
+/* Note: The previous implementation toggled border(). With this new
+   implementation this is not necessary. Additionally, if we do that,
+   the application may lose focus when switching out of fullscreen
+   mode with some window managers. Besides, the API does not say that
+   the FLTK border state should be toggled; it only says that the
+   borders should not be *visible*. 
+*/
 void Fl_Window::fullscreen() {
-#ifndef WIN32
-  //this would clobber the fake wm, since it relies on the border flags to
-  //determine its thickness
-  border(0);
-#endif
-#if defined(__APPLE__) || defined(WIN32) || defined(USE_X11)
-  int sx, sy, sw, sh;
-  Fl::screen_xywh(sx, sy, sw, sh, x(), y(), w(), h());
-  // if we are on the main screen, we will leave the system menu bar 
unobstructed
-  if (Fl::x()>=sx && Fl::y()>=sy && Fl::x()+Fl::w()<=sx+sw && 
Fl::y()+Fl::h()<=sy+sh) {
-sx = Fl::x(); sy = Fl::y(); 
-sw = Fl::w(); sh = Fl::h();
+  if (shown() && !(flags() & Fl_Widget::FULLSCREEN)) {
+no_fullscreen_x = x();
+no_fullscreen_y = y();
+no_fullscreen_w = w();
+no_fullscreen_h = h();
+fullscreen_x(this);
+  } else {
+set_flag(FULLSCREEN);
   }
-  if (x()==sx) x(sx+1); // make sure that we actually execute the resize
-#if defined(USE_X11)
-  resize(0, 0, w(), h()); // work around some quirks in X11
-#endif
-  resize(sx, sy, sw, sh);
-#else
-  if (!x()) x(1); // make sure that we actually execute the resize
-  resize(0,0,Fl::w(),Fl::h());
-#endif
 }
 
 void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
-  // this order produces less blinking on IRIX:
-  resize(X,Y,W,H);
-#ifndef WIN32
-  border(1);
-#endif
+  if (shown() && (flags() & Fl_Widget::FULLSCREEN)) {
+fullscreen_off_x(this, X, Y, W, H);
+  } else {
+clear_flag(FULLSCREEN);
+  }
+  no_fullscreen_x = no_fullscreen_y = no_fullscreen_w = no_fullscreen_h = 0;
 }
 
+void Fl_Window::fullscreen_off() {
+  if (!no_fullscreen_x && !no_fullscreen_y) {
+// Window was initially created fullscreen - default to current monitor
+no_fullscreen_x = x();
+no_fullscreen_y = y();
+  }
+  fullscreen_off(no_fullscreen_x, no_fullscreen_y, no_fullscreen_w, 
no_fullscreen_h);
+}
+
+
 //
 // End of "$Id$".
 //
Index: src/Fl_Window.cxx
===
--- src/Fl_Window.cxx   (revision 8739)
+++ src/Fl_Window.cxx   (arbetskopia)
@@ -59,6 +59,10 @@
   resizable(0);
   size_range_set = 0;
   minw = maxw = minh = maxh = 0;
+  no_fullscreen_x = 0;
+  no_fullscreen_y = 0;
+  no_fullscreen_w = w();
+  no_fullscreen_h = h();
   callback((Fl_Callback*)default_callback);
 }
 
Index: src/Fl_grab.cxx
===
--- src/Fl_grab.cxx (revision 8739)
+++ src/Fl_grab.cxx (arbetskopia)
@@ -50,7 +50,19 @@
 extern void *fl_capture;
 #endif
 
+#if !(defined(WIN32) || defined(__APPLE__))
+extern int ewmh_supported(); // from Fl_x.cxx
+#endif
+
 void Fl::grab(Fl_Window* win) {
+Fl_Window *fullscreen_win = NULL;
+for (Fl_Window *W = Fl::first_window(); W; W = Fl::next_window(W)) {
+   if (W->fullscreen_active()) {
+   fullscreen_win = W;
+   break;
+   }
+}
+
   if (win) {
 if (!grab_) {
 #ifdef WIN32
@@ -60,8 +72,9 @@
   fl_capture = Fl_X::i(first_window())->xid;
   Fl_X::i(first_window())->set_key_window();
 #else
+  Window xid = fullscreen_win ? fl_xid(fullscreen_win) : 
fl_xid(first_window());
   XGrabPointer(fl_display,
-  fl_xid(first_window()),
+  xid,
   1,
   ButtonPressMask|ButtonReleaseMask|
   ButtonMotionMask|PointerMotionMask,
@@ -71,7 +84,7 @@
   0,
   fl_event_time);
   XGrabKeyboard(fl_display,
-   fl_xid(first_window()),
+   xid,
1,
GrabModeAsync,
GrabModeAsync, 
@@ -87,7 +100,10 @@
 #elif defined(__APPLE__)
   fl_capture = 0;
 #else
-  XUngrabKeyboard(fl_display, fl_event_time);
+  // We must keep the grab in the non-EWMH fullscreen case
+  if (!fullscreen_win || ewmh_supported()) {
+ XUngrabKeyboard(fl_display, fl_event_time);
+  }
   XUngrabPointer(fl_display, fl_event_time);
   // this flush is done in case

Re: [fltk.development] [RFE] STR #2641: Implement proper fullscreen support

2011-05-26 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2641
Version: 1.4-feature


Attached updated patch, fullscreen16.patch. This patch fixes several
problems with the previous implementation:

* On Windows, the window was shrinking somewhat every time we switched to
non-fullscreen mode. 

* ewmh_supported() was broken, due to signed/unsigned variables. 

* We are now correctly grabbing the keyboard in override-redirect mode,
still supporting popup dialogs in front the the O-R window. 

* Optimized EWMH code: Avoids unnecessary resizes. 

* Improved OS X implementation, which works better when switching between
a fullscreen and normal application. 

Also note that since STR #2640 and STR #2646 have been applied, this patch
no longer depends on other patches.


Link: http://www.fltk.org/str.php?L2641
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2641: Implement proper fullscreen support

2011-06-20 Thread Peter Åstrand
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2641
Version: 1.4-feature


Attached file "fullscreen17.patch"...


Link: http://www.fltk.org/str.php?L2641
Version: 1.4-featureIndex: src/Fl_Window_fullscreen.cxx
===
--- src/Fl_Window_fullscreen.cxx(revision 8831)
+++ src/Fl_Window_fullscreen.cxx(arbetskopia)
@@ -60,39 +60,48 @@
 #endif
 }
 
+void fullscreen_x(Fl_Window *w);
+void fullscreen_off_x();
+void fullscreen_off_x(Fl_Window *w, int X, int Y, int W, int H);
+
+/* Note: The previous implementation toggled border(). With this new
+   implementation this is not necessary. Additionally, if we do that,
+   the application may lose focus when switching out of fullscreen
+   mode with some window managers. Besides, the API does not say that
+   the FLTK border state should be toggled; it only says that the
+   borders should not be *visible*. 
+*/
 void Fl_Window::fullscreen() {
-#ifndef WIN32
-  //this would clobber the fake wm, since it relies on the border flags to
-  //determine its thickness
-  border(0);
-#endif
-#if defined(__APPLE__) || defined(WIN32) || defined(USE_X11)
-  int sx, sy, sw, sh;
-  Fl::screen_xywh(sx, sy, sw, sh, x(), y(), w(), h());
-  // if we are on the main screen, we will leave the system menu bar 
unobstructed
-  if (Fl::x()>=sx && Fl::y()>=sy && Fl::x()+Fl::w()<=sx+sw && 
Fl::y()+Fl::h()<=sy+sh) {
-sx = Fl::x(); sy = Fl::y(); 
-sw = Fl::w(); sh = Fl::h();
+  if (shown() && !(flags() & Fl_Widget::FULLSCREEN)) {
+no_fullscreen_x = x();
+no_fullscreen_y = y();
+no_fullscreen_w = w();
+no_fullscreen_h = h();
+fullscreen_x(this);
+  } else {
+set_flag(FULLSCREEN);
   }
-  if (x()==sx) x(sx+1); // make sure that we actually execute the resize
-#if defined(USE_X11)
-  resize(0, 0, w(), h()); // work around some quirks in X11
-#endif
-  resize(sx, sy, sw, sh);
-#else
-  if (!x()) x(1); // make sure that we actually execute the resize
-  resize(0,0,Fl::w(),Fl::h());
-#endif
 }
 
 void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
-  // this order produces less blinking on IRIX:
-  resize(X,Y,W,H);
-#ifndef WIN32
-  border(1);
-#endif
+  if (shown() && (flags() & Fl_Widget::FULLSCREEN)) {
+fullscreen_off_x(this, X, Y, W, H);
+  } else {
+clear_flag(FULLSCREEN);
+  }
+  no_fullscreen_x = no_fullscreen_y = no_fullscreen_w = no_fullscreen_h = 0;
 }
 
+void Fl_Window::fullscreen_off() {
+  if (!no_fullscreen_x && !no_fullscreen_y) {
+// Window was initially created fullscreen - default to current monitor
+no_fullscreen_x = x();
+no_fullscreen_y = y();
+  }
+  fullscreen_off(no_fullscreen_x, no_fullscreen_y, no_fullscreen_w, 
no_fullscreen_h);
+}
+
+
 //
 // End of "$Id$".
 //
Index: src/Fl_Window.cxx
===
--- src/Fl_Window.cxx   (revision 8831)
+++ src/Fl_Window.cxx   (arbetskopia)
@@ -59,6 +59,10 @@
   resizable(0);
   size_range_set = 0;
   minw = maxw = minh = maxh = 0;
+  no_fullscreen_x = 0;
+  no_fullscreen_y = 0;
+  no_fullscreen_w = w();
+  no_fullscreen_h = h();
   callback((Fl_Callback*)default_callback);
 }
 
Index: src/Fl_grab.cxx
===
--- src/Fl_grab.cxx (revision 8831)
+++ src/Fl_grab.cxx (arbetskopia)
@@ -50,7 +50,19 @@
 extern void *fl_capture;
 #endif
 
+#if !(defined(WIN32) || defined(__APPLE__))
+extern int ewmh_supported(); // from Fl_x.cxx
+#endif
+
 void Fl::grab(Fl_Window* win) {
+Fl_Window *fullscreen_win = NULL;
+for (Fl_Window *W = Fl::first_window(); W; W = Fl::next_window(W)) {
+  if (W->fullscreen_active()) {
+fullscreen_win = W;
+break;
+  }
+}
+
   if (win) {
 if (!grab_) {
 #ifdef WIN32
@@ -60,8 +72,9 @@
   fl_capture = Fl_X::i(first_window())->xid;
   Fl_X::i(first_window())->set_key_window();
 #else
+  Window xid = fullscreen_win ? fl_xid(fullscreen_win) : 
fl_xid(first_window());
   XGrabPointer(fl_display,
-  fl_xid(first_window()),
+  xid,
   1,
   ButtonPressMask|ButtonReleaseMask|
   ButtonMotionMask|PointerMotionMask,
@@ -71,7 +84,7 @@
   0,
   fl_event_time);
   XGrabKeyboard(fl_display,
-   fl_xid(first_window()),
+   xid,
1,
GrabModeAsync,
GrabModeAsync, 
@@ -87,7 +100,10 @@
 #elif defined(__APPLE__)
   fl_capture = 0;
 #else
+  // We must keep the grab in the non-EWMH fullscreen case
+  if (!fullscreen_win || ewmh_supported()) {
   XUngrabKeyboard(fl_display, fl_event_time);
+  }
   XUngrabPointer(fl_display, fl_event_time);
   // this flush is done in case the picked menu item goes into
   // an infinite loop, so

Re: [fltk.development] [RFE] STR #2641: Implement proper fullscreen support

2011-06-20 Thread Peter Åstrand

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2641
Version: 1.4-feature


Attached patch fullscreen17.patch, update patch to better deal with the
Windows coordinate mess and to fix windows starting in fullscreen.


Link: http://www.fltk.org/str.php?L2641
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev


Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2011-08-08 Thread Peter Åstrand
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-win32-fix.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-featureIndex: fltk-1.3/src/Fl_win32.cxx
===
--- fltk-1.3/src/Fl_win32.cxx   (revision 8929)
+++ fltk-1.3/src/Fl_win32.cxx   (arbetskopia)
@@ -533,6 +533,37 @@
   const char* GetValue() const { return(out); }
 };
 
+void fl_update_clipboard(void) {
+  Fl_Window *w1 = Fl::first_window();
+  if (!w1)
+return;
+
+  HWND hwnd = fl_xid(w1);
+
+  if (!OpenClipboard(hwnd))
+return;
+
+  EmptyClipboard();
+
+  int utf16_len = fl_utf8toUtf16(fl_selection_buffer[1],
+ fl_selection_length[1], 0, 0);
+
+  HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and zero'ed 
mem alloc.
+  LPVOID memLock = GlobalLock(hMem);
+
+  fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1],
+ (unsigned short*) memLock, utf16_len + 1);
+
+  GlobalUnlock(hMem);
+  SetClipboardData(CF_UNICODETEXT, hMem);
+
+  CloseClipboard();
+
+  // In case Windows managed to lob of a WM_DESTROYCLIPBOARD during
+  // the above.
+  fl_i_own_selection[1] = 1;
+}
+
 // call this when you create a selection:
 void Fl::copy(const char *stuff, int len, int clipboard) {
   if (!stuff || len<0) return;
@@ -550,25 +581,9 @@
   memcpy(fl_selection_buffer[clipboard], stuff, len);
   fl_selection_buffer[clipboard][len] = 0; // needed for direct paste
   fl_selection_length[clipboard] = len;
-  if (clipboard) {
-// set up for "delayed rendering":
-if (OpenClipboard(NULL)) {
-  // if the system clipboard works, use it
-  int utf16_len = fl_utf8toUtf16(fl_selection_buffer[clipboard], 
fl_selection_length[clipboard], 0, 0);
-  EmptyClipboard();
-  HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and 
zero'ed mem alloc.
-  LPVOID memLock = GlobalLock(hMem);
-  fl_utf8toUtf16(fl_selection_buffer[clipboard], 
fl_selection_length[clipboard], (unsigned short*) memLock, utf16_len + 1);
-  GlobalUnlock(hMem);
-  SetClipboardData(CF_UNICODETEXT, hMem);
-  CloseClipboard();
-  GlobalFree(hMem);
-  fl_i_own_selection[clipboard] = 0;
-} else {
-  // only if it fails, instruct paste() to use the internal buffers
-  fl_i_own_selection[clipboard] = 1;
-}
-  }
+  fl_i_own_selection[clipboard] = 1;
+  if (clipboard)
+fl_update_clipboard();
 }
 
 // Call this when a "paste" operation happens:
@@ -1176,34 +1191,6 @@
 fl_i_own_selection[1] = 0;
 return 1;
 
-  case WM_RENDERALLFORMATS:
-fl_i_own_selection[1] = 0;
-// Windoze seems unhappy unless I do these two steps. Documentation
-// seems to vary on whether opening the clipboard is necessary or
-// is in fact wrong:
-CloseClipboard();
-OpenClipboard(NULL);
-// fall through...
-  case WM_RENDERFORMAT: {
-HANDLE h;
-
-//  int l = fl_utf_nb_char((unsigned char*)fl_selection_buffer[1], 
fl_selection_length[1]);
-int l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], 
NULL, 0); // Pass NULL buffer to query length required
-h = GlobalAlloc(GHND, (l+1) * sizeof(unsigned short));
-if (h) {
-  unsigned short *g = (unsigned short*) GlobalLock(h);
-//fl_utf2unicode((unsigned char *)fl_selection_buffer[1], 
fl_selection_length[1], (xchar*)g);
-  l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], g, 
(l+1));
-  g[l] = 0;
-  GlobalUnlock(h);
-  SetClipboardData(CF_UNICODETEXT, h);
-}
-
-// Windoze also seems unhappy if I don't do this. Documentation very
-// unclear on what is correct:
-if (fl_msg.message == WM_RENDERALLFORMATS) CloseClipboard();
-return 1;}
-
   default:
 if (Fl::handle(0,0)) return 0;
 break;
Index: fltk-1.3/src/Fl.cxx
===
--- fltk-1.3/src/Fl.cxx (revision 8929)
+++ fltk-1.3/src/Fl.cxx (arbetskopia)
@@ -1352,7 +1352,9 @@
 
 // hide() destroys the X window, it does not do unmap!
 
-#if !defined(WIN32) && USE_XFT
+#if defined(WIN32)
+extern void fl_update_clipboard(void);
+#elif USE_XFT
 extern void fl_destroy_xft_draw(Window);
 #endif
 
@@ -1399,14 +1401,8 @@
 #if defined(WIN32)
   // this little trick keeps the current clipboard alive, even if we are about
   // to destroy the window that owns the selection.
-  if (GetClipboardOwner()==ip->xid) {
-Fl_Window *w1 = Fl::first_window();
-if (w1 && OpenClipboard(fl_xid(w1))) {
-  EmptyClipboard();
-  SetClipboardData(CF_TEXT, NULL);
-  CloseClipboard();
-}
-  }
+  if (GetClipboardOwner()==ip->xid)
+fl_update_clipboard();
   // Send a message to myself so that I'll get out of the event loop...
   PostMessage(ip-

Re: [fltk.development] [RFE] STR #2636: notification of clipboard changes

2011-08-08 Thread Peter Åstrand

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


Updated fltk-1.3.x-clipboard-win32-fix.patch, fixes problems with crashes
on exit, due to fl_xid(Fl::first_window()).


Link: http://www.fltk.org/str.php?L2636
Version: 1.4-feature

___
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev