X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Fprompt.c;h=aa5eb06f0ed4cf3db46c215364792e718d3b019b;hb=f86fa2b3b49b1e790e84bd041f3e91cb63f369a4;hp=54ea469d921f38912e23c4a01b301f435d8600f0;hpb=0e9cfd7c77d8608a4be29f43413575d9553bf21c;p=chaz%2Fopenbox diff --git a/openbox/prompt.c b/openbox/prompt.c index 54ea469d..aa5eb06f 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -20,6 +20,7 @@ #include "openbox.h" #include "screen.h" #include "client.h" +#include "event.h" #include "obt/display.h" #include "obt/keyboard.h" #include "obt/prop.h" @@ -47,8 +48,8 @@ void prompt_startup(gboolean reconfig) prompt_a_press = RrAppearanceCopy(ob_rr_theme->a_focused_pressed_close); c_button = prompt_a_button->texture[0].data.mask.color; - c_focus = prompt_a_button->texture[0].data.mask.color; - c_press = prompt_a_button->texture[0].data.mask.color; + c_focus = prompt_a_focus->texture[0].data.mask.color; + c_press = prompt_a_press->texture[0].data.mask.color; RrAppearanceRemoveTextures(prompt_a_button); RrAppearanceRemoveTextures(prompt_a_focus); @@ -330,7 +331,15 @@ void prompt_show(ObPrompt *self, ObClient *parent) XSizeHints hints; gint i; - if (self->mapped) return; + if (self->mapped) { + /* activate the prompt */ + OBT_PROP_MSG(ob_screen, self->super.window, NET_ACTIVE_WINDOW, + 1, /* from an application.. */ + event_curtime, + 0, + 0, 0); + return; + } /* set the focused button (if not found then the first button is used) */ self->focus = &self->button[0]; @@ -346,8 +355,8 @@ void prompt_show(ObPrompt *self, ObClient *parent) hints.min_height = hints.max_height = self->height; XSetWMNormalHints(obt_display, self->super.window, &hints); - XSetTransientForHint(obt_display, (parent ? parent->window : 0), - self->super.window); + XSetTransientForHint(obt_display, self->super.window, + (parent ? parent->window : 0)); /* set up the dialog and render it */ prompt_layout(self); @@ -364,35 +373,43 @@ 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; shift_mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT); shift = !!(e->xkey.state & shift_mask); /* 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]; @@ -400,17 +417,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)) @@ -418,7 +437,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; @@ -448,6 +467,7 @@ void prompt_mouse_event(ObPrompt *self, XEvent *e) render_button(self, but); } } + return TRUE; } void prompt_cancel(ObPrompt *self)