aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-04-12 18:19:10 (GMT)
committerfluxgen <fluxgen>2004-04-12 18:19:10 (GMT)
commit9502426e7335e08395fe9500c5ecdff98e680d14 (patch)
treeeb7fee860c62d1b11281d0838074c010afd9205b
parentd26e439375245be6a5c2044be93b952f02ad68f7 (diff)
downloadfluxbox_paul-9502426e7335e08395fe9500c5ecdff98e680d14.zip
fluxbox_paul-9502426e7335e08395fe9500c5ecdff98e680d14.tar.bz2
fixed grab counting
-rw-r--r--src/Window.cc86
-rw-r--r--src/Window.hh13
2 files changed, 80 insertions, 19 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 2324e78..f77d79e 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.275 2004/03/31 10:28:08 fluxgen Exp $ 25// $Id: Window.cc,v 1.276 2004/04/12 18:19:10 fluxgen Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -254,6 +254,8 @@ void LayerMenuItem<FluxboxWindow>::click(int button, int time) {
254 m_object->moveToLayer(m_layernum); 254 m_object->moveToLayer(m_layernum);
255} 255}
256 256
257int FluxboxWindow::s_num_grabs = 0;
258
257FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, 259FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
258 FbTk::XLayer &layer): 260 FbTk::XLayer &layer):
259 oplock(false), 261 oplock(false),
@@ -265,17 +267,27 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
265 m_focussig(*this), 267 m_focussig(*this),
266 m_titlesig(*this), 268 m_titlesig(*this),
267 m_themelistener(*this), 269 m_themelistener(*this),
268 m_icon_hidden(false),
269 moving(false), resizing(false), shaded(false), 270 moving(false), resizing(false), shaded(false),
270 iconic(false), focused(false), 271 iconic(false), focused(false),
271 stuck(false), m_managed(false), 272 stuck(false), m_managed(false),
272 maximized(MAX_NONE), 273 maximized(MAX_NONE),
274 m_attaching_tab(0),
273 m_screen(client.screen()), 275 m_screen(client.screen()),
274 display(FbTk::App::instance()->display()), 276 display(FbTk::App::instance()->display()),
275 m_windowmenu(client.screen().menuTheme(), client.screen().imageControl(), 277 m_windowmenu(client.screen().menuTheme(), client.screen().imageControl(),
276 *client.screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), 278 *client.screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer())),
279 m_button_grab_x(0), m_button_grab_y(0),
280 m_last_move_x(0), m_last_move_y(0),
281 m_last_resize_h(1), m_last_resize_w(1),
282 m_workspace_number(0),
283 m_current_state(0),
277 m_old_decoration(DECOR_NORMAL), 284 m_old_decoration(DECOR_NORMAL),
278 m_client(&client), 285 m_client(&client),
286 m_shaped(false),
287 m_icon_hidden(false),
288 m_old_pos_x(0), m_old_pos_y(0),
289 m_old_width(1), m_old_height(1),
290 m_last_button_x(0), m_last_button_y(0),
279 m_frame(tm, client.screen().imageControl(), 0, 0, 100, 100), 291 m_frame(tm, client.screen().imageControl(), 0, 0, 100, 100),
280 m_layeritem(m_frame.window(), layer), 292 m_layeritem(m_frame.window(), layer),
281 m_layernum(layer.getLayerNum()), 293 m_layernum(layer.getLayerNum()),
@@ -299,7 +311,7 @@ FluxboxWindow::~FluxboxWindow() {
299 if (moving || resizing || m_attaching_tab) { 311 if (moving || resizing || m_attaching_tab) {
300 screen().hideGeometry(); 312 screen().hideGeometry();
301 screen().hidePosition(); 313 screen().hidePosition();
302 XUngrabPointer(display, CurrentTime); 314 ungrabPointer(CurrentTime);
303 } 315 }
304 316
305 // no longer a valid window to do stuff with 317 // no longer a valid window to do stuff with
@@ -2357,7 +2369,7 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
2357 attachTo(re.x_root, re.y_root); 2369 attachTo(re.x_root, re.y_root);
2358 else if (re.window == frame().window()) { 2370 else if (re.window == frame().window()) {
2359 if (re.button == 2 && re.state == Mod1Mask) 2371 if (re.button == 2 && re.state == Mod1Mask)
2360 XUngrabPointer(display, CurrentTime); 2372 ungrabPointer(CurrentTime);
2361 else 2373 else
2362 frame().buttonReleaseEvent(re); 2374 frame().buttonReleaseEvent(re);
2363 } else { 2375 } else {
@@ -2528,17 +2540,17 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2528 screen().showGeometry(gx, gy); 2540 screen().showGeometry(gx, gy);
2529 } 2541 }
2530 } else if ((me.state & Button2Mask) && inside_titlebar && client != 0) { 2542 } else if ((me.state & Button2Mask) && inside_titlebar && client != 0) {
2531 2543 if (s_num_grabs > 0)
2544 return;
2532 // 2545 //
2533 // drag'n'drop code for tabs 2546 // drag'n'drop code for tabs
2534 // 2547 //
2535 if (m_attaching_tab == 0) { 2548 if (m_attaching_tab == 0) {
2536 // start drag'n'drop for tab 2549 // start drag'n'drop for tab
2537 m_attaching_tab = client; 2550 m_attaching_tab = client;
2538 2551 grabPointer(me.window, False, Button2MotionMask |
2539 XGrabPointer(display, me.window, False, Button2MotionMask | 2552 ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
2540 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, 2553 None, frame().theme().moveCursor(), CurrentTime);
2541 None, frame().theme().moveCursor(), CurrentTime);
2542 m_last_move_x = me.x_root - 1; 2554 m_last_move_x = me.x_root - 1;
2543 m_last_move_y = me.y_root - 1; 2555 m_last_move_y = me.y_root - 1;
2544 2556
@@ -2803,13 +2815,16 @@ void FluxboxWindow::setDecorationMask(unsigned int mask) {
2803} 2815}
2804 2816
2805void FluxboxWindow::startMoving(Window win) { 2817void FluxboxWindow::startMoving(Window win) {
2818 if (s_num_grabs > 0)
2819 return;
2820
2806 moving = true; 2821 moving = true;
2807 Fluxbox *fluxbox = Fluxbox::instance(); 2822 Fluxbox *fluxbox = Fluxbox::instance();
2808 // grabbing (and masking) on the root window allows us to 2823 // grabbing (and masking) on the root window allows us to
2809 // freely map and unmap the window we're moving. 2824 // freely map and unmap the window we're moving.
2810 XGrabPointer(display, screen().rootWindow().window(), False, Button1MotionMask | 2825 grabPointer(screen().rootWindow().window(), False, Button1MotionMask |
2811 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, 2826 ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
2812 screen().rootWindow().window(), frame().theme().moveCursor(), CurrentTime); 2827 screen().rootWindow().window(), frame().theme().moveCursor(), CurrentTime);
2813 2828
2814 if (m_windowmenu.isVisible()) 2829 if (m_windowmenu.isVisible())
2815 m_windowmenu.hide(); 2830 m_windowmenu.hide();
@@ -2853,7 +2868,7 @@ void FluxboxWindow::stopMoving() {
2853 2868
2854 2869
2855 screen().hidePosition(); 2870 screen().hidePosition();
2856 XUngrabPointer(display, CurrentTime); 2871 ungrabPointer(CurrentTime);
2857 2872
2858 FbTk::App::instance()->sync(false); //make sure the redraw is made before we continue 2873 FbTk::App::instance()->sync(false); //make sure the redraw is made before we continue
2859} 2874}
@@ -2997,6 +3012,9 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
2997 3012
2998 3013
2999void FluxboxWindow::startResizing(Window win, int x, int y) { 3014void FluxboxWindow::startResizing(Window win, int x, int y) {
3015 if (s_num_grabs > 0)
3016 return;
3017
3000 resizing = true; 3018 resizing = true;
3001 3019
3002 const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme().upperLeftAngleCursor() : 3020 const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme().upperLeftAngleCursor() :
@@ -3004,8 +3022,8 @@ void FluxboxWindow::startResizing(Window win, int x, int y) {
3004 (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() : 3022 (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() :
3005 frame().theme().lowerLeftAngleCursor(); 3023 frame().theme().lowerLeftAngleCursor();
3006 3024
3007 XGrabPointer(display, win, false, ButtonMotionMask | ButtonReleaseMask, 3025 grabPointer(win, false, ButtonMotionMask | ButtonReleaseMask,
3008 GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); 3026 GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
3009 3027
3010 int gx = 0, gy = 0; 3028 int gx = 0, gy = 0;
3011 m_button_grab_x = x; 3029 m_button_grab_x = x;
@@ -3041,14 +3059,14 @@ void FluxboxWindow::stopResizing(Window win) {
3041 moveResize(m_last_resize_x, m_last_resize_y, 3059 moveResize(m_last_resize_x, m_last_resize_y,
3042 m_last_resize_w, m_last_resize_h); 3060 m_last_resize_w, m_last_resize_h);
3043 3061
3044 XUngrabPointer(display, CurrentTime); 3062 ungrabPointer(CurrentTime);
3045} 3063}
3046 3064
3047void FluxboxWindow::attachTo(int x, int y) { 3065void FluxboxWindow::attachTo(int x, int y) {
3048 if (m_attaching_tab == 0) 3066 if (m_attaching_tab == 0)
3049 return; 3067 return;
3050 3068
3051 XUngrabPointer(display, CurrentTime); 3069 ungrabPointer(CurrentTime);
3052 3070
3053 3071
3054 parent().drawRectangle(screen().rootTheme().opGC(), 3072 parent().drawRectangle(screen().rootTheme().opGC(),
@@ -3526,3 +3544,35 @@ void FluxboxWindow::reconfigTheme() {
3526 3544
3527 sendConfigureNotify(); 3545 sendConfigureNotify();
3528} 3546}
3547
3548// grab pointer an increase counter.
3549// we need this to count grab pointers,
3550// especially at startup, where we can drag/resize while starting
3551// and causing it to send events to windows later on and make
3552// two different windows do grab pointer which only one window
3553// should do at the time
3554void FluxboxWindow::grabPointer(Window grab_window,
3555 Bool owner_events,
3556 unsigned int event_mask,
3557 int pointer_mode, int keyboard_mode,
3558 Window confine_to,
3559 Cursor cursor,
3560 Time time) {
3561 XGrabPointer(FbTk::App::instance()->display(),
3562 grab_window,
3563 owner_events,
3564 event_mask,
3565 pointer_mode, keyboard_mode,
3566 confine_to,
3567 cursor,
3568 time);
3569 s_num_grabs++;
3570}
3571
3572// ungrab and decrease counter
3573void FluxboxWindow::ungrabPointer(Time time) {
3574 XUngrabPointer(FbTk::App::instance()->display(), time);
3575 s_num_grabs--;
3576 if (s_num_grabs < 0)
3577 s_num_grabs = 0;
3578}
diff --git a/src/Window.hh b/src/Window.hh
index 0c80669..6b5a411 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.hh,v 1.110 2004/03/21 09:00:25 rathnor Exp $ 25// $Id: Window.hh,v 1.111 2004/04/12 18:19:10 fluxgen Exp $
26 26
27#ifndef WINDOW_HH 27#ifndef WINDOW_HH
28#define WINDOW_HH 28#define WINDOW_HH
@@ -413,6 +413,16 @@ private:
413 void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height); 413 void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height);
414 /// sends configurenotify to all clients 414 /// sends configurenotify to all clients
415 void sendConfigureNotify(bool send_to_netizens = true); 415 void sendConfigureNotify(bool send_to_netizens = true);
416
417 static void grabPointer(Window grab_window,
418 Bool owner_events,
419 unsigned int event_mask,
420 int pointer_mode, int keyboard_mode,
421 Window confine_to,
422 Cursor cursor,
423 Time time);
424 static void ungrabPointer(Time time);
425
416 // state and hint signals 426 // state and hint signals
417 WinSubject m_hintsig, m_statesig, m_layersig, m_workspacesig, m_diesig, m_focussig, m_titlesig; 427 WinSubject m_hintsig, m_statesig, m_layersig, m_workspacesig, m_diesig, m_focussig, m_titlesig;
418 428
@@ -487,6 +497,7 @@ private:
487 ResizeCorner m_resize_corner; 497 ResizeCorner m_resize_corner;
488 498
489 ExtraMenus m_extramenus; 499 ExtraMenus m_extramenus;
500 static int s_num_grabs; ///< number of XGrabPointer's
490}; 501};
491 502
492 503