diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 18 | ||||
-rw-r--r-- | src/events.c | 2 | ||||
-rw-r--r-- | src/input.c | 21 | ||||
-rw-r--r-- | src/input.h | 2 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/split.c | 13 | ||||
-rw-r--r-- | src/split.h | 2 |
7 files changed, 46 insertions, 16 deletions
diff --git a/src/actions.c b/src/actions.c index 82fac46..8e18bf2 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1381,9 +1381,16 @@ cmd_only (int interactive, void *data) char * cmd_remove (int interactive, void *data) { + screen_info *s = current_screen(); rp_window_frame *frame; - frame = find_frame_next (current_screen()->rp_current_frame); + if (num_frames(s) <= 1) + { + message (" remove: cannot remove only frame "); + return NULL; + } + + frame = find_frame_next (s->rp_current_frame); if (frame) { @@ -1425,9 +1432,11 @@ cmd_resize (int interactive, void *data) XGetInputFocus (dpy, &fwin, &revert); XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); - nbytes = read_key (&c, &mod, buffer, sizeof (buffer)); while (1) { + show_frame_message (" Resize frame "); + nbytes = read_key (&c, &mod, buffer, sizeof (buffer), 1); + if (c == RESIZE_VGROW_KEY && mod == RESIZE_VGROW_MODIFIER) resize_frame_vertically (s->rp_current_frame, defaults.frame_resize_unit); else if (c == RESIZE_VSHRINK_KEY && mod == RESIZE_VSHRINK_MODIFIER) @@ -1441,10 +1450,9 @@ cmd_resize (int interactive, void *data) resize_shrink_to_window (s->rp_current_frame); else if (c == RESIZE_END_KEY && mod == RESIZE_END_MODIFIER) break; - - nbytes = read_key (&c, &mod, buffer, sizeof (buffer)); } + hide_frame_indicator (); XSetInputFocus (dpy, fwin, RevertToPointerRoot, CurrentTime); } else @@ -2914,7 +2922,7 @@ cmd_fselect (int interactive, void *data) /* Read a key. */ XGetInputFocus (dpy, &fwin, &revert); XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); - read_key (&c, &mod, NULL, 0); + read_key (&c, &mod, NULL, 0, 1); XSetInputFocus (dpy, fwin, RevertToPointerRoot, CurrentTime); /* Destroy our number windows and free the array. */ diff --git a/src/events.c b/src/events.c index dd998b5..b656f16 100644 --- a/src/events.c +++ b/src/events.c @@ -375,7 +375,7 @@ handle_key (screen_info *s) rat_grabbed = 1; } - read_key (&keysym, &mod, NULL, 0); + read_key (&keysym, &mod, NULL, 0, 1); XSetInputFocus (dpy, fwin, revert, CurrentTime); if (rat_grabbed) diff --git a/src/input.c b/src/input.c index 6064d93..a5d5461 100644 --- a/src/input.c +++ b/src/input.c @@ -258,18 +258,33 @@ cook_keycode (XKeyEvent *ev, KeySym *keysym, unsigned int *mod, char *keysym_nam } int -read_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int len) +read_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int len, int gobble_rel) { + int key_presses = 0; XEvent ev; int nbytes; + unsigned int keycode; + /* Read a key from the keyboard. */ do { XMaskEvent (dpy, KeyPressMask, &ev); + /* Store the keycode so we can wait for it's corresponding key + release event. */ + keycode = ev.xkey.keycode; *modifiers = ev.xkey.state; nbytes = cook_keycode (&ev.xkey, keysym, modifiers, keysym_name, len, 0); } while (IsModifierKey (*keysym)); + PRINT_DEBUG (("key press events: %d\n", key_presses)); + + /* Gobble the release event for the key we pressed. */ + if (gobble_rel) + do + { + XMaskEvent (dpy, KeyReleaseMask, &ev); + } while (ev.xkey.keycode != keycode); + return nbytes; } @@ -357,7 +372,7 @@ get_more_input (char *prompt, char *preinput) /* XSync (dpy, False); */ - nbytes = read_key (&ch, &modifier, keysym_buf, keysym_bufsize); + nbytes = read_key (&ch, &modifier, keysym_buf, keysym_bufsize, 0); while (ch != XK_Return) { PRINT_DEBUG (("key %ld\n", ch)); @@ -429,7 +444,7 @@ get_more_input (char *prompt, char *preinput) update_input_window(s, prompt, str, cur_len); } - nbytes = read_key (&ch, &modifier, keysym_buf, keysym_bufsize); + nbytes = read_key (&ch, &modifier, keysym_buf, keysym_bufsize, 0); } str[cur_len] = 0; diff --git a/src/input.h b/src/input.h index 0544f37..631d4d4 100644 --- a/src/input.h +++ b/src/input.h @@ -26,7 +26,7 @@ char *keysym_to_string (KeySym keysym, unsigned int modifier); int cook_keycode (XKeyEvent *ev, KeySym *keysym, unsigned int *mod, char *keysym_name, int len, int ignore_bad_mods); char *get_input (char *prompt); char *get_more_input (char *prompt, char *preinput); -int read_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int len); +int read_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int len, int gobble_rel); unsigned int x11_mask_to_rp_mask (unsigned int mask); unsigned int rp_mask_to_x11_mask (unsigned int mask); void update_modifier_map (); @@ -680,14 +680,14 @@ init_screen (screen_info *s, int screen_num) s->key_window = XCreateSimpleWindow (dpy, s->root, 0, 0, 1, 1, 0, WhitePixel (dpy, s->screen_num), BlackPixel (dpy, s->screen_num)); - XSelectInput (dpy, s->key_window, KeyPressMask ); + XSelectInput (dpy, s->key_window, KeyPressMask | KeyReleaseMask); XMapWindow (dpy, s->key_window); /* Create the input window. */ s->input_window = XCreateSimpleWindow (dpy, s->root, 0, 0, 1, 1, defaults.bar_border_width, s->fg_color, s->bg_color); - XSelectInput (dpy, s->input_window, KeyPressMask ); + XSelectInput (dpy, s->input_window, KeyPressMask | KeyReleaseMask); /* Create the frame indicator window */ s->frame_window = XCreateSimpleWindow (dpy, s->root, 1, 1, 1, 1, defaults.bar_border_width, diff --git a/src/split.c b/src/split.c index fe1565c..b0d6ff1 100644 --- a/src/split.c +++ b/src/split.c @@ -788,10 +788,17 @@ hide_frame_indicator () void show_frame_indicator () { + show_frame_message (MESSAGE_FRAME_STRING); + alarm (defaults.frame_indicator_timeout); +} + +void +show_frame_message (char *msg) +{ screen_info *s = current_screen (); int width, height; - width = defaults.bar_x_padding * 2 + XTextWidth (defaults.font, MESSAGE_FRAME_STRING, strlen (MESSAGE_FRAME_STRING)); + width = defaults.bar_x_padding * 2 + XTextWidth (defaults.font, msg, strlen (msg)); height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2); XMoveResizeWindow (dpy, current_screen()->frame_window, @@ -808,9 +815,7 @@ show_frame_indicator () XDrawString (dpy, s->frame_window, s->normal_gc, defaults.bar_x_padding, defaults.bar_y_padding + defaults.font->max_bounds.ascent, - MESSAGE_FRAME_STRING, strlen (MESSAGE_FRAME_STRING)); - - alarm (defaults.frame_indicator_timeout); + msg, strlen (msg)); } rp_window_frame * diff --git a/src/split.h b/src/split.h index a9e952d..d7ce710 100644 --- a/src/split.h +++ b/src/split.h @@ -45,6 +45,8 @@ void blank_frame (rp_window_frame *frame); void show_frame_indicator (); void hide_frame_indicator (); +void show_frame_message (char *msg); + rp_window_frame *find_frame_right (rp_window_frame *frame); rp_window_frame *find_frame_left (rp_window_frame *frame); rp_window_frame *find_frame_down (rp_window_frame *frame); |