|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: Fl_grab.cxx 8055 2010-12-18 22:31:01Z manolo $" 00003 // 00004 // Grab/release code for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 #include <config.h> 00029 #include <FL/Fl.H> 00030 #include <FL/x.H> 00031 00033 // "Grab" is done while menu systems are up. This has several effects: 00034 // Events are all sent to the "grab window", which does not even 00035 // have to be displayed (and in the case of Fl_Menu.cxx it isn't). 00036 // The system is also told to "grab" events and send them to this app. 00037 // This also modifies how Fl_Window::show() works, on X it turns on 00038 // override_redirect, it does similar things on WIN32. 00039 00040 extern void fl_fix_focus(); // in Fl.cxx 00041 00042 #ifdef WIN32 00043 // We have to keep track of whether we have captured the mouse, since 00044 // MSWindows shows little respect for this... Grep for fl_capture to 00045 // see where and how this is used. 00046 extern HWND fl_capture; 00047 #endif 00048 00049 #ifdef __APPLE__ 00050 extern void *fl_capture; 00051 #endif 00052 00053 void Fl::grab(Fl_Window* win) { 00054 if (win) { 00055 if (!grab_) { 00056 #ifdef WIN32 00057 SetActiveWindow(fl_capture = fl_xid(first_window())); 00058 SetCapture(fl_capture); 00059 #elif defined(__APPLE__) 00060 fl_capture = Fl_X::i(first_window())->xid; 00061 Fl_X::i(first_window())->set_key_window(); 00062 #else 00063 XGrabPointer(fl_display, 00064 fl_xid(first_window()), 00065 1, 00066 ButtonPressMask|ButtonReleaseMask| 00067 ButtonMotionMask|PointerMotionMask, 00068 GrabModeAsync, 00069 GrabModeAsync, 00070 None, 00071 0, 00072 fl_event_time); 00073 XGrabKeyboard(fl_display, 00074 fl_xid(first_window()), 00075 1, 00076 GrabModeAsync, 00077 GrabModeAsync, 00078 fl_event_time); 00079 #endif 00080 } 00081 grab_ = win; 00082 } else { 00083 if (grab_) { 00084 #ifdef WIN32 00085 fl_capture = 0; 00086 ReleaseCapture(); 00087 #elif defined(__APPLE__) 00088 fl_capture = 0; 00089 #else 00090 XUngrabKeyboard(fl_display, fl_event_time); 00091 XUngrabPointer(fl_display, fl_event_time); 00092 // this flush is done in case the picked menu item goes into 00093 // an infinite loop, so we don't leave the X server locked up: 00094 XFlush(fl_display); 00095 #endif 00096 grab_ = 0; 00097 fl_fix_focus(); 00098 } 00099 } 00100 } 00101 00102 // 00103 // End of "$Id: Fl_grab.cxx 8055 2010-12-18 22:31:01Z manolo $". 00104 //