X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fprompt.c;h=1c7e2261e25bc20f1ceae2e6dda97216f3751868;hb=972e1fc5a32e7d798fb3023012e73af20b5b03c7;hp=ba5228a1ce9623feaa0fd11a4bdee096edc70bc7;hpb=c7af49b5c564d6287a0293ae26fc713fb55b4dc8;p=chaz%2Fopenbox diff --git a/openbox/prompt.c b/openbox/prompt.c index ba5228a1..1c7e2261 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -23,6 +23,7 @@ #include "client.h" #include "prop.h" #include "modkeys.h" +#include "event.h" #include "gettext.h" static GList *prompt_list = NULL; @@ -332,7 +333,15 @@ void prompt_show(ObPrompt *self, ObClient *parent) XSizeHints hints; gint i; - if (self->mapped) return; + if (self->mapped) { + /* activate the prompt */ + PROP_MSG(self->super.window, net_active_window, + 1, /* from an application.. */ + event_curtime, + 0, + 0); + return; + } /* set the focused button (if not found then the first button is used) */ self->focus = &self->button[0]; @@ -348,8 +357,8 @@ void prompt_show(ObPrompt *self, ObClient *parent) hints.min_height = hints.max_height = self->height; XSetWMNormalHints(ob_display, self->super.window, &hints); - XSetTransientForHint(ob_display, (parent ? parent->window : 0), - self->super.window); + XSetTransientForHint(ob_display, self->super.window, + (parent ? parent->window : 0)); /* set up the dialog and render it */ prompt_layout(self); @@ -366,12 +375,12 @@ void prompt_hide(ObPrompt *self) self->mapped = FALSE; } -void prompt_key_event(ObPrompt *self, XEvent *e) +gboolean prompt_key_event(ObPrompt *self, XEvent *e) { gboolean shift; guint shift_mask; - if (e->type != KeyPress) return; + if (e->type != KeyPress) return FALSE; g_print("key 0x%x 0x%x\n", e->xkey.keycode, ob_keycode(OB_KEY_TAB)); @@ -380,23 +389,31 @@ void prompt_key_event(ObPrompt *self, XEvent *e) /* only accept shift */ if (e->xkey.state != 0 && e->xkey.state != shift_mask) - return; + return FALSE; if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) prompt_cancel(self); - else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) { + else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN) || + e->xkey.keycode == ob_keycode(OB_KEY_SPACE)) + { if (self->func) self->func(self, self->focus->result, self->data); prompt_hide(self); } - else if (e->xkey.keycode == ob_keycode(OB_KEY_TAB)) { + else if (e->xkey.keycode == ob_keycode(OB_KEY_TAB) || + e->xkey.keycode == ob_keycode(OB_KEY_LEFT) || + e->xkey.keycode == ob_keycode(OB_KEY_RIGHT)) + { gint i; + gboolean left; ObPromptElement *oldfocus; + left = e->xkey.keycode == ob_keycode(OB_KEY_LEFT) || + (e->xkey.keycode == ob_keycode(OB_KEY_TAB) && shift); oldfocus = self->focus; for (i = 0; i < self->n_buttons; ++i) if (self->focus == &self->button[i]) break; - i += (shift ? -1 : 1); + i += (left ? -1 : 1); if (i < 0) i = self->n_buttons - 1; else if (i >= self->n_buttons) i = 0; self->focus = &self->button[i]; @@ -404,17 +421,19 @@ void prompt_key_event(ObPrompt *self, XEvent *e) if (oldfocus != self->focus) render_button(self, oldfocus); render_button(self, self->focus); } + return TRUE; } -void prompt_mouse_event(ObPrompt *self, XEvent *e) +gboolean prompt_mouse_event(ObPrompt *self, XEvent *e) { gint i; ObPromptElement *but; if (e->type != ButtonPress && e->type != ButtonRelease && - e->type != MotionNotify) return; + e->type != MotionNotify) return FALSE; /* find the button */ + but = NULL; for (i = 0; i < self->n_buttons; ++i) if (self->button[i].window == (e->type == MotionNotify ? e->xmotion.window : e->xbutton.window)) @@ -422,7 +441,7 @@ void prompt_mouse_event(ObPrompt *self, XEvent *e) but = &self->button[i]; break; } - g_assert(but != NULL); + if (!but) return FALSE; if (e->type == ButtonPress) { ObPromptElement *oldfocus; @@ -452,6 +471,7 @@ void prompt_mouse_event(ObPrompt *self, XEvent *e) render_button(self, but); } } + return TRUE; } void prompt_cancel(ObPrompt *self)