]> Dogcows Code - chaz/openbox/commitdiff
key input works for ObPrompt windows now
authorDana Jansens <danakj@orodu.net>
Thu, 7 Feb 2008 04:44:15 +0000 (23:44 -0500)
committerDana Jansens <danakj@orodu.net>
Thu, 7 Feb 2008 07:14:44 +0000 (02:14 -0500)
openbox/client.c
openbox/event.c
openbox/prompt.c
openbox/prompt.h

index 272d42b3d8cbaea8352b40e7431f141af154589d..33be03dec4c419eecc84c3bcef7f4b1d03ad4366 100644 (file)
@@ -189,10 +189,10 @@ void client_manage(Window window, ObPrompt *prompt)
 
     map_time = event_get_server_time();
 
-    /* choose the events we want to receive on the CLIENT window */
-    attrib_set.event_mask = CLIENT_EVENTMASK;
-    if (prompt)
-        attrib_set.event_mask |= KeyPressMask;
+    /* choose the events we want to receive on the CLIENT window
+       (ObPrompt windows can request events too) */
+    attrib_set.event_mask = CLIENT_EVENTMASK |
+        (prompt ? prompt->event_mask : 0);
     attrib_set.do_not_propagate_mask = CLIENT_NOPROPAGATEMASK;
     XChangeWindowAttributes(obt_display, window,
                             CWEventMask|CWDontPropagate, &attrib_set);
index 8552807674ebec49793615b92b78394e4d585574..3476f6277540da8a07930ae3a68cd27b41699161 100644 (file)
@@ -484,6 +484,8 @@ static void event_process(const XEvent *ec, gpointer data)
             break;
         case OB_WINDOW_CLASS_CLIENT:
             client = WINDOW_AS_CLIENT(obwin);
+            /* events on clients can be events on prompt windows too */
+            prompt = client->prompt;
             break;
         case OB_WINDOW_CLASS_MENUFRAME:
             menu = WINDOW_AS_MENUFRAME(obwin);
@@ -1682,7 +1684,6 @@ static ObMenuFrame* find_active_or_last_menu(void)
 
 static void event_handle_prompt(ObPrompt *p, XEvent *e)
 {
-    g_print("prompt event\n");
     switch (e->type) {
     case ButtonPress:
     case ButtonRelease:
index 4b0931cd38911e3e4232c9b10e989fe1291b9450..b9183a9bdc840e26b51097c9bf532176911a1744 100644 (file)
@@ -63,6 +63,10 @@ void prompt_startup(gboolean reconfig)
     prompt_a_focus->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
     prompt_a_press->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
 
+    prompt_a_button->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+    prompt_a_focus->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+    prompt_a_press->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+
     prompt_a_button->texture[0].data.text.color = c_button;
     prompt_a_focus->texture[0].data.text.color = c_focus;
     prompt_a_press->texture[0].data.text.color = c_press;
@@ -112,6 +116,9 @@ ObPrompt* prompt_new(const gchar *msg, const gchar *const *answers)
     OBT_PROP_SET32(self->super.window, NET_WM_WINDOW_TYPE, ATOM,
                    OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG));
 
+    /* listen for key presses on the window */
+    self->event_mask = KeyPressMask;
+
     self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
 
     self->msg.text = g_strdup(msg);
@@ -198,6 +205,8 @@ static void prompt_layout(ObPrompt *self)
     const gint OUTSIDE_MARGIN = 4;
     const gint MSG_BUTTON_SEPARATION = 4;
     const gint BUTTON_SEPARATION = 4;
+    const gint BUTTON_VMARGIN = 4;
+    const gint BUTTON_HMARGIN = 12;
     const gint MAX_WIDTH = 600;
 
     RrMargins(self->a_bg, &l, &t, &r, &b);
@@ -230,6 +239,9 @@ static void prompt_layout(ObPrompt *self)
         self->button[i].width = MAX(self->button[i].width, bw);
         self->button[i].height = MAX(self->button[i].height, bh);
 
+        self->button[i].width += BUTTON_HMARGIN * 2;
+        self->button[i].height += BUTTON_VMARGIN * 2;
+
         allbuttonsw += self->button[i].width + (i > 0 ? BUTTON_SEPARATION : 0);
         allbuttonsh = MAX(allbuttonsh, self->button[i].height);
     }
@@ -278,7 +290,7 @@ static void render_button(ObPrompt *self, ObPromptElement *e)
     RrAppearance *a;
 
     if (e->pressed) a = prompt_a_press;
-    else if (self->focus == e) a = prompt_a_focus, g_print("focus!\n");
+    else if (self->focus == e) a = prompt_a_focus;
     else a = prompt_a_button;
 
     a->surface.parent = self->a_bg;
@@ -343,8 +355,6 @@ void prompt_key_event(ObPrompt *self, XEvent *e)
 
     if (e->type != KeyPress) return;
 
-    g_print("key 0x%x 0x%x\n", e->xkey.keycode, ob_keycode(OB_KEY_TAB));
-
     shift_mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT);
     shift = !!(e->xkey.state & shift_mask);
 
index b0ebad51e6380d9ca19dee53b733e8bc1543b846..09361b0496d795237cca46e8250e7abe849ca89e 100644 (file)
@@ -41,6 +41,8 @@ struct _ObPrompt
     ObInternalWindow super;
     gint ref;
 
+    guint event_mask;
+
     /* keep a copy of this because we re-render things that may need it
        (i.e. the buttons) */
     RrAppearance *a_bg;
This page took 0.030152 seconds and 4 git commands to generate.