Merge branch 'backport' into work
[dana/openbox.git] / openbox / prompt.c
index 6084d79..d4dcbb7 100644 (file)
 #include "prompt.h"
 #include "openbox.h"
 #include "screen.h"
 #include "prompt.h"
 #include "openbox.h"
 #include "screen.h"
-#include "openbox.h"
 #include "client.h"
 #include "group.h"
 #include "client.h"
 #include "group.h"
-#include "prop.h"
-#include "modkeys.h"
 #include "event.h"
 #include "event.h"
+#include "obt/display.h"
+#include "obt/keyboard.h"
+#include "obt/prop.h"
 #include "gettext.h"
 
 static GList *prompt_list = NULL;
 #include "gettext.h"
 
 static GList *prompt_list = NULL;
@@ -149,9 +149,8 @@ ObPrompt* prompt_new(const gchar *msg,
     self->data = data;
     self->default_result = default_result;
     self->cancel_result = cancel_result;
     self->data = data;
     self->default_result = default_result;
     self->cancel_result = cancel_result;
-    self->super.type = Window_Prompt;
-    self->super.window = XCreateWindow(ob_display,
-                                       RootWindow(ob_display, ob_screen),
+    self->super.type = OB_WINDOW_CLASS_PROMPT;
+    self->super.window = XCreateWindow(obt_display, obt_root(ob_screen),
                                        0, 0, 1, 1, 0,
                                        CopyFromParent, InputOutput,
                                        CopyFromParent,
                                        0, 0, 1, 1, 0,
                                        CopyFromParent, InputOutput,
                                        CopyFromParent,
@@ -159,19 +158,19 @@ ObPrompt* prompt_new(const gchar *msg,
                                        &attrib);
 
     /* make it a dialog type window */
                                        &attrib);
 
     /* make it a dialog type window */
-    PROP_SET32(self->super.window, net_wm_window_type, atom,
-               prop_atoms.net_wm_window_type_dialog);
+    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;
 
     /* set up the text message widow */
     self->msg.text = g_strdup(msg);
 
     /* listen for key presses on the window */
     self->event_mask = KeyPressMask;
 
     /* set up the text message widow */
     self->msg.text = g_strdup(msg);
-    self->msg.window = XCreateWindow(ob_display, self->super.window,
+    self->msg.window = XCreateWindow(obt_display, self->super.window,
                                      0, 0, 1, 1, 0,
                                      CopyFromParent, InputOutput,
                                      CopyFromParent, 0, NULL);
                                      0, 0, 1, 1, 0,
                                      CopyFromParent, InputOutput,
                                      CopyFromParent, 0, NULL);
-    XMapWindow(ob_display, self->msg.window);
+    XMapWindow(obt_display, self->msg.window);
 
     /* set up the buttons from the answers */
 
 
     /* set up the buttons from the answers */
 
@@ -194,16 +193,15 @@ ObPrompt* prompt_new(const gchar *msg,
     }
 
     for (i = 0; i < self->n_buttons; ++i) {
     }
 
     for (i = 0; i < self->n_buttons; ++i) {
-        self->button[i].window = XCreateWindow(ob_display, self->super.window,
+        self->button[i].window = XCreateWindow(obt_display, self->super.window,
                                                0, 0, 1, 1, 0,
                                                CopyFromParent, InputOutput,
                                                CopyFromParent, 0, NULL);
                                                0, 0, 1, 1, 0,
                                                CopyFromParent, InputOutput,
                                                CopyFromParent, 0, NULL);
-        XMapWindow(ob_display, self->button[i].window);
-        g_hash_table_insert(window_map, &self->button[i].window,
-                            PROMPT_AS_WINDOW(self));
+        XMapWindow(obt_display, self->button[i].window);
+        window_add(&self->button[i].window, PROMPT_AS_WINDOW(self));
 
         /* listen for button presses on the buttons */
 
         /* listen for button presses on the buttons */
-        XSelectInput(ob_display, self->button[i].window,
+        XSelectInput(obt_display, self->button[i].window,
                      ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
     }
 
                      ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
     }
 
@@ -228,12 +226,12 @@ void prompt_unref(ObPrompt *self)
         prompt_list = g_list_remove(prompt_list, self);
 
         for (i = 0; i < self->n_buttons; ++i) {
         prompt_list = g_list_remove(prompt_list, self);
 
         for (i = 0; i < self->n_buttons; ++i) {
-            g_hash_table_remove(window_map, &self->button[i].window);
-            XDestroyWindow(ob_display, self->button[i].window);
+            window_remove(self->button[i].window);
+            XDestroyWindow(obt_display, self->button[i].window);
         }
 
         }
 
-        XDestroyWindow(ob_display, self->msg.window);
-        XDestroyWindow(ob_display, self->super.window);
+        XDestroyWindow(obt_display, self->msg.window);
+        XDestroyWindow(obt_display, self->super.window);
         g_free(self);
     }
 }
         g_free(self);
     }
 }
@@ -316,11 +314,11 @@ static void prompt_layout(ObPrompt *self)
     prompt_resize(self, w + l + r, h + t + b);
 
     /* move and resize the internal windows */
     prompt_resize(self, w + l + r, h + t + b);
 
     /* move and resize the internal windows */
-    XMoveResizeWindow(ob_display, self->msg.window,
+    XMoveResizeWindow(obt_display, self->msg.window,
                       self->msg.x, self->msg.y,
                       self->msg.width, self->msg.height);
     for (i = 0; i < self->n_buttons; ++i)
                       self->msg.x, self->msg.y,
                       self->msg.width, self->msg.height);
     for (i = 0; i < self->n_buttons; ++i)
-        XMoveResizeWindow(ob_display, self->button[i].window,
+        XMoveResizeWindow(obt_display, self->button[i].window,
                           self->button[i].x, self->button[i].y,
                           self->button[i].width, self->button[i].height);
 }
                           self->button[i].x, self->button[i].y,
                           self->button[i].width, self->button[i].height);
 }
@@ -337,13 +335,13 @@ static void prompt_resize(ObPrompt *self, gint w, gint h)
     hints.flags = PMinSize | PMaxSize;
     hints.min_width = hints.max_width = w;
     hints.min_height = hints.max_height = h;
     hints.flags = PMinSize | PMaxSize;
     hints.min_width = hints.max_width = w;
     hints.min_height = hints.max_height = h;
-    XSetWMNormalHints(ob_display, self->super.window, &hints);
+    XSetWMNormalHints(obt_display, self->super.window, &hints);
 
     if (self->mapped) {
         /* send a configure request like a normal client would */
         req.type = ConfigureRequest;
 
     if (self->mapped) {
         /* send a configure request like a normal client would */
         req.type = ConfigureRequest;
-        req.display = ob_display;
-        req.parent = RootWindow(ob_display, ob_screen);
+        req.display = obt_display;
+        req.parent = obt_root(ob_screen);
         req.window = self->super.window;
         req.width = w;
         req.height = h;
         req.window = self->super.window;
         req.width = w;
         req.height = h;
@@ -352,7 +350,7 @@ static void prompt_resize(ObPrompt *self, gint w, gint h)
                    (XEvent*)&req);
     }
     else
                    (XEvent*)&req);
     }
     else
-        XResizeWindow(ob_display, self->super.window, w, h);
+        XResizeWindow(obt_display, self->super.window, w, h);
 }
 
 static void setup_button_focus_tex(ObPromptElement *e, RrAppearance *a,
 }
 
 static void setup_button_focus_tex(ObPromptElement *e, RrAppearance *a,
@@ -446,11 +444,11 @@ void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
 
     if (self->mapped) {
         /* activate the prompt */
 
     if (self->mapped) {
         /* activate the prompt */
-        PROP_MSG(self->super.window, net_active_window,
-                 1, /* from an application.. */
-                 event_curtime,
-                 0,
-                 0);
+        OBT_PROP_MSG(ob_screen, self->super.window, NET_ACTIVE_WINDOW,
+                     1, /* from an application.. */
+                     event_curtime,
+                     0,
+                     0, 0);
         return;
     }
 
         return;
     }
 
@@ -472,7 +470,7 @@ void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
             /* make it transient for the window's group */
             h.flags = WindowGroupHint;
             h.window_group = parent->group->leader;
             /* make it transient for the window's group */
             h.flags = WindowGroupHint;
             h.window_group = parent->group->leader;
-            p = RootWindow(ob_display, ob_screen);
+            p = obt_root(ob_screen);
         }
         else {
             /* make it transient for the window directly */
         }
         else {
             /* make it transient for the window directly */
@@ -480,15 +478,16 @@ void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
             p = parent->window;
         }
 
             p = parent->window;
         }
 
-        XSetWMHints(ob_display, self->super.window, &h);
-        PROP_SET32(self->super.window, wm_transient_for, window, p);
+        XSetWMHints(obt_display, self->super.window, &h);
+        OBT_PROP_SET32(self->super.window, WM_TRANSIENT_FOR, WINDOW, p);
 
 
-        states[0] = prop_atoms.net_wm_state_modal;
+        states[0] = OBT_PROP_ATOM(NET_WM_STATE_MODAL);
         nstates = (modal ? 1 : 0);
         nstates = (modal ? 1 : 0);
-        PROP_SETA32(self->super.window, net_wm_state, atom, states, nstates);
+        OBT_PROP_SETA32(self->super.window, NET_WM_STATE, ATOM,
+                        states, nstates);
     }
     else
     }
     else
-        PROP_ERASE(self->super.window, wm_transient_for);
+        OBT_PROP_ERASE(self->super.window, WM_TRANSIENT_FOR);
 
     /* set up the dialog and render it */
     prompt_layout(self);
 
     /* set up the dialog and render it */
     prompt_layout(self);
@@ -501,7 +500,7 @@ void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
 
 void prompt_hide(ObPrompt *self)
 {
 
 void prompt_hide(ObPrompt *self)
 {
-    XUnmapWindow(ob_display, self->super.window);
+    XUnmapWindow(obt_display, self->super.window);
     self->mapped = FALSE;
 }
 
     self->mapped = FALSE;
 }
 
@@ -512,7 +511,7 @@ gboolean prompt_key_event(ObPrompt *self, XEvent *e)
 
     if (e->type != KeyPress) return FALSE;
 
 
     if (e->type != KeyPress) return FALSE;
 
-    shift_mask = modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT);
+    shift_mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT);
     shift = !!(e->xkey.state & shift_mask);
 
     /* only accept shift */
     shift = !!(e->xkey.state & shift_mask);
 
     /* only accept shift */