Merge branch 'backport' into work
[mikachu/openbox.git] / openbox / prompt.c
index 0278757..7c19bcb 100644 (file)
 #include "prompt.h"
 #include "openbox.h"
 #include "screen.h"
-#include "openbox.h"
 #include "client.h"
 #include "group.h"
-#include "prop.h"
-#include "modkeys.h"
 #include "event.h"
+#include "obt/display.h"
+#include "obt/keyboard.h"
+#include "obt/prop.h"
 #include "gettext.h"
 
 static GList *prompt_list = NULL;
@@ -145,9 +145,8 @@ ObPrompt* prompt_new(const gchar *msg,
     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,
@@ -155,19 +154,19 @@ ObPrompt* prompt_new(const gchar *msg,
                                        &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);
-    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);
-    XMapWindow(ob_display, self->msg.window);
+    XMapWindow(obt_display, self->msg.window);
 
     /* set up the buttons from the answers */
 
@@ -190,16 +189,15 @@ ObPrompt* prompt_new(const gchar *msg,
     }
 
     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);
-        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 */
-        XSelectInput(ob_display, self->button[i].window,
+        XSelectInput(obt_display, self->button[i].window,
                      ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
     }
 
@@ -221,12 +219,12 @@ void prompt_unref(ObPrompt *self)
         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);
     }
 }
@@ -309,11 +307,11 @@ static void prompt_layout(ObPrompt *self)
     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)
-        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);
 }
@@ -330,13 +328,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;
-    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;
-        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;
@@ -345,7 +343,7 @@ static void prompt_resize(ObPrompt *self, gint w, gint h)
                    (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,
@@ -439,11 +437,11 @@ void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
 
     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;
     }
 
@@ -465,7 +463,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;
-            p = RootWindow(ob_display, ob_screen);
+            p = obt_root(ob_screen);
         }
         else {
             /* make it transient for the window directly */
@@ -473,15 +471,16 @@ void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
             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);
-        PROP_SETA32(self->super.window, net_wm_state, atom, states, nstates);
+        OBT_PROP_SETA32(self->super.window, NET_WM_STATE, ATOM,
+                        states, nstates);
     }
     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);
@@ -494,7 +493,7 @@ void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
 
 void prompt_hide(ObPrompt *self)
 {
-    XUnmapWindow(ob_display, self->super.window);
+    XUnmapWindow(obt_display, self->super.window);
     self->mapped = FALSE;
 }
 
@@ -505,7 +504,7 @@ gboolean prompt_key_event(ObPrompt *self, XEvent *e)
 
     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 */