From 9a9e3f6bf6be75094636e37d54fb16e4456b43be Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 5 May 2007 00:50:53 +0000 Subject: [PATCH] woa.. let you do mouse actions while in an interactive keyboard action, and let you do keyboard actions while move/resizing. yay. also you can click in windows at the same time.. --- openbox/event.c | 12 +++++++----- openbox/keyboard.c | 24 +++++++++++------------- openbox/moveresize.c | 33 +++++++++++++++++++++++---------- openbox/moveresize.h | 2 +- 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/openbox/event.c b/openbox/event.c index ff9ea574..efef0faa 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -546,14 +546,16 @@ static void event_process(const XEvent *ec, gpointer data) } if (useevent) { - if (!keyboard_process_interactive_grab(e, &client)) { - if (moveresize_in_progress) { - moveresize_event(e); - + /* if the keyboard interactive action uses the event then dont + use it for bindings. likewise is moveresize uses the event. */ + if (!keyboard_process_interactive_grab(e, &client) && + !(moveresize_in_progress && moveresize_event(e))) + { + if (moveresize_in_progress) /* make further actions work on the client being moved/resized */ client = moveresize_client; - } + menu_can_hide = FALSE; ob_main_loop_timeout_add(ob_main_loop, diff --git a/openbox/keyboard.c b/openbox/keyboard.c index 2c97b93c..cf56ad8f 100644 --- a/openbox/keyboard.c +++ b/openbox/keyboard.c @@ -199,10 +199,8 @@ static void keyboard_interactive_end(guint state, gboolean cancel, Time time, istate.active = FALSE; - if (ungrab) { + if (ungrab) grab_keyboard(FALSE); - grab_pointer(FALSE, FALSE, OB_CURSOR_NONE); - } } static void keyboard_interactive_end_client(ObClient *client, gpointer data) @@ -217,11 +215,8 @@ gboolean keyboard_interactive_grab(guint state, ObClient *client, g_assert(action->data.any.interactive); if (!istate.active) { - grab_pointer(TRUE, FALSE, OB_CURSOR_POINTER); - if (!grab_keyboard(TRUE)) { - grab_pointer(FALSE, FALSE, OB_CURSOR_NONE); + if (!grab_keyboard(TRUE)) return FALSE; - } } else if (action->func != istate.action->func) { keyboard_interactive_end(state, FALSE, action->data.any.time, FALSE); } @@ -241,23 +236,26 @@ gboolean keyboard_process_interactive_grab(const XEvent *e, ObClient **client) gboolean cancel = FALSE; if (istate.active) { - if ((e->type == KeyRelease && !(istate.state & e->xkey.state))) + if ((e->type == KeyRelease && !(istate.state & e->xkey.state))) { done = TRUE; - else if (e->type == KeyPress) { + handled = TRUE; + } else if (e->type == KeyPress) { /*if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) done = TRUE; - else */if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) + else */if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) { cancel = done = TRUE; + handled = TRUE; + } } else if (e->type == ButtonPress) { cancel = FALSE; done = TRUE; + handled = FALSE; } - if (done) { + if (done) keyboard_interactive_end(e->xkey.state, cancel, e->xkey.time,TRUE); - handled = TRUE; - } else + if (handled) *client = istate.client; } diff --git a/openbox/moveresize.c b/openbox/moveresize.c index eba21066..afd0de2a 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -395,8 +395,10 @@ static void calc_resize(gboolean resist) moveresize_client->frame->size.bottom; } -void moveresize_event(XEvent *e) +gboolean moveresize_event(XEvent *e) { + gboolean used = FALSE; + g_assert(moveresize_in_progress); if (e->type == ButtonPress) { @@ -405,10 +407,12 @@ void moveresize_event(XEvent *e) start_y = e->xbutton.y_root; button = e->xbutton.button; /* this will end it now */ } + used = TRUE; } else if (e->type == ButtonRelease) { if (!button || e->xbutton.button == button) { moveresize_end(FALSE); } + used = TRUE; } else if (e->type == MotionNotify) { if (moving) { cur_x = start_cx + e->xmotion.x_root - start_x; @@ -459,12 +463,19 @@ void moveresize_event(XEvent *e) calc_resize(TRUE); do_resize(); } + used = TRUE; } else if (e->type == KeyPress) { - if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) + if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) { moveresize_end(TRUE); - else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) + used = TRUE; + } else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) { moveresize_end(FALSE); - else { + used = TRUE; + } else if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT) || + e->xkey.keycode == ob_keycode(OB_KEY_LEFT) || + e->xkey.keycode == ob_keycode(OB_KEY_DOWN) || + e->xkey.keycode == ob_keycode(OB_KEY_UP)) + { if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { gint dx = 0, dy = 0, ox = cur_x, oy = cur_y; @@ -474,10 +485,8 @@ void moveresize_event(XEvent *e) dx = -MAX(4, moveresize_client->size_inc.width); else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN)) dy = MAX(4, moveresize_client->size_inc.height); - else if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) + else /* if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) */ dy = -MAX(4, moveresize_client->size_inc.height); - else - return; cur_x += dx; cur_y += dy; @@ -497,6 +506,8 @@ void moveresize_event(XEvent *e) actually is */ start_x += dx - (cur_x - ox); start_y += dy - (cur_y - oy); + + used = TRUE; } else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) { gint dx = 0, dy = 0, ox = cur_x, oy = cur_y; gint opx, px, opy, py; @@ -507,10 +518,8 @@ void moveresize_event(XEvent *e) dx = -4; else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN)) dy = 4; - else if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) + else /* if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) */ dy = -4; - else - return; cur_x += dx; cur_y += dy; @@ -532,6 +541,8 @@ void moveresize_event(XEvent *e) actually is */ start_x += (px - opx) - (cur_x - ox); start_y += (py - opy) - (cur_y - oy); + + used = TRUE; } } } @@ -540,6 +551,8 @@ void moveresize_event(XEvent *e) { waiting_for_sync = FALSE; /* we got our sync... */ do_resize(); /* ...so try resize if there is more change pending */ + used = TRUE; } #endif + return used; } diff --git a/openbox/moveresize.h b/openbox/moveresize.h index 410b5544..ec5ce10d 100644 --- a/openbox/moveresize.h +++ b/openbox/moveresize.h @@ -40,6 +40,6 @@ void moveresize_start(struct _ObClient *c, gint x, gint y, guint button, guint32 corner); void moveresize_end(gboolean cancel); -void moveresize_event(XEvent *e); +gboolean moveresize_event(XEvent *e); #endif -- 2.45.2