2 // "$Id: Fl_grab.cxx 8055 2010-12-18 22:31:01Z manolo $"
4 // Grab/release code for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
32 ////////////////////////////////////////////////////////////////
33 // "Grab" is done while menu systems are up. This has several effects:
34 // Events are all sent to the "grab window", which does not even
35 // have to be displayed (and in the case of Fl_Menu.cxx it isn't).
36 // The system is also told to "grab" events and send them to this app.
37 // This also modifies how Fl_Window::show() works, on X it turns on
38 // override_redirect, it does similar things on WIN32.
40 extern void fl_fix_focus(); // in Fl.cxx
43 // We have to keep track of whether we have captured the mouse, since
44 // MSWindows shows little respect for this... Grep for fl_capture to
45 // see where and how this is used.
46 extern HWND fl_capture
;
50 extern void *fl_capture
;
53 void Fl::grab(Fl_Window
* win
) {
57 SetActiveWindow(fl_capture
= fl_xid(first_window()));
58 SetCapture(fl_capture
);
59 #elif defined(__APPLE__)
60 fl_capture
= Fl_X::i(first_window())->xid
;
61 Fl_X::i(first_window())->set_key_window();
63 XGrabPointer(fl_display
,
64 fl_xid(first_window()),
66 ButtonPressMask
|ButtonReleaseMask
|
67 ButtonMotionMask
|PointerMotionMask
,
73 XGrabKeyboard(fl_display
,
74 fl_xid(first_window()),
87 #elif defined(__APPLE__)
90 XUngrabKeyboard(fl_display
, fl_event_time
);
91 XUngrabPointer(fl_display
, fl_event_time
);
92 // this flush is done in case the picked menu item goes into
93 // an infinite loop, so we don't leave the X server locked up:
103 // End of "$Id: Fl_grab.cxx 8055 2010-12-18 22:31:01Z manolo $".