factorize quit/exec elements, and reparent systray

That fixes FS#296.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-02 17:12:10 +02:00
parent 8e4873b3aa
commit 11dfa832a8
6 changed files with 72 additions and 38 deletions

View File

@ -29,6 +29,7 @@
#include <ev.h>
#include "awesome.h"
#include "client.h"
#include "event.h"
#include "window.h"
@ -48,6 +49,33 @@ typedef struct
xcb_query_tree_cookie_t tree_cookie;
} root_win_t;
/** Call before exiting.
*/
void
awesome_atexit(void)
{
client_t *c;
xembed_window_t *em;
a_dbus_cleanup();
luaA_cs_cleanup();
/* reparent systray windows, otherwise they may die with their master */
for(em = globalconf.embedded; em; em = em->next)
{
xcb_screen_t *s = xutil_screen_get(globalconf.connection, em->phys_screen);
xcb_reparent_window(globalconf.connection, em->win, s->root, 0, 0);
}
/* remap all clients since some WM won't handle them otherwise */
for(c = globalconf.clients; c; c = c->next)
client_unban(c);
xcb_flush(globalconf.connection);
xcb_disconnect(globalconf.connection);
}
/** Scan X to find windows to manage.
*/
static void
@ -199,13 +227,20 @@ exit_on_signal(EV_P_ ev_signal *w, int revents)
ev_unloop(EV_A_ 1);
}
void
awesome_restart(void)
{
awesome_atexit();
a_exec(globalconf.argv);
}
/** Function to restart aweome on some signals.
* \param sig the signam received, unused
*/
static void
restart_on_signal(EV_P_ ev_signal *w, int revents)
{
ewmh_restart();
awesome_restart();
}
/** \brief awesome xerror function.
@ -280,7 +315,6 @@ main(int argc, char **argv)
xcolor_init_request_t colors_reqs[2];
xcb_get_modifier_mapping_cookie_t xmapping_cookie;
ssize_t cmdlen = 1;
client_t *c;
static struct option long_options[] =
{
{"help", 0, NULL, 'h'},
@ -486,16 +520,8 @@ main(int argc, char **argv)
ev_check_stop(globalconf.loop, &xcheck);
ev_ref(globalconf.loop);
ev_io_stop(globalconf.loop, &xio);
a_dbus_cleanup();
luaA_cs_cleanup();
/* remap all clients since some WM won't handle them otherwise */
for(c = globalconf.clients; c; c = c->next)
client_unban(c);
xcb_flush(globalconf.connection);
xcb_disconnect(globalconf.connection);
awesome_atexit();
return EXIT_SUCCESS;
}

29
awesome.h Normal file
View File

@ -0,0 +1,29 @@
/*
* awesome.h - awesome main header
*
* Copyright © 2008 Julien Danjou <julien@danjou.info>
*
* 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.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef AWESOME_AWESOME_H
#define AWESOME_AWESOME_H
void awesome_restart(void);
void awesome_atexit(void);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -24,6 +24,7 @@
#include <xcb/randr.h>
#include <xcb/xcb_icccm.h>
#include "awesome.h"
#include "event.h"
#include "tag.h"
#include "window.h"
@ -285,7 +286,7 @@ event_handle_configurenotify(void *data __attribute__ ((unused)),
&& (ev->width != screen->width_in_pixels
|| ev->height != screen->height_in_pixels))
/* it's not that we panic, but restart */
ewmh_restart();
awesome_restart();
return 0;
}
@ -615,7 +616,7 @@ event_handle_randr_screen_change_notify(void *data __attribute__ ((unused)),
* XRenderSetSubpixelOrder(dpy, snum, scevent->subpixel_order);
*/
ewmh_restart();
awesome_restart();
return 0;
}

17
ewmh.c
View File

@ -572,21 +572,4 @@ ewmh_window_icon_get_reply(xcb_get_property_cookie_t cookie)
return icon;
}
/**
* Restart awesome.
*/
void
ewmh_restart(void)
{
client_t *c;
for(c = globalconf.clients; c; c = c->next)
client_unban(c);
xcb_flush(globalconf.connection);
xcb_disconnect(globalconf.connection);
a_exec(globalconf.argv);
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

1
ewmh.h
View File

@ -46,7 +46,6 @@ void ewmh_check_client_hints(client_t *);
void ewmh_update_workarea(int);
xcb_get_property_cookie_t ewmh_window_icon_get_unchecked(xcb_window_t);
netwm_icon_t *ewmh_window_icon_get_reply(xcb_get_property_cookie_t);
void ewmh_restart(void);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

10
lua.c
View File

@ -37,6 +37,7 @@
#include <xcb/xcb.h>
#include "awesome.h"
#include "awesome-version-internal.h"
#include "ewmh.h"
#include "config.h"
@ -108,14 +109,9 @@ luaA_quit(lua_State *L __attribute__ ((unused)))
static int
luaA_exec(lua_State *L)
{
client_t *c;
const char *cmd = luaL_checkstring(L, 1);
for(c = globalconf.clients; c; c = c->next)
client_unban(c);
xcb_flush(globalconf.connection);
xcb_disconnect(globalconf.connection);
awesome_atexit();
a_exec(cmd);
return 0;
@ -126,7 +122,7 @@ luaA_exec(lua_State *L)
static int
luaA_restart(lua_State *L __attribute__ ((unused)))
{
ewmh_restart();
awesome_restart();
return 0;
}