restore the desktop and focused window on restarts if possible

This commit is contained in:
Dana Jansens 2003-04-25 22:35:08 +00:00
parent 92d3f2342d
commit d3c094357d
6 changed files with 53 additions and 19 deletions

View file

@ -24,12 +24,12 @@ openbox3_SOURCES=parse.tab.c parse.lex.c action.c client.c config.c \
extensions.c focus.c frame.c grab.c menu.c menu_render.c \ extensions.c focus.c frame.c grab.c menu.c menu_render.c \
openbox.c framerender.c parse.c plugin.c prop.c screen.c \ openbox.c framerender.c parse.c plugin.c prop.c screen.c \
stacking.c dispatch.c event.c group.c timer.c xerror.c \ stacking.c dispatch.c event.c group.c timer.c xerror.c \
moveresize.c moveresize.c startup.c
noinst_HEADERS=action.h client.h config.h dispatch.h event.h extensions.h \ noinst_HEADERS=action.h client.h config.h dispatch.h event.h extensions.h \
focus.h frame.h framerender.h geom.h gettext.h grab.h group.h \ focus.h frame.h framerender.h geom.h gettext.h grab.h group.h \
menu.h openbox.h parse.h parse.tab.h plugin.h prop.h screen.h \ menu.h openbox.h parse.h parse.tab.h plugin.h prop.h screen.h \
stacking.h timer.h xerror.h moveresize.h stacking.h timer.h xerror.h moveresize.h startup.h
# kill the implicit .c.y rule # kill the implicit .c.y rule
%.c: %.y %.c: %.y

View file

@ -1,4 +1,5 @@
#include "client.h" #include "client.h"
#include "startup.h"
#include "screen.h" #include "screen.h"
#include "moveresize.h" #include "moveresize.h"
#include "prop.h" #include "prop.h"
@ -26,9 +27,6 @@
GList *client_list = NULL; GList *client_list = NULL;
GHashTable *client_map = NULL; GHashTable *client_map = NULL;
static Window *client_startup_stack_order = NULL;
static guint client_startup_stack_size = 0;
static void client_get_all(Client *self); static void client_get_all(Client *self);
static void client_toggle_border(Client *self, gboolean show); static void client_toggle_border(Client *self, gboolean show);
static void client_get_area(Client *self); static void client_get_area(Client *self);
@ -53,11 +51,6 @@ void client_startup()
client_map = g_hash_table_new((GHashFunc)map_hash, client_map = g_hash_table_new((GHashFunc)map_hash,
(GEqualFunc)map_key_comp); (GEqualFunc)map_key_comp);
/* save the stacking order on startup! */
PROP_GETA32(ob_root, net_client_list_stacking, window,
(guint32**)&client_startup_stack_order,
&client_startup_stack_size);
client_set_list(); client_set_list();
} }
@ -95,6 +88,7 @@ void client_manage_all()
Window w, *children; Window w, *children;
XWMHints *wmhints; XWMHints *wmhints;
XWindowAttributes attrib; XWindowAttributes attrib;
Client *active;
XQueryTree(ob_display, ob_root, &w, &w, &children, &nchild); XQueryTree(ob_display, ob_root, &w, &w, &children, &nchild);
@ -130,19 +124,21 @@ void client_manage_all()
why with stacking_lower? Why, because then windows who aren't in the why with stacking_lower? Why, because then windows who aren't in the
stacking list are on the top where you can see them instead of buried stacking list are on the top where you can see them instead of buried
at the bottom! */ at the bottom! */
for (i = client_startup_stack_size; i > 0; --i) { for (i = startup_stack_size; i > 0; --i) {
Client *c; Client *c;
w = client_startup_stack_order[i-1]; w = startup_stack_order[i-1];
c = g_hash_table_lookup(client_map, &w); c = g_hash_table_lookup(client_map, &w);
if (c) stacking_lower(c); if (c) stacking_lower(c);
} }
g_free(client_startup_stack_order); g_free(startup_stack_order);
client_startup_stack_order = NULL; startup_stack_order = NULL;
client_startup_stack_size = 0; startup_stack_size = 0;
if (config_focus_new) active = g_hash_table_lookup(client_map, &startup_active);
focus_fallback(Fallback_NoFocus); if (!active || !client_focus(active))
if (config_focus_new)
focus_fallback(Fallback_NoFocus);
} }
void client_manage(Window window) void client_manage(Window window)

View file

@ -5,6 +5,7 @@
#include "dispatch.h" #include "dispatch.h"
#include "xerror.h" #include "xerror.h"
#include "prop.h" #include "prop.h"
#include "startup.h"
#include "screen.h" #include "screen.h"
#include "focus.h" #include "focus.h"
#include "moveresize.h" #include "moveresize.h"
@ -151,6 +152,9 @@ int main(int argc, char **argv)
prop_startup(); /* get atoms values for the display */ prop_startup(); /* get atoms values for the display */
extensions_query_all(); /* find which extensions are present */ extensions_query_all(); /* find which extensions are present */
/* save stuff that we can use to restore state */
startup_save();
if (screen_annex()) { /* it will be ours! */ if (screen_annex()) { /* it will be ours! */
/* startup the parsing so everything can register sections of the rc */ /* startup the parsing so everything can register sections of the rc */
parse_startup(); parse_startup();

View file

@ -1,5 +1,6 @@
#include "openbox.h" #include "openbox.h"
#include "prop.h" #include "prop.h"
#include "startup.h"
#include "config.h" #include "config.h"
#include "screen.h" #include "screen.h"
#include "client.h" #include "client.h"
@ -173,8 +174,10 @@ void screen_startup()
screen_num_desktops = 0; screen_num_desktops = 0;
screen_set_num_desktops(config_desktops_num); screen_set_num_desktops(config_desktops_num);
screen_desktop = 0; if (startup_desktop >= screen_num_desktops)
screen_set_desktop(0); startup_desktop = 0;
screen_desktop = startup_desktop;
screen_set_desktop(startup_desktop);
/* don't start in showing-desktop mode */ /* don't start in showing-desktop mode */
screen_showing_desktop = FALSE; screen_showing_desktop = FALSE;

20
openbox/startup.c Normal file
View file

@ -0,0 +1,20 @@
#include "prop.h"
#include "screen.h"
#include "client.h"
#include "focus.h"
#include "config.h"
#include "openbox.h"
guint32 *startup_stack_order = NULL;
guint startup_stack_size = 0;
guint32 startup_active = None;
guint32 startup_desktop = 0;
void startup_save()
{
/* save the stacking order on startup! */
PROP_GETA32(ob_root, net_client_list_stacking, window,
(guint32**)&startup_stack_order, &startup_stack_size);
PROP_GET32(ob_root, net_active_window, window, &startup_active);
PROP_GET32(ob_root, net_current_desktop, cardinal, &startup_desktop);
}

11
openbox/startup.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef __startup_h
#define __startup_h
extern guint32 *startup_stack_order;
extern guint startup_stack_size;
extern guint32 startup_active;
extern guint32 startup_desktop;
void startup_save();
#endif