]> 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, 14 Feb 2008 19:24:07 +0000 (14:24 -0500)
openbox/client.c
openbox/event.c
openbox/prompt.c
openbox/prompt.h

index cd26debb5fbff3d5d9c73c1c82e202941da45d34..500562b0423a329e894f8fc6a2f3724978a0557d 100644 (file)
@@ -270,10 +270,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(ob_display, window,
                             CWEventMask|CWDontPropagate, &attrib_set);
index b26439166deee447ebec7db08a93c73f436f359c..ddf78e4fb48e261edd29cea9b0d3a0759d03ff65 100644 (file)
@@ -478,6 +478,8 @@ static void event_process(const XEvent *ec, gpointer data)
             break;
         case Window_Client:
             client = WINDOW_AS_CLIENT(obwin);
+            /* events on clients can be events on prompt windows too */
+            prompt = client->prompt;
             break;
         case Window_Menu:
             /* not to be used for events */
@@ -1677,7 +1679,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 a72b6a444116c3d9a250bc88c722ba9f6d36d945..73f0ba3385543be7631638e3f99d57f47024f65e 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;
@@ -113,6 +117,9 @@ ObPrompt* prompt_new(const gchar *msg, const gchar *const *answers)
     PROP_SET32(self->super.window, net_wm_window_type, atom,
                prop_atoms.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);
@@ -200,6 +207,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);
@@ -232,6 +241,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);
     }
@@ -280,7 +292,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;
index 02c1edd7e7e4aafbe5ff10e6a519cc06757a00d9..b31a0c04655a58018331e15b36deeeebf86003c5 100644 (file)
@@ -41,6 +41,8 @@ struct _ObPrompt
     InternalWindow 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.032396 seconds and 4 git commands to generate.