summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
Diffstat (limited to 'openbox')
-rw-r--r--openbox/client.c25
-rw-r--r--openbox/event.c4
-rw-r--r--openbox/openbox.c12
-rw-r--r--openbox/openbox.h1
-rw-r--r--openbox/session.c22
-rw-r--r--openbox/session.h2
6 files changed, 51 insertions, 15 deletions
diff --git a/openbox/client.c b/openbox/client.c
index 797d5b85..682de02a 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -705,16 +705,23 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
/* XXX watch for xinerama dead areas */
/* This makes sure windows aren't entirely outside of the screen so you
- * can't see them at all */
+ can't see them at all.
+ It makes sure 10% of the window is on the screen at least. At don't let
+ it move itself off the top of the screen, which would hide the titlebar
+ on you. (The user can still do this if they want too, it's only limiting
+ the application.
+ */
if (client_normal(self)) {
a = screen_area(self->desktop);
- if (!self->strut.right && *x >= a->x + a->width - 1)
- *x = a->x + a->width - self->frame->area.width;
- if (!self->strut.bottom && *y >= a->y + a->height - 1)
- *y = a->y + a->height - self->frame->area.height;
- if (!self->strut.left && *x + self->frame->area.width - 1 < a->x)
- *x = a->x;
- if (!self->strut.top && *y + self->frame->area.height - 1 < a->y)
+ if (!self->strut.right &&
+ *x + self->frame->area.width/10 >= a->x + a->width - 1)
+ *x = a->x + a->width - self->frame->area.width/10;
+ if (!self->strut.bottom &&
+ *y + self->frame->area.height/10 >= a->y + a->height - 1)
+ *y = a->y + a->height - self->frame->area.height/10;
+ if (!self->strut.left && *x + self->frame->area.width*9/10 - 1 < a->x)
+ *x = a->x - self->frame->area.width*9/10;
+ if (!self->strut.top && *y < a->y)
*y = a->y;
}
@@ -729,7 +736,7 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
* remember to fix the placement stuff to avoid it also and
* then remove this XXX */
a = screen_physical_area_monitor(client_monitor(self));
- /* dont let windows map/move into the strut unless they
+ /* dont let windows map into the strut unless they
are bigger than the available area */
if (w <= a->width) {
if (!self->strut.left && *x < a->x) *x = a->x;
diff --git a/openbox/event.c b/openbox/event.c
index c74e15ae..42fd26ba 100644
--- a/openbox/event.c
+++ b/openbox/event.c
@@ -579,7 +579,7 @@ static void event_handle_root(XEvent *e)
switch(e->type) {
case SelectionClear:
ob_debug("Another WM has requested to replace us. Exiting.\n");
- ob_exit(0);
+ ob_exit_replace();
break;
case ClientMessage:
@@ -854,7 +854,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
gint fh = h +
client->frame->size.top + client->frame->size.bottom;
client_find_onscreen(client, &newx, &newy, fw, fh,
- client_normal(client));
+ FALSE);
if (e->xconfigurerequest.value_mask & CWX)
x = newx;
if (e->xconfigurerequest.value_mask & CWY)
diff --git a/openbox/openbox.c b/openbox/openbox.c
index e3309f00..1c4a8706 100644
--- a/openbox/openbox.c
+++ b/openbox/openbox.c
@@ -87,6 +87,7 @@ static Cursor cursors[OB_NUM_CURSORS];
static KeyCode keys[OB_NUM_KEYS];
static gint exitcode = 0;
static gboolean reconfigure_and_exit = FALSE;
+static gboolean being_replaced = FALSE;
static void signal_handler(gint signal, gpointer data);
static void parse_args(gint argc, gchar **argv);
@@ -332,7 +333,7 @@ gint main(gint argc, gchar **argv)
RrThemeFree(ob_rr_theme);
RrInstanceFree(ob_rr_inst);
- session_shutdown();
+ session_shutdown(being_replaced);
XCloseDisplay(ob_display);
@@ -448,7 +449,7 @@ static void parse_args(gint argc, gchar **argv)
void ob_exit_with_error(gchar *msg)
{
g_critical(msg);
- session_shutdown();
+ session_shutdown(TRUE);
exit(EXIT_FAILURE);
}
@@ -476,6 +477,13 @@ void ob_exit(gint code)
ob_main_loop_exit(ob_main_loop);
}
+void ob_exit_replace()
+{
+ exitcode = 0;
+ being_replaced = TRUE;
+ ob_main_loop_exit(ob_main_loop);
+}
+
Cursor ob_cursor(ObCursor cursor)
{
g_assert(cursor < OB_NUM_CURSORS);
diff --git a/openbox/openbox.h b/openbox/openbox.h
index 649b6108..4d410201 100644
--- a/openbox/openbox.h
+++ b/openbox/openbox.h
@@ -50,6 +50,7 @@ ObState ob_state();
void ob_restart_other(const gchar *path);
void ob_restart();
void ob_exit(gint code);
+void ob_exit_replace();
void ob_reconfigure();
diff --git a/openbox/session.c b/openbox/session.c
index f44d3b4c..72588ff0 100644
--- a/openbox/session.c
+++ b/openbox/session.c
@@ -257,7 +257,7 @@ void session_startup(gint argc, gchar **argv)
}
}
-void session_shutdown()
+void session_shutdown(gboolean permanent)
{
if (sm_disable)
return;
@@ -268,6 +268,26 @@ void session_shutdown()
g_free(sm_argv);
if (sm_conn) {
+ /* if permanent is true then we will change our session state so that
+ the SM won't run us again */
+ if (permanent) {
+ SmPropValue val_hint;
+ SmProp prop_hint = { SmRestartStyleHint, SmCARD8, 1, };
+ SmProp *props[1];
+ gulong hint;
+
+ /* when we exit, we want to reset this to a more friendly state */
+ hint = SmRestartIfRunning;
+ val_hint.value = &hint;
+ val_hint.length = 1;
+
+ prop_hint.vals = &val_hint;
+
+ props[0] = &prop_hint;
+
+ SmcSetProperties(sm_conn, 1, props);
+ }
+
SmcCloseConnection(sm_conn, 0, NULL);
while (session_saved_state) {
diff --git a/openbox/session.h b/openbox/session.h
index c3146337..75198caf 100644
--- a/openbox/session.h
+++ b/openbox/session.h
@@ -39,7 +39,7 @@ struct _ObSessionState {
extern GList *session_saved_state;
void session_startup(gint argc, gchar **argv);
-void session_shutdown();
+void session_shutdown(gboolean permanent);
GList* session_state_find(struct _ObClient *c);
gboolean session_state_cmp(ObSessionState *s, struct _ObClient *c);