summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
Diffstat (limited to 'openbox')
-rw-r--r--openbox/client.c113
-rw-r--r--openbox/client.h23
-rw-r--r--openbox/client_list_combined_menu.c10
-rw-r--r--openbox/client_list_menu.c10
-rw-r--r--openbox/config.c7
-rw-r--r--openbox/config.h5
-rw-r--r--openbox/event.c49
-rw-r--r--openbox/focus.c8
-rw-r--r--openbox/focus_cycle_indicator.c8
-rw-r--r--openbox/menuframe.c5
-rw-r--r--openbox/misc.h2
-rw-r--r--openbox/openbox.c6
-rw-r--r--openbox/place.c5
-rw-r--r--openbox/prompt.c477
-rw-r--r--openbox/prompt.h110
-rw-r--r--openbox/stacking.c9
-rw-r--r--openbox/window.c6
-rw-r--r--openbox/window.h10
18 files changed, 809 insertions, 54 deletions
diff --git a/openbox/client.c b/openbox/client.c
index 6534e1b3..a54feb8b 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -29,6 +29,7 @@
#include "session.h"
#include "event.h"
#include "grab.h"
+#include "prompt.h"
#include "focus.h"
#include "stacking.h"
#include "openbox.h"
@@ -103,6 +104,7 @@ static GSList *client_search_all_top_parents_internal(ObClient *self,
ObStackingLayer layer);
static void client_call_notifies(ObClient *self, GSList *list);
static void client_ping_event(ObClient *self, gboolean dead);
+static void client_prompt_kill(ObClient *self);
void client_startup(gboolean reconfig)
@@ -174,7 +176,7 @@ void client_set_list(void)
stacking_set_list();
}
-void client_manage(Window window)
+void client_manage(Window window, ObPrompt *prompt)
{
ObClient *self;
XSetWindowAttributes attrib_set;
@@ -188,8 +190,10 @@ void client_manage(Window window)
map_time = event_get_server_time();
- /* choose the events we want to receive on the CLIENT window */
- attrib_set.event_mask = CLIENT_EVENTMASK;
+ /* 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);
@@ -199,6 +203,7 @@ void client_manage(Window window)
self = g_new0(ObClient, 1);
self->obwin.type = OB_WINDOW_CLASS_CLIENT;
self->window = window;
+ self->prompt = prompt;
/* non-zero defaults */
self->wmstate = WithdrawnState; /* make sure it gets updated first time */
@@ -217,8 +222,10 @@ void client_manage(Window window)
client_setup_decor_and_functions(self, FALSE);
/* specify that if we exit, the window should not be destroyed and
- should be reparented back to root automatically */
- XChangeSaveSet(obt_display, window, SetModeInsert);
+ should be reparented back to root automatically, unless we are managing
+ an internal ObPrompt window */
+ if (!self->prompt)
+ XChangeSaveSet(obt_display, window, SetModeInsert);
/* create the decoration frame for the client window */
self->frame = frame_new(self);
@@ -616,8 +623,10 @@ void client_unmanage(ObClient *self)
mouse_grab_for_client(self, FALSE);
- /* remove the window from our save set */
- XChangeSaveSet(obt_display, self->window, SetModeDelete);
+ /* remove the window from our save set, unless we are managing an internal
+ ObPrompt window */
+ if (!self->prompt)
+ XChangeSaveSet(obt_display, self->window, SetModeDelete);
/* update the focus lists */
focus_order_remove(self);
@@ -626,6 +635,10 @@ void client_unmanage(ObClient *self)
focus_client = NULL;
}
+ /* if we're prompting to kill the client, close that */
+ prompt_unref(self->kill_prompt);
+ self->kill_prompt = NULL;
+
client_list = g_list_remove(client_list, self);
stacking_remove(self);
window_remove(self->window);
@@ -724,6 +737,7 @@ void client_unmanage(ObClient *self)
g_free(self->wm_command);
g_free(self->title);
g_free(self->icon_title);
+ g_free(self->original_title);
g_free(self->name);
g_free(self->class);
g_free(self->role);
@@ -1879,6 +1893,7 @@ void client_update_title(ObClient *self)
gchar *visible = NULL;
g_free(self->title);
+ g_free(self->original_title);
/* try netwm */
if (!OBT_PROP_GETS(self->window, NET_WM_NAME, utf8, &data)) {
@@ -1895,6 +1910,7 @@ void client_update_title(ObClient *self)
data = g_strdup("Unnamed Window");
}
}
+ self->original_title = g_strdup(data);
if (self->client_machine) {
visible = g_strdup_printf("%s (%s)", data, self->client_machine);
@@ -1904,7 +1920,7 @@ void client_update_title(ObClient *self)
if (self->not_responding) {
data = visible;
- if (self->close_tried_term)
+ if (self->kill_level > 0)
visible = g_strdup_printf("%s - [%s]", data, _("Killing..."));
else
visible = g_strdup_printf("%s - [%s]", data, _("Not Responding"));
@@ -1936,7 +1952,7 @@ void client_update_title(ObClient *self)
if (self->not_responding) {
data = visible;
- if (self->close_tried_term)
+ if (self->kill_level > 0)
visible = g_strdup_printf("%s - [%s]", data, _("Killing..."));
else
visible = g_strdup_printf("%s - [%s]", data, _("Not Responding"));
@@ -3240,9 +3256,14 @@ static void client_ping_event(ObClient *self, gboolean dead)
client_update_title(self);
if (!dead) {
- /* try kill it nicely the first time again, if it started responding
- at some point */
- self->close_tried_term = FALSE;
+ /* it came back to life ! */
+
+ if (self->kill_prompt) {
+ prompt_unref(self->kill_prompt);
+ self->kill_prompt = NULL;
+ }
+
+ self->kill_level = 0;
}
}
@@ -3250,30 +3271,84 @@ void client_close(ObClient *self)
{
if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
+ if (self->prompt) {
+ prompt_cancel(self->prompt);
+ return;
+ }
+
/* in the case that the client provides no means to requesting that it
close, we just kill it */
if (!self->delete_window)
/* don't use client_kill(), we should only kill based on PID in
response to a lack of PING replies */
XKillClient(obt_display, self->window);
- else if (self->not_responding)
- client_kill(self);
- else
+ else {
/* request the client to close with WM_DELETE_WINDOW */
OBT_PROP_MSG_TO(self->window, self->window, WM_PROTOCOLS,
OBT_PROP_ATOM(WM_DELETE_WINDOW), event_curtime,
0, 0, 0, NoEventMask);
+
+ if (self->not_responding)
+ client_prompt_kill(self);
+ }
+}
+
+#define OB_KILL_RESULT_NO 0
+#define OB_KILL_RESULT_YES 1
+
+static void client_kill_requested(ObPrompt *p, gint result, gpointer data)
+{
+ ObClient *self = data;
+
+ if (result == OB_KILL_RESULT_YES)
+ client_kill(self);
+
+ prompt_unref(self->kill_prompt);
+ self->kill_prompt = NULL;
+}
+
+static void client_prompt_kill(ObClient *self)
+{
+ /* check if we're already prompting */
+ if (!self->kill_prompt) {
+ ObPromptAnswer answers[] = {
+ { _("No"), OB_KILL_RESULT_NO },
+ { _("Yes"), OB_KILL_RESULT_YES }
+ };
+ gchar *m;
+ const gchar *sig;
+
+ if (self->kill_level == 0)
+ sig = "terminate";
+ else
+ sig = "kill";
+
+ m = g_strdup_printf
+ (_("The window \"%s\" does not seem to be responding. Do you want to force it to exit by sending the %s signal?"), self->original_title, sig);
+
+ self->kill_prompt = prompt_new(m, answers,
+ sizeof(answers)/sizeof(answers[0]),
+ OB_KILL_RESULT_NO, /* default = no */
+ OB_KILL_RESULT_NO, /* cancel = no */
+ client_kill_requested, self);
+ g_free(m);
+ }
+
+ prompt_show(self->kill_prompt, self);
}
void client_kill(ObClient *self)
{
+ /* don't kill our own windows */
+ if (self->prompt) return;
+
if (!self->client_machine && self->pid) {
/* running on the local host */
- if (!self->close_tried_term) {
+ if (self->kill_level == 0) {
ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
self->window, self->pid);
kill(self->pid, SIGTERM);
- self->close_tried_term = TRUE;
+ ++self->kill_level;
/* show that we're trying to kill it */
client_update_title(self);
@@ -3284,8 +3359,10 @@ void client_kill(ObClient *self)
kill(self->pid, SIGKILL); /* kill -9 */
}
}
- else
+ else {
+ /* running on a remote host */
XKillClient(obt_display, self->window);
+ }
}
void client_hilite(ObClient *self, gboolean hilite)
diff --git a/openbox/client.h b/openbox/client.h
index a27d37c6..dbe93d28 100644
--- a/openbox/client.h
+++ b/openbox/client.h
@@ -37,6 +37,7 @@
struct _ObFrame;
struct _ObGroup;
struct _ObSessionState;
+struct _ObPrompt;
typedef struct _ObClient ObClient;
typedef struct _ObClientIcon ObClientIcon;
@@ -82,6 +83,10 @@ struct _ObClient
ObWindow obwin;
Window window;
+ /*! If this client is managing an ObPrompt window, then this is set to the
+ prompt */
+ struct _ObPrompt *prompt;
+
/*! The window's decorations. NULL while the window is being managed! */
struct _ObFrame *frame;
@@ -115,6 +120,8 @@ struct _ObClient
gchar *title;
/*! Window title when iconified */
gchar *icon_title;
+ /*! The title as requested by the client, without any of our own changes */
+ gchar *original_title;
/*! Hostname of machine running the client */
gchar *client_machine;
/*! The command used to run the program. Pre-XSMP window identification. */
@@ -231,8 +238,11 @@ struct _ObClient
/*! Indicates if the client is trying to close but has stopped responding
to pings */
gboolean not_responding;
+ /*! A prompt shown when you are trying to close a client that is not
+ responding. It asks if you want to kill the client */
+ struct _ObPrompt *kill_prompt;
/*! We tried to close the window with a SIGTERM */
- gboolean close_tried_term;
+ gint kill_level;
#ifdef SYNC
/*! The client wants to sync during resizes */
@@ -322,8 +332,11 @@ typedef void (*ObClientCallback)(ObClient *client, gpointer data);
void client_add_destroy_notify(ObClientCallback func, gpointer data);
void client_remove_destroy_notify(ObClientCallback func);
-/*! Manages a given window */
-void client_manage(Window win);
+/*! Manages a given window
+ @param prompt This specifies an ObPrompt which is being managed. It is
+ possible to manage Openbox-owned windows through this.
+*/
+void client_manage(Window win, struct _ObPrompt *prompt);
/*! Unmanages all managed windows */
void client_unmanage_all();
/*! Unmanages a given client */
@@ -688,7 +701,9 @@ ObClient *client_direct_parent(ObClient *self);
*/
ObClient *client_search_top_direct_parent(ObClient *self);
-/*! Is one client a direct child of another (i.e. not through the group.) */
+/*! Is one client a direct child of another (i.e. not through the group.)
+ This checks more than one level, so there may be another direct child in
+ between */
gboolean client_is_direct_child(ObClient *parent, ObClient *child);
/*! Search for a parent of a client. This only searches up *ONE LEVEL*, and
diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c
index c1572eaf..76a819fc 100644
--- a/openbox/client_list_combined_menu.c
+++ b/openbox/client_list_combined_menu.c
@@ -94,10 +94,12 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
}
}
- menu_add_separator(menu, SEPARATOR, _("Manage desktops"));
- menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE);
- menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"),
- NULL, TRUE);
+ if (config_menu_manage_desktops) {
+ menu_add_separator(menu, SEPARATOR, _("Manage desktops"));
+ menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE);
+ menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"),
+ NULL, TRUE);
+ }
return TRUE; /* always show the menu */
}
diff --git a/openbox/client_list_menu.c b/openbox/client_list_menu.c
index 0febe2e6..e6521a0a 100644
--- a/openbox/client_list_menu.c
+++ b/openbox/client_list_menu.c
@@ -153,10 +153,12 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
desktop_menus = g_slist_append(desktop_menus, submenu);
}
- menu_add_separator(menu, SEPARATOR, NULL);
- menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE);
- menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"),
- NULL, TRUE);
+ if (config_menu_manage_desktops) {
+ menu_add_separator(menu, SEPARATOR, NULL);
+ menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE);
+ menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"),
+ NULL, TRUE);
+ }
return TRUE; /* always show */
}
diff --git a/openbox/config.c b/openbox/config.c
index eaaab536..a268eb5b 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -88,6 +88,7 @@ guint config_menu_hide_delay;
gboolean config_menu_middle;
guint config_submenu_show_delay;
gboolean config_menu_client_list_icons;
+gboolean config_menu_manage_desktops;
GSList *config_menu_files;
@@ -136,6 +137,7 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
if (src->pos_given) {
dst->pos_given = TRUE;
+ dst->pos_force = src->pos_force;
dst->position = src->position;
dst->monitor = src->monitor;
}
@@ -241,6 +243,8 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
settings->monitor = obt_parse_node_int(c) + 1;
g_free(s);
}
+
+ obt_parse_attr_bool(n, "force", &settings->pos_force);
}
if ((n = obt_parse_find_node(app->children, "focus")))
@@ -759,6 +763,8 @@ static void parse_menu(xmlNodePtr node, gpointer d)
config_submenu_show_delay = obt_parse_node_int(n);
if ((n = obt_parse_find_node(node, "applicationIcons")))
config_menu_client_list_icons = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "manageDesktops")))
+ config_menu_manage_desktops = obt_parse_node_bool(n);
}
}
@@ -949,6 +955,7 @@ void config_startup(ObtParseInst *i)
config_menu_middle = FALSE;
config_submenu_show_delay = 0;
config_menu_client_list_icons = TRUE;
+ config_menu_manage_desktops = TRUE;
config_menu_files = NULL;
obt_parse_register(i, "menu", parse_menu, NULL);
diff --git a/openbox/config.h b/openbox/config.h
index 1a60ee0f..cf9eb43e 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -40,6 +40,7 @@ struct _ObAppSettings
GravityPoint position;
gboolean pos_given;
+ gboolean pos_force;
guint desktop;
gint shade;
@@ -175,8 +176,10 @@ extern guint config_menu_hide_delay;
extern gboolean config_menu_middle;
/*! Delay before opening a submenu in milliseconds */
extern guint config_submenu_show_delay;
-/*! show icons in client_list_menu */
+/*! Show icons in client_list_menu */
extern gboolean config_menu_client_list_icons;
+/*! Show manage desktops in client_list_menu */
+extern gboolean config_menu_manage_desktops;
/*! User-specified menu files */
extern GSList *config_menu_files;
/*! Per app settings */
diff --git a/openbox/event.c b/openbox/event.c
index bce1de12..4fbb97c6 100644
--- a/openbox/event.c
+++ b/openbox/event.c
@@ -29,6 +29,7 @@
#include "frame.h"
#include "grab.h"
#include "menu.h"
+#include "prompt.h"
#include "menuframe.h"
#include "keyboard.h"
#include "mouse.h"
@@ -85,11 +86,12 @@ static void event_process(const XEvent *e, gpointer data);
static void event_handle_root(XEvent *e);
static gboolean event_handle_menu_input(XEvent *e);
static void event_handle_menu(ObMenuFrame *frame, XEvent *e);
+static gboolean event_handle_prompt(ObPrompt *p, XEvent *e);
static void event_handle_dock(ObDock *s, XEvent *e);
static void event_handle_dockapp(ObDockApp *app, XEvent *e);
static void event_handle_client(ObClient *c, XEvent *e);
static void event_handle_user_input(ObClient *client, XEvent *e);
-static gboolean is_enter_focus_event_ignored(XEvent *e);
+static gboolean is_enter_focus_event_ignored(gulong serial);
static void event_ignore_enter_range(gulong start, gulong end);
static void focus_delay_dest(gpointer data);
@@ -466,6 +468,7 @@ static void event_process(const XEvent *ec, gpointer data)
ObDockApp *dockapp = NULL;
ObWindow *obwin = NULL;
ObMenuFrame *menu = NULL;
+ ObPrompt *prompt = NULL;
/* make a copy we can mangle */
ee = *ec;
@@ -481,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);
@@ -488,6 +493,9 @@ static void event_process(const XEvent *ec, gpointer data)
case OB_WINDOW_CLASS_INTERNAL:
/* we don't do anything with events directly on these windows */
break;
+ case OB_WINDOW_CLASS_PROMPT:
+ prompt = WINDOW_AS_PROMPT(obwin);
+ break;
}
}
else
@@ -704,7 +712,9 @@ static void event_process(const XEvent *ec, gpointer data)
}
#endif
- if (e->type == ButtonPress || e->type == ButtonRelease) {
+ if (prompt && event_handle_prompt(prompt, e))
+ ;
+ else if (e->type == ButtonPress || e->type == ButtonRelease) {
/* If the button press was on some non-root window, or was physically
on the root window, then process it */
if (window != obt_root(ob_screen) ||
@@ -800,6 +810,12 @@ void event_enter_client(ObClient *client)
{
g_assert(config_focus_follow);
+ if (is_enter_focus_event_ignored(event_curserial)) {
+ ob_debug_type(OB_DEBUG_FOCUS, "Ignoring enter event with serial %lu\n"
+ "on client 0x%x", event_curserial, client->window);
+ return;
+ }
+
if (client_enter_focusable(client) && client_can_focus(client)) {
if (config_focus_delay) {
ObFocusDelayData *data;
@@ -1044,8 +1060,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
if (e->xcrossing.mode == NotifyGrab ||
e->xcrossing.mode == NotifyUngrab ||
/*ignore enters when we're already in the window */
- e->xcrossing.detail == NotifyInferior ||
- is_enter_focus_event_ignored(e))
+ e->xcrossing.detail == NotifyInferior)
{
ob_debug_type(OB_DEBUG_FOCUS,
"%sNotify mode %d detail %d serial %lu on %lx "
@@ -1667,6 +1682,21 @@ static ObMenuFrame* find_active_or_last_menu(void)
return ret;
}
+static gboolean event_handle_prompt(ObPrompt *p, XEvent *e)
+{
+ switch (e->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ return prompt_mouse_event(p, e);
+ break;
+ case KeyPress:
+ return prompt_key_event(p, e);
+ break;
+ }
+ return FALSE;
+}
+
static gboolean event_handle_menu_input(XEvent *ev)
{
gboolean ret = FALSE;
@@ -1967,26 +1997,21 @@ void event_end_ignore_all_enters(gulong start)
event_ignore_enter_range(start, NextRequest(obt_display)-1);
}
-static gboolean is_enter_focus_event_ignored(XEvent *e)
+static gboolean is_enter_focus_event_ignored(gulong serial)
{
GSList *it, *next;
- g_assert(e->type == EnterNotify &&
- !(e->xcrossing.mode == NotifyGrab ||
- e->xcrossing.mode == NotifyUngrab ||
- e->xcrossing.detail == NotifyInferior));
-
for (it = ignore_serials; it; it = next) {
ObSerialRange *r = it->data;
next = g_slist_next(it);
- if ((glong)(e->xany.serial - r->end) > 0) {
+ if ((glong)(serial - r->end) > 0) {
/* past the end */
ignore_serials = g_slist_delete_link(ignore_serials, it);
g_free(r);
}
- else if ((glong)(e->xany.serial - r->start) >= 0)
+ else if ((glong)(serial - r->start) >= 0)
return TRUE;
}
return FALSE;
diff --git a/openbox/focus.c b/openbox/focus.c
index 68b0b7f9..cff81bfb 100644
--- a/openbox/focus.c
+++ b/openbox/focus.c
@@ -57,6 +57,14 @@ void focus_shutdown(gboolean reconfig)
static void push_to_top(ObClient *client)
{
+ ObClient *p;
+
+ /* if it is modal for a single window, then put that window at the top
+ of the focus order first, so it will be right after ours. the same is
+ done with stacking */
+ if (client->modal && (p = client_direct_parent(client)))
+ push_to_top(p);
+
focus_order = g_list_remove(focus_order, client);
focus_order = g_list_prepend(focus_order, client);
}
diff --git a/openbox/focus_cycle_indicator.c b/openbox/focus_cycle_indicator.c
index da5efa56..495a7230 100644
--- a/openbox/focus_cycle_indicator.c
+++ b/openbox/focus_cycle_indicator.c
@@ -59,10 +59,10 @@ void focus_cycle_indicator_startup(gboolean reconfig)
if (reconfig) return;
- focus_indicator.top.obwin.type = OB_WINDOW_CLASS_INTERNAL;
- focus_indicator.left.obwin.type = OB_WINDOW_CLASS_INTERNAL;
- focus_indicator.right.obwin.type = OB_WINDOW_CLASS_INTERNAL;
- focus_indicator.bottom.obwin.type = OB_WINDOW_CLASS_INTERNAL;
+ focus_indicator.top.type = OB_WINDOW_CLASS_INTERNAL;
+ focus_indicator.left.type = OB_WINDOW_CLASS_INTERNAL;
+ focus_indicator.right.type = OB_WINDOW_CLASS_INTERNAL;
+ focus_indicator.bottom.type = OB_WINDOW_CLASS_INTERNAL;
attr.override_redirect = True;
attr.background_pixel = BlackPixel(obt_display, ob_screen);
diff --git a/openbox/menuframe.c b/openbox/menuframe.c
index b48b9280..598bc005 100644
--- a/openbox/menuframe.c
+++ b/openbox/menuframe.c
@@ -386,8 +386,11 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
text_a->texture[0].data.text.shortcut = FALSE;
break;
case OB_MENU_ENTRY_TYPE_SEPARATOR:
- if (self->entry->data.separator.label != NULL)
+ if (self->entry->data.separator.label != NULL) {
text_a = ob_rr_theme->a_menu_text_title;
+ text_a->texture[0].data.text.string =
+ self->entry->data.separator.label;
+ }
else
text_a = ob_rr_theme->a_menu_text_normal;
break;
diff --git a/openbox/misc.h b/openbox/misc.h
index 2b5584d7..c73c9265 100644
--- a/openbox/misc.h
+++ b/openbox/misc.h
@@ -51,6 +51,8 @@ typedef enum
OB_KEY_RIGHT,
OB_KEY_UP,
OB_KEY_DOWN,
+ OB_KEY_TAB,
+ OB_KEY_SPACE,
OB_NUM_KEYS
} ObKey;
diff --git a/openbox/openbox.c b/openbox/openbox.c
index 80f81594..a6a81cef 100644
--- a/openbox/openbox.c
+++ b/openbox/openbox.c
@@ -41,6 +41,7 @@
#include "group.h"
#include "config.h"
#include "ping.h"
+#include "prompt.h"
#include "gettext.h"
#include "render/render.h"
#include "render/theme.h"
@@ -209,6 +210,8 @@ gint main(gint argc, gchar **argv)
keys[OB_KEY_RIGHT] = obt_keyboard_keysym_to_keycode(XK_Right);
keys[OB_KEY_UP] = obt_keyboard_keysym_to_keycode(XK_Up);
keys[OB_KEY_DOWN] = obt_keyboard_keysym_to_keycode(XK_Down);
+ keys[OB_KEY_TAB] = obt_keyboard_keysym_to_keycode(XK_Tab);
+ keys[OB_KEY_SPACE] = obt_keyboard_keysym_to_keycode(XK_space);
{
ObtParseInst *i;
@@ -293,6 +296,7 @@ gint main(gint argc, gchar **argv)
grab_startup(reconfigure);
group_startup(reconfigure);
ping_startup(reconfigure);
+ prompt_startup(reconfigure);
client_startup(reconfigure);
dock_startup(reconfigure);
moveresize_startup(reconfigure);
@@ -349,6 +353,7 @@ gint main(gint argc, gchar **argv)
moveresize_shutdown(reconfigure);
dock_shutdown(reconfigure);
client_shutdown(reconfigure);
+ prompt_shutdown(reconfigure);
ping_shutdown(reconfigure);
group_shutdown(reconfigure);
grab_shutdown(reconfigure);
@@ -558,7 +563,6 @@ static void parse_args(gint *argc, gchar **argv)
}
else if (!strcmp(argv[i], "--config-file")) {
if (i == *argc - 1) /* no args left */
- /* not translated cuz it's sekret */
g_printerr(_("--config-file requires an argument\n"));
else {
/* this will be in the current locale encoding, which is
diff --git a/openbox/place.c b/openbox/place.c
index 9e38bdef..aac40e8a 100644
--- a/openbox/place.c
+++ b/openbox/place.c
@@ -489,8 +489,9 @@ gboolean place_client(ObClient *client, gint *x, gint *y,
gboolean userplaced = FALSE;
/* per-app settings override program specified position
- * but not user specified */
- if ((client->positioned & USPosition) ||
+ * but not user specified, unless pos_force is enabled */
+ if (((client->positioned & USPosition) &&
+ !(settings && settings->pos_given && settings->pos_force)) ||
((client->positioned & PPosition) &&
!(settings && settings->pos_given)))
return FALSE;
diff --git a/openbox/prompt.c b/openbox/prompt.c
new file mode 100644
index 00000000..aa5eb06f
--- /dev/null
+++ b/openbox/prompt.c
@@ -0,0 +1,477 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ prompt.c for the Openbox window manager
+ Copyright (c) 2008 Dana Jansens
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "prompt.h"
+#include "openbox.h"
+#include "screen.h"
+#include "client.h"
+#include "event.h"
+#include "obt/display.h"
+#include "obt/keyboard.h"
+#include "obt/prop.h"
+#include "gettext.h"
+
+static GList *prompt_list = NULL;
+
+/* we construct these */
+static RrAppearance *prompt_a_button;
+static RrAppearance *prompt_a_focus;
+static RrAppearance *prompt_a_press;
+/* we change the max width which would screw with others */
+static RrAppearance *prompt_a_msg;
+
+static void prompt_layout(ObPrompt *self);
+static void render_all(ObPrompt *self);
+static void render_button(ObPrompt *self, ObPromptElement *e);
+
+void prompt_startup(gboolean reconfig)
+{
+ RrColor *c_button, *c_focus, *c_press;
+
+ prompt_a_button = RrAppearanceCopy(ob_rr_theme->a_focused_unpressed_close);
+ prompt_a_focus = RrAppearanceCopy(ob_rr_theme->a_hover_focused_close);
+ 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_focus->texture[0].data.mask.color;
+ c_press = prompt_a_press->texture[0].data.mask.color;
+
+ RrAppearanceRemoveTextures(prompt_a_button);
+ RrAppearanceRemoveTextures(prompt_a_focus);
+ RrAppearanceRemoveTextures(prompt_a_press);
+
+ RrAppearanceAddTextures(prompt_a_button, 1);
+ RrAppearanceAddTextures(prompt_a_focus, 1);
+ RrAppearanceAddTextures(prompt_a_press, 1);
+
+ /* totally cheating here.. */
+ prompt_a_button->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+ 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;
+
+ prompt_a_msg = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
+ prompt_a_msg->texture[0].data.text.flow = TRUE;
+
+ if (reconfig) {
+ GList *it;
+ for (it = prompt_list; it; it = g_list_next(it)) {
+ ObPrompt *p = it->data;
+ prompt_layout(p);
+ render_all(p);
+ }
+ }
+}
+
+void prompt_shutdown(gboolean reconfig)
+{
+ RrAppearanceFree(prompt_a_button);
+ RrAppearanceFree(prompt_a_focus);
+ RrAppearanceFree(prompt_a_press);
+ RrAppearanceFree(prompt_a_msg);
+}
+
+ObPrompt* prompt_new(const gchar *msg,
+ const ObPromptAnswer *answers, gint n_answers,
+ gint default_result, gint cancel_result,
+ ObPromptCallback func, gpointer data)
+{
+ ObPrompt *self;
+ XSetWindowAttributes attrib;
+ gint i;
+
+ attrib.override_redirect = FALSE;
+ attrib.border_pixel = RrColorPixel(ob_rr_theme->osd_border_color);
+
+ self = g_new0(ObPrompt, 1);
+ self->ref = 1;
+ self->func = func;
+ self->data = data;
+ self->default_result = default_result;
+ self->cancel_result = cancel_result;
+ self->super.type = OB_WINDOW_CLASS_PROMPT;
+ self->super.window = XCreateWindow(obt_display, obt_root(ob_screen),
+ 0, 0, 1, 1, ob_rr_theme->obwidth,
+ CopyFromParent, InputOutput,
+ CopyFromParent,
+ CWOverrideRedirect | CWBorderPixel,
+ &attrib);
+
+ /* make it a dialog type window */
+ 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;
+
+ /* we make a copy of this appearance for each prompt */
+ self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
+
+ /* set up the text message widow */
+ self->msg.text = g_strdup(msg);
+ self->msg.window = XCreateWindow(obt_display, self->super.window,
+ 0, 0, 1, 1, 0,
+ CopyFromParent, InputOutput,
+ CopyFromParent, 0, NULL);
+ XMapWindow(obt_display, self->msg.window);
+
+ /* set up the buttons from the answers */
+
+ self->n_buttons = n_answers;
+ if (!self->n_buttons)
+ self->n_buttons = 1;
+
+ self->button = g_new0(ObPromptElement, self->n_buttons);
+
+ if (n_answers == 0) {
+ g_assert(self->n_buttons == 1); /* should be set to this above.. */
+ self->button[0].text = g_strdup(_("OK"));
+ }
+ else {
+ g_assert(self->n_buttons > 0);
+ for (i = 0; i < self->n_buttons; ++i) {
+ self->button[i].text = g_strdup(answers[i].text);
+ self->button[i].result = answers[i].result;
+ }
+ }
+
+ for (i = 0; i < self->n_buttons; ++i) {
+ self->button[i].window = XCreateWindow(obt_display, self->super.window,
+ 0, 0, 1, 1, 0,
+ CopyFromParent, InputOutput,
+ CopyFromParent, 0, NULL);
+ 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(obt_display, self->button[i].window,
+ ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
+ }
+
+ prompt_list = g_list_prepend(prompt_list, self);
+
+ return self;
+}
+
+void prompt_ref(ObPrompt *self)
+{
+ ++self->ref;
+}
+
+void prompt_unref(ObPrompt *self)
+{
+ if (self && --self->ref == 0) {
+ gint i;
+
+ prompt_list = g_list_remove(prompt_list, self);
+
+ for (i = 0; i < self->n_buttons; ++i) {
+ window_remove(self->button[i].window);
+ XDestroyWindow(obt_display, self->button[i].window);
+ }
+
+ XDestroyWindow(obt_display, self->msg.window);
+
+ RrAppearanceFree(self->a_bg);
+
+ XDestroyWindow(obt_display, self->super.window);
+ g_free(self);
+ }
+}
+
+static void prompt_layout(ObPrompt *self)
+{
+ gint l, r, t, b;
+ gint i;
+ gint allbuttonsw, allbuttonsh, buttonx;
+ gint w, h;
+ gint maxw;
+
+ 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);
+ l += OUTSIDE_MARGIN;
+ t += OUTSIDE_MARGIN;
+ r += OUTSIDE_MARGIN;
+ b += OUTSIDE_MARGIN;
+
+ {
+ Rect *area = screen_physical_area_all_monitors();
+ maxw = MIN(MAX_WIDTH, area->width*4/5);
+ g_free(area);
+ }
+
+ /* find the button sizes and how much space we need for them */
+ allbuttonsw = allbuttonsh = 0;
+ for (i = 0; i < self->n_buttons; ++i) {
+ gint bw, bh;
+
+ prompt_a_button->texture[0].data.text.string = self->button[i].text;
+ prompt_a_focus->texture[0].data.text.string = self->button[i].text;
+ prompt_a_press->texture[0].data.text.string = self->button[i].text;
+ RrMinSize(prompt_a_button, &bw, &bh);
+ self->button[i].width = bw;
+ self->button[i].height = bh;
+ RrMinSize(prompt_a_focus, &bw, &bh);
+ self->button[i].width = MAX(self->button[i].width, bw);
+ self->button[i].height = MAX(self->button[i].height, bh);
+ RrMinSize(prompt_a_press, &bw, &bh);
+ 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);
+ }
+
+ self->msg_wbound = MAX(allbuttonsw, maxw);
+
+ /* measure the text message area */
+ prompt_a_msg->texture[0].data.text.string = self->msg.text;
+ prompt_a_msg->texture[0].data.text.maxwidth = self->msg_wbound;
+ RrMinSize(prompt_a_msg, &self->msg.width, &self->msg.height);
+
+ /* width and height inside the outer margins */
+ w = MAX(self->msg.width, allbuttonsw);
+ h = self->msg.height + MSG_BUTTON_SEPARATION + allbuttonsh;
+
+ /* position the text message */
+ self->msg.x = l + (w - self->msg.width) / 2;
+ self->msg.y = t;
+
+ /* position the button buttons on the right of the dialog */
+ buttonx = l + w;
+ for (i = self->n_buttons - 1; i >= 0; --i) {
+ self->button[i].x = buttonx - self->button[i].width;
+ buttonx -= self->button[i].width + BUTTON_SEPARATION;
+ self->button[i].y = t + h - allbuttonsh;
+ self->button[i].y += (allbuttonsh - self->button[i].height) / 2;
+ }
+
+ /* size and position the toplevel window */
+ self->width = w + l + r;
+ self->height = h + t + b;
+
+ /* move and resize the actual windows */
+ XResizeWindow(obt_display, self->super.window, self->width, self->height);
+ 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(obt_display, self->button[i].window,
+ self->button[i].x, self->button[i].y,
+ self->button[i].width, self->button[i].height);
+}
+
+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;
+ else a = prompt_a_button;
+
+ a->surface.parent = self->a_bg;
+ a->surface.parentx = e->x;
+ a->surface.parentx = e->y;
+
+ a->texture[0].data.text.string = e->text;
+ RrPaint(a, e->window, e->width, e->height);
+}
+
+static void render_all(ObPrompt *self)
+{
+ gint i;
+
+ RrPaint(self->a_bg, self->super.window, self->width, self->height);
+
+ prompt_a_msg->surface.parent = self->a_bg;
+ prompt_a_msg->surface.parentx = self->msg.x;
+ prompt_a_msg->surface.parenty = self->msg.y;
+
+ prompt_a_msg->texture[0].data.text.string = self->msg.text;
+ prompt_a_msg->texture[0].data.text.maxwidth = self->msg_wbound;
+ RrPaint(prompt_a_msg, self->msg.window, self->msg.width, self->msg.height);
+
+ for (i = 0; i < self->n_buttons; ++i)
+ render_button(self, &self->button[i]);
+}
+
+void prompt_show(ObPrompt *self, ObClient *parent)
+{
+ XSizeHints hints;
+ gint i;
+
+ 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];
+ for (i = 0; i < self->n_buttons; ++i)
+ if (self->button[i].result == self->default_result) {
+ self->focus = &self->button[i];
+ break;
+ }
+
+ /* you can't resize the prompt */
+ hints.flags = PMinSize | PMaxSize;
+ hints.min_width = hints.max_width = self->width;
+ hints.min_height = hints.max_height = self->height;
+ XSetWMNormalHints(obt_display, self->super.window, &hints);
+
+ XSetTransientForHint(obt_display, self->super.window,
+ (parent ? parent->window : 0));
+
+ /* set up the dialog and render it */
+ prompt_layout(self);
+ render_all(self);
+
+ client_manage(self->super.window, self);
+
+ self->mapped = TRUE;
+}
+
+void prompt_hide(ObPrompt *self)
+{
+ XUnmapWindow(obt_display, self->super.window);
+ self->mapped = FALSE;
+}
+
+gboolean prompt_key_event(ObPrompt *self, XEvent *e)
+{
+ gboolean shift;
+ guint shift_mask;
+
+ 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 FALSE;
+
+ if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
+ prompt_cancel(self);
+ 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) ||
+ 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 += (left ? -1 : 1);
+ if (i < 0) i = self->n_buttons - 1;
+ else if (i >= self->n_buttons) i = 0;
+ self->focus = &self->button[i];
+
+ if (oldfocus != self->focus) render_button(self, oldfocus);
+ render_button(self, self->focus);
+ }
+ return TRUE;
+}
+
+gboolean prompt_mouse_event(ObPrompt *self, XEvent *e)
+{
+ gint i;
+ ObPromptElement *but;
+
+ if (e->type != ButtonPress && e->type != ButtonRelease &&
+ 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))
+ {
+ but = &self->button[i];
+ break;
+ }
+ if (!but) return FALSE;
+
+ if (e->type == ButtonPress) {
+ ObPromptElement *oldfocus;
+
+ oldfocus = self->focus;
+
+ but->pressed = TRUE;
+ self->focus = but;
+
+ if (oldfocus != but) render_button(self, oldfocus);
+ render_button(self, but);
+ }
+ else if (e->type == ButtonRelease) {
+ if (but->pressed) {
+ if (self->func) self->func(self, but->result, self->data);
+ prompt_hide(self);
+ }
+ }
+ else if (e->type == MotionNotify) {
+ gboolean press;
+
+ press = (e->xmotion.x >= 0 && e->xmotion.y >= 0 &&
+ e->xmotion.x < but->width && e->xmotion.y < but->height);
+
+ if (press != but->pressed) {
+ but->pressed = press;
+ render_button(self, but);
+ }
+ }
+ return TRUE;
+}
+
+void prompt_cancel(ObPrompt *self)
+{
+ if (self->func) self->func(self, self->cancel_result, self->data);
+ prompt_hide(self);
+}
diff --git a/openbox/prompt.h b/openbox/prompt.h
new file mode 100644
index 00000000..1bcd66cc
--- /dev/null
+++ b/openbox/prompt.h
@@ -0,0 +1,110 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ prompt.h for the Openbox window manager
+ Copyright (c) 2008 Dana Jansens
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef ob__prompt_h
+#define ob__prompt_h
+
+#include "window.h"
+#include "geom.h"
+#include "render/render.h"
+#include <glib.h>
+#include <X11/Xlib.h>
+
+typedef struct _ObPrompt ObPrompt;
+typedef struct _ObPromptElement ObPromptElement;
+typedef struct _ObPromptAnswer ObPromptAnswer;
+
+typedef void (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data);
+
+struct _ObPromptElement {
+ gchar *text;
+ Window window;
+
+ gint x, y, width, height;
+ gboolean pressed;
+ gint result;
+};
+
+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;
+
+ gboolean mapped;
+ gint width, height;
+ gint msg_wbound;
+
+ ObPromptElement msg;
+
+ /* one for each answer */
+ ObPromptElement *button;
+ gint n_buttons;
+
+ /* points to the button with the focus */
+ ObPromptElement *focus;
+ /* the default button to have selected */
+ gint default_result;
+ /* the cancel result if the dialog is closed */
+ gint cancel_result;
+
+ ObPromptCallback func;
+ gpointer data;
+};
+
+struct _ObPromptAnswer {
+ const gchar *text;
+ gint result;
+};
+
+void prompt_startup(gboolean reconfig);
+void prompt_shutdown(gboolean reconfig);
+
+/*! Create a new prompt
+ @param answers A number of ObPromptAnswers which define the buttons which
+ will appear in the dialog from left to right, and the result
+ returned when they are selected.
+ @param n_answers The number of answers
+ @param default_result The result for the answer button selected by default
+ @param cancel_result The result that is given if the dialog is closed instead
+ of having a button presssed
+ @param func The callback function which is called when the dialog is closed
+ or a button is pressed
+ @param data User defined data which will be passed to the callback
+*/
+ObPrompt* prompt_new(const gchar *msg,
+ const ObPromptAnswer *answers, gint n_answers,
+ gint default_result, gint cancel_result,
+ ObPromptCallback func, gpointer data);
+void prompt_ref(ObPrompt *self);
+void prompt_unref(ObPrompt *self);
+
+/*! Show the prompt. It will be centered within the given area rectangle */
+void prompt_show(ObPrompt *self, struct _ObClient *parent);
+void prompt_hide(ObPrompt *self);
+
+gboolean prompt_key_event(ObPrompt *self, XEvent *e);
+gboolean prompt_mouse_event(ObPrompt *self, XEvent *e);
+void prompt_cancel(ObPrompt *self);
+
+#endif
diff --git a/openbox/stacking.c b/openbox/stacking.c
index 03a62dd4..3c05df49 100644
--- a/openbox/stacking.c
+++ b/openbox/stacking.c
@@ -221,6 +221,15 @@ static void restack_windows(ObClient *selected, gboolean raise)
GList *modals = NULL;
GList *trans = NULL;
+ if (raise) {
+ ObClient *p;
+
+ /* if a window is modal for another single window, then raise it to the
+ top too, the same is done with the focus order */
+ while (selected->modal && (p = client_direct_parent(selected)))
+ selected = p;
+ }
+
/* remove first so we can't run into ourself */
it = g_list_find(stacking_list, selected);
g_assert(it);
diff --git a/openbox/window.c b/openbox/window.c
index 28b08571..c8951741 100644
--- a/openbox/window.c
+++ b/openbox/window.c
@@ -23,6 +23,7 @@
#include "client.h"
#include "frame.h"
#include "openbox.h"
+#include "prompt.h"
#include "debug.h"
#include "grab.h"
@@ -57,6 +58,8 @@ Window window_top(ObWindow *self)
return WINDOW_AS_CLIENT(self)->frame->window;
case OB_WINDOW_CLASS_INTERNAL:
return WINDOW_AS_INTERNAL(self)->window;
+ case OB_WINDOW_CLASS_PROMPT:
+ return WINDOW_AS_PROMPT(self)->super.window;
}
g_assert_not_reached();
return None;
@@ -71,6 +74,7 @@ ObStackingLayer window_layer(ObWindow *self)
return ((ObClient*)self)->layer;
case OB_WINDOW_CLASS_MENUFRAME:
case OB_WINDOW_CLASS_INTERNAL:
+ case OB_WINDOW_CLASS_PROMPT:
return OB_STACKING_LAYER_INTERNAL;
}
g_assert_not_reached();
@@ -189,7 +193,7 @@ void window_manage(Window win)
dock_manage(icon_win, win);
}
else
- client_manage(win);
+ client_manage(win, NULL);
}
else {
grab_server(FALSE);
diff --git a/openbox/window.h b/openbox/window.h
index c7bfc895..24a7d07b 100644
--- a/openbox/window.h
+++ b/openbox/window.h
@@ -31,7 +31,8 @@ typedef enum {
OB_WINDOW_CLASS_MENUFRAME,
OB_WINDOW_CLASS_DOCK,
OB_WINDOW_CLASS_CLIENT,
- OB_WINDOW_CLASS_INTERNAL
+ OB_WINDOW_CLASS_INTERNAL,
+ OB_WINDOW_CLASS_PROMPT
} ObWindowClass;
/* In order to be an ObWindow, you need to make this struct the top of your
@@ -48,21 +49,26 @@ struct _ObWindow {
(((ObWindow*)win)->type == OB_WINDOW_CLASS_CLIENT)
#define WINDOW_IS_INTERNAL(win) \
(((ObWindow*)win)->type == OB_WINDOW_CLASS_INTERNAL)
+#define WINDOW_IS_PROMPT(win) \
+ (((ObWindow*)win)->type == OB_WINDOW_CLASS_PROMPT)
struct _ObMenu;
struct _ObDock;
struct _ObDockApp;
struct _ObClient;
+struct _ObPrompt;
#define WINDOW_AS_MENUFRAME(win) ((struct _ObMenuFrame*)win)
#define WINDOW_AS_DOCK(win) ((struct _ObDock*)win)
#define WINDOW_AS_CLIENT(win) ((struct _ObClient*)win)
#define WINDOW_AS_INTERNAL(win) ((struct _ObInternalWindow*)win)
+#define WINDOW_AS_PROMPT(win) ((struct _ObPrompt*)win)
#define MENUFRAME_AS_WINDOW(menu) ((ObWindow*)menu)
#define DOCK_AS_WINDOW(dock) ((ObWindow*)dock)
#define CLIENT_AS_WINDOW(client) ((ObWindow*)client)
#define INTERNAL_AS_WINDOW(intern) ((ObWindow*)intern)
+#define PROMPT_AS_WINDOW(prompt) ((ObWindow*)prompt)
void window_startup (gboolean reconfig);
void window_shutdown(gboolean reconfig);
@@ -76,7 +82,7 @@ void window_remove(Window xwin);
/* Internal openbox-owned windows like the alt-tab popup */
struct _ObInternalWindow {
- ObWindow obwin;
+ ObWindowClass type;
Window window;
};