2003-03-16 21:11:39 +00:00
|
|
|
#include "openbox.h"
|
2003-05-16 18:10:10 +00:00
|
|
|
#include "dock.h"
|
2003-05-21 03:56:56 +00:00
|
|
|
#include "xerror.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
#include "prop.h"
|
2003-04-25 22:35:08 +00:00
|
|
|
#include "startup.h"
|
2003-05-18 02:10:26 +00:00
|
|
|
#include "timer.h"
|
2003-04-08 07:31:26 +00:00
|
|
|
#include "config.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
#include "screen.h"
|
|
|
|
#include "client.h"
|
2003-03-17 02:03:45 +00:00
|
|
|
#include "frame.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
#include "focus.h"
|
2003-03-17 20:16:32 +00:00
|
|
|
#include "dispatch.h"
|
2003-05-09 16:57:17 +00:00
|
|
|
#include "extensions.h"
|
2003-06-21 02:26:50 +00:00
|
|
|
#include "render/render.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-05-18 02:10:26 +00:00
|
|
|
#ifdef USE_LIBSN
|
|
|
|
# define SN_API_NOT_YET_FROZEN
|
|
|
|
# include <libsn/sn.h>
|
|
|
|
#endif
|
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*! The event mask to grab on the root window */
|
2003-05-09 16:57:17 +00:00
|
|
|
#define ROOT_EVENTMASK (StructureNotifyMask | PropertyChangeMask | \
|
2003-03-16 21:11:39 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask | \
|
|
|
|
SubstructureNotifyMask | SubstructureRedirectMask | \
|
|
|
|
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
|
|
|
|
|
2003-03-19 08:06:19 +00:00
|
|
|
guint screen_num_desktops = 0;
|
2003-07-10 05:44:23 +00:00
|
|
|
guint screen_num_monitors = 0;
|
2003-03-16 21:11:39 +00:00
|
|
|
guint screen_desktop = 0;
|
|
|
|
Size screen_physical_size;
|
|
|
|
gboolean screen_showing_desktop;
|
|
|
|
DesktopLayout screen_desktop_layout;
|
2003-04-14 23:38:54 +00:00
|
|
|
char **screen_desktop_names = NULL;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-06-27 04:20:30 +00:00
|
|
|
static Rect **area = NULL; /* array of desktop holding array of
|
|
|
|
xinerama areas */
|
2003-07-10 05:44:23 +00:00
|
|
|
static Rect *monitor_area = NULL;
|
2003-03-19 09:36:09 +00:00
|
|
|
static Window support_window = None;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-05-18 02:10:26 +00:00
|
|
|
#ifdef USE_LIBSN
|
|
|
|
static SnMonitorContext *sn_context;
|
|
|
|
static int sn_busy_cnt;
|
|
|
|
static Timer *sn_timer = NULL;
|
|
|
|
|
|
|
|
static void sn_event_func(SnMonitorEvent *event, void *data);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void set_root_cursor();
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
static gboolean running;
|
|
|
|
static int another_running(Display *d, XErrorEvent *e)
|
|
|
|
{
|
|
|
|
(void)d;(void)e;
|
|
|
|
g_message("A window manager is already running on screen %d",
|
|
|
|
ob_screen);
|
|
|
|
running = TRUE;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean screen_annex()
|
|
|
|
{
|
|
|
|
XErrorHandler old;
|
|
|
|
pid_t pid;
|
|
|
|
int i, num_support;
|
2003-04-14 22:25:17 +00:00
|
|
|
guint32 *supported;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
running = FALSE;
|
|
|
|
old = XSetErrorHandler(another_running);
|
|
|
|
XSelectInput(ob_display, ob_root, ROOT_EVENTMASK);
|
|
|
|
XSync(ob_display, FALSE);
|
|
|
|
XSetErrorHandler(old);
|
|
|
|
if (running)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_message("Managing screen %d", ob_screen);
|
|
|
|
|
2003-05-18 02:10:26 +00:00
|
|
|
set_root_cursor();
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
/* set the OPENBOX_PID hint */
|
|
|
|
pid = getpid();
|
|
|
|
PROP_SET32(ob_root, openbox_pid, cardinal, pid);
|
|
|
|
|
|
|
|
/* create the netwm support window */
|
2003-03-19 09:36:09 +00:00
|
|
|
support_window = XCreateSimpleWindow(ob_display, ob_root, 0,0,1,1,0,0,0);
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
/* set supporting window */
|
2003-03-19 09:36:09 +00:00
|
|
|
PROP_SET32(ob_root, net_supporting_wm_check, window, support_window);
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
/* set properties on the supporting window */
|
2003-06-27 13:01:04 +00:00
|
|
|
PROP_SETS(support_window, net_wm_name, "Openbox");
|
2003-03-19 09:36:09 +00:00
|
|
|
PROP_SET32(support_window, net_supporting_wm_check, window,support_window);
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
/* set the _NET_SUPPORTED_ATOMS hint */
|
2003-04-17 05:43:41 +00:00
|
|
|
num_support = 61;
|
2003-03-16 21:11:39 +00:00
|
|
|
i = 0;
|
2003-04-14 22:25:17 +00:00
|
|
|
supported = g_new(guint32, num_support);
|
2003-03-16 21:11:39 +00:00
|
|
|
supported[i++] = prop_atoms.net_current_desktop;
|
|
|
|
supported[i++] = prop_atoms.net_number_of_desktops;
|
|
|
|
supported[i++] = prop_atoms.net_desktop_geometry;
|
|
|
|
supported[i++] = prop_atoms.net_desktop_viewport;
|
|
|
|
supported[i++] = prop_atoms.net_active_window;
|
|
|
|
supported[i++] = prop_atoms.net_workarea;
|
|
|
|
supported[i++] = prop_atoms.net_client_list;
|
|
|
|
supported[i++] = prop_atoms.net_client_list_stacking;
|
|
|
|
supported[i++] = prop_atoms.net_desktop_names;
|
|
|
|
supported[i++] = prop_atoms.net_close_window;
|
|
|
|
supported[i++] = prop_atoms.net_desktop_layout;
|
|
|
|
supported[i++] = prop_atoms.net_showing_desktop;
|
|
|
|
supported[i++] = prop_atoms.net_wm_name;
|
|
|
|
supported[i++] = prop_atoms.net_wm_visible_name;
|
|
|
|
supported[i++] = prop_atoms.net_wm_icon_name;
|
|
|
|
supported[i++] = prop_atoms.net_wm_visible_icon_name;
|
|
|
|
supported[i++] = prop_atoms.net_wm_desktop;
|
|
|
|
supported[i++] = prop_atoms.net_wm_strut;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_desktop;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_dock;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_toolbar;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_menu;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_utility;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_splash;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_dialog;
|
|
|
|
supported[i++] = prop_atoms.net_wm_window_type_normal;
|
|
|
|
supported[i++] = prop_atoms.net_wm_allowed_actions;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_move;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_resize;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_minimize;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_shade;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_maximize_horz;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_maximize_vert;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_fullscreen;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_change_desktop;
|
|
|
|
supported[i++] = prop_atoms.net_wm_action_close;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_modal;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_maximized_vert;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_maximized_horz;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_shaded;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_skip_taskbar;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_skip_pager;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_hidden;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_fullscreen;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_above;
|
|
|
|
supported[i++] = prop_atoms.net_wm_state_below;
|
2003-04-17 05:43:41 +00:00
|
|
|
supported[i++] = prop_atoms.net_moveresize_window;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_topleft;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_top;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_topright;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_right;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_bottomright;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_bottom;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_bottomleft;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_left;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_move;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_size_keyboard;
|
|
|
|
supported[i++] = prop_atoms.net_wm_moveresize_move_keyboard;
|
2003-03-16 21:11:39 +00:00
|
|
|
g_assert(i == num_support);
|
|
|
|
/*
|
|
|
|
supported[] = prop_atoms.net_wm_action_stick;
|
|
|
|
*/
|
|
|
|
|
2003-04-14 21:34:35 +00:00
|
|
|
PROP_SETA32(ob_root, net_supported, atom, supported, num_support);
|
2003-03-16 21:11:39 +00:00
|
|
|
g_free(supported);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void screen_startup()
|
|
|
|
{
|
2003-04-08 07:31:26 +00:00
|
|
|
GSList *it;
|
2003-04-14 21:34:35 +00:00
|
|
|
guint i;
|
2003-04-08 07:31:26 +00:00
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
/* get the initial size */
|
2003-07-10 05:44:23 +00:00
|
|
|
screen_resize();
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-04-08 07:31:26 +00:00
|
|
|
/* set the names */
|
2003-04-14 23:38:54 +00:00
|
|
|
screen_desktop_names = g_new(char*,
|
|
|
|
g_slist_length(config_desktops_names) + 1);
|
2003-04-14 21:34:35 +00:00
|
|
|
for (i = 0, it = config_desktops_names; it; ++i, it = it->next)
|
|
|
|
screen_desktop_names[i] = it->data; /* dont strdup */
|
2003-04-14 23:38:54 +00:00
|
|
|
screen_desktop_names[i] = NULL;
|
2003-04-14 21:34:35 +00:00
|
|
|
PROP_SETSS(ob_root, net_desktop_names, screen_desktop_names);
|
|
|
|
g_free(screen_desktop_names); /* dont free the individual strings */
|
|
|
|
screen_desktop_names = NULL;
|
|
|
|
|
2003-03-23 18:21:45 +00:00
|
|
|
screen_num_desktops = 0;
|
2003-04-08 07:31:26 +00:00
|
|
|
screen_set_num_desktops(config_desktops_num);
|
2003-04-25 22:35:08 +00:00
|
|
|
if (startup_desktop >= screen_num_desktops)
|
|
|
|
startup_desktop = 0;
|
|
|
|
screen_desktop = startup_desktop;
|
|
|
|
screen_set_desktop(startup_desktop);
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
/* don't start in showing-desktop mode */
|
|
|
|
screen_showing_desktop = FALSE;
|
|
|
|
PROP_SET32(ob_root, net_showing_desktop, cardinal, screen_showing_desktop);
|
|
|
|
|
|
|
|
screen_update_layout();
|
2003-05-18 02:10:26 +00:00
|
|
|
|
|
|
|
#ifdef USE_LIBSN
|
|
|
|
sn_context = sn_monitor_context_new(ob_sn_display, ob_screen,
|
|
|
|
sn_event_func, NULL, NULL);
|
|
|
|
sn_busy_cnt = 0;
|
|
|
|
#endif
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void screen_shutdown()
|
|
|
|
{
|
2003-06-27 04:20:30 +00:00
|
|
|
Rect **r;
|
|
|
|
|
2003-03-19 09:36:09 +00:00
|
|
|
XSelectInput(ob_display, ob_root, NoEventMask);
|
|
|
|
|
2003-03-19 09:03:54 +00:00
|
|
|
PROP_ERASE(ob_root, openbox_pid); /* we're not running here no more! */
|
2003-03-19 09:36:09 +00:00
|
|
|
PROP_ERASE(ob_root, net_supported); /* not without us */
|
|
|
|
PROP_ERASE(ob_root, net_showing_desktop); /* don't keep this mode */
|
|
|
|
|
|
|
|
XDestroyWindow(ob_display, support_window);
|
2003-03-19 09:03:54 +00:00
|
|
|
|
2003-04-14 21:34:35 +00:00
|
|
|
g_strfreev(screen_desktop_names);
|
2003-06-27 04:20:30 +00:00
|
|
|
for (r = area; *r; ++r)
|
|
|
|
g_free(*r);
|
2003-03-16 21:11:39 +00:00
|
|
|
g_free(area);
|
|
|
|
}
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
void screen_resize()
|
2003-03-16 21:11:39 +00:00
|
|
|
{
|
2003-07-10 05:44:23 +00:00
|
|
|
static int oldw = 0, oldh = 0;
|
|
|
|
int w, h;
|
2003-05-09 16:57:17 +00:00
|
|
|
GList *it;
|
2003-04-14 21:34:35 +00:00
|
|
|
guint32 geometry[2];
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen));
|
|
|
|
h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen));
|
|
|
|
|
|
|
|
if (w == oldw && h == oldh) return;
|
|
|
|
|
|
|
|
oldw = w; oldh = h;
|
|
|
|
|
2003-03-19 09:36:55 +00:00
|
|
|
/* Set the _NET_DESKTOP_GEOMETRY hint */
|
2003-06-27 04:20:30 +00:00
|
|
|
screen_physical_size.width = geometry[0] = w;
|
|
|
|
screen_physical_size.height = geometry[1] = h;
|
2003-04-14 21:34:35 +00:00
|
|
|
PROP_SETA32(ob_root, net_desktop_geometry, cardinal, geometry, 2);
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-07-10 06:18:47 +00:00
|
|
|
if (ob_state == OB_STATE_STARTING)
|
2003-03-16 21:11:39 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-16 18:10:10 +00:00
|
|
|
dock_configure();
|
2003-06-27 04:20:30 +00:00
|
|
|
screen_update_areas();
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-05-09 16:57:17 +00:00
|
|
|
for (it = client_list; it; it = it->next)
|
|
|
|
client_move_onscreen(it->data);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void screen_set_num_desktops(guint num)
|
|
|
|
{
|
2003-03-19 07:08:15 +00:00
|
|
|
guint i, old;
|
2003-04-14 21:34:35 +00:00
|
|
|
guint32 *viewport;
|
2003-04-05 20:27:03 +00:00
|
|
|
GList *it;
|
2003-03-23 18:21:45 +00:00
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
g_assert(num > 0);
|
|
|
|
|
2003-03-18 05:29:01 +00:00
|
|
|
old = screen_num_desktops;
|
2003-03-16 21:11:39 +00:00
|
|
|
screen_num_desktops = num;
|
|
|
|
PROP_SET32(ob_root, net_number_of_desktops, cardinal, num);
|
|
|
|
|
|
|
|
/* set the viewport hint */
|
2003-04-14 21:34:35 +00:00
|
|
|
viewport = g_new0(guint32, num * 2);
|
|
|
|
PROP_SETA32(ob_root, net_desktop_viewport, cardinal, viewport, num * 2);
|
2003-03-16 21:11:39 +00:00
|
|
|
g_free(viewport);
|
|
|
|
|
|
|
|
/* the number of rows/columns will differ */
|
|
|
|
screen_update_layout();
|
|
|
|
|
|
|
|
/* may be some unnamed desktops that we need to fill in with names */
|
|
|
|
screen_update_desktop_names();
|
|
|
|
|
2003-03-19 07:08:15 +00:00
|
|
|
/* update the focus lists */
|
|
|
|
/* free our lists for the desktops which have disappeared */
|
|
|
|
for (i = num; i < old; ++i)
|
|
|
|
g_list_free(focus_order[i]);
|
|
|
|
/* realloc the array */
|
|
|
|
focus_order = g_renew(GList*, focus_order, num);
|
|
|
|
/* set the new lists to be empty */
|
|
|
|
for (i = old; i < num; ++i)
|
|
|
|
focus_order[i] = NULL;
|
|
|
|
|
2003-03-23 18:21:45 +00:00
|
|
|
/* move windows on desktops that will no longer exist! */
|
|
|
|
for (it = client_list; it != NULL; it = it->next) {
|
2003-07-10 06:38:42 +00:00
|
|
|
ObClient *c = it->data;
|
2003-04-28 19:36:59 +00:00
|
|
|
if (c->desktop >= num && c->desktop != DESKTOP_ALL)
|
2003-03-28 08:11:02 +00:00
|
|
|
client_set_desktop(c, num - 1, FALSE);
|
2003-03-23 18:21:45 +00:00
|
|
|
}
|
|
|
|
|
2003-04-28 19:36:59 +00:00
|
|
|
/* change our struts/area to match (after moving windows) */
|
2003-06-27 04:20:30 +00:00
|
|
|
screen_update_areas();
|
2003-04-28 19:36:59 +00:00
|
|
|
|
2003-03-18 05:29:01 +00:00
|
|
|
dispatch_ob(Event_Ob_NumDesktops, num, old);
|
2003-03-17 20:16:32 +00:00
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
/* change our desktop if we're on one that no longer exists! */
|
|
|
|
if (screen_desktop >= screen_num_desktops)
|
|
|
|
screen_set_desktop(num - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void screen_set_desktop(guint num)
|
|
|
|
{
|
|
|
|
GList *it;
|
2003-03-18 05:29:01 +00:00
|
|
|
guint old;
|
2003-03-27 23:05:54 +00:00
|
|
|
XEvent e;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
g_assert(num < screen_num_desktops);
|
|
|
|
|
2003-03-18 05:29:01 +00:00
|
|
|
old = screen_desktop;
|
2003-03-16 21:11:39 +00:00
|
|
|
screen_desktop = num;
|
|
|
|
PROP_SET32(ob_root, net_current_desktop, cardinal, num);
|
|
|
|
|
|
|
|
if (old == num) return;
|
|
|
|
|
2003-03-27 23:05:54 +00:00
|
|
|
g_message("Moving to desktop %d", num+1);
|
|
|
|
|
2003-03-20 22:36:01 +00:00
|
|
|
/* show windows before hiding the rest to lessen the enter/leave events */
|
2003-03-17 02:03:45 +00:00
|
|
|
|
|
|
|
/* show windows from top to bottom */
|
|
|
|
for (it = stacking_list; it != NULL; it = it->next) {
|
2003-05-11 20:19:00 +00:00
|
|
|
if (WINDOW_IS_CLIENT(it->data)) {
|
2003-07-10 06:38:42 +00:00
|
|
|
ObClient *c = it->data;
|
2003-05-11 20:19:00 +00:00
|
|
|
if (!c->frame->visible && client_should_show(c))
|
|
|
|
frame_show(c->frame);
|
|
|
|
}
|
2003-03-17 02:03:45 +00:00
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-03-20 22:36:01 +00:00
|
|
|
/* hide windows from bottom to top */
|
|
|
|
for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
|
2003-05-11 20:19:00 +00:00
|
|
|
if (WINDOW_IS_CLIENT(it->data)) {
|
2003-07-10 06:38:42 +00:00
|
|
|
ObClient *c = it->data;
|
2003-05-11 20:19:00 +00:00
|
|
|
if (c->frame->visible && !client_should_show(c))
|
|
|
|
frame_hide(c->frame);
|
|
|
|
}
|
2003-03-20 22:36:01 +00:00
|
|
|
}
|
|
|
|
|
2003-03-27 23:05:54 +00:00
|
|
|
/* focus the last focused window on the desktop, and ignore enter events
|
|
|
|
from the switch so it doesnt mess with the focus */
|
|
|
|
while (XCheckTypedEvent(ob_display, EnterNotify, &e));
|
2003-06-20 00:05:51 +00:00
|
|
|
g_message("switch fallback");
|
2003-04-08 06:14:53 +00:00
|
|
|
focus_fallback(Fallback_Desktop);
|
2003-06-20 00:05:51 +00:00
|
|
|
g_message("/switch fallback");
|
2003-03-27 23:05:54 +00:00
|
|
|
|
2003-03-18 05:29:01 +00:00
|
|
|
dispatch_ob(Event_Ob_Desktop, num, old);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void screen_update_layout()
|
|
|
|
{
|
2003-07-10 06:18:47 +00:00
|
|
|
ObOrientation orient;
|
|
|
|
ObCorner corner;
|
|
|
|
guint rows;
|
|
|
|
guint cols;
|
|
|
|
guint32 *data;
|
2003-04-14 21:34:35 +00:00
|
|
|
guint num;
|
2003-07-10 06:18:47 +00:00
|
|
|
gboolean valid = FALSE;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-04-14 22:20:27 +00:00
|
|
|
if (PROP_GETA32(ob_root, net_desktop_layout, cardinal, &data, &num)) {
|
2003-04-14 21:34:35 +00:00
|
|
|
if (num == 3 || num == 4) {
|
2003-07-10 06:18:47 +00:00
|
|
|
|
2003-04-14 21:34:35 +00:00
|
|
|
if (data[0] == prop_atoms.net_wm_orientation_vert)
|
2003-07-10 06:18:47 +00:00
|
|
|
orient = OB_ORIENTATION_VERT;
|
|
|
|
else if (data[0] == prop_atoms.net_wm_orientation_horz)
|
|
|
|
orient = OB_ORIENTATION_HORZ;
|
|
|
|
else
|
|
|
|
goto screen_update_layout_bail;
|
|
|
|
|
|
|
|
if (num < 4)
|
|
|
|
corner = OB_CORNER_TOPLEFT;
|
2003-04-14 21:34:35 +00:00
|
|
|
else {
|
|
|
|
if (data[3] == prop_atoms.net_wm_topright)
|
2003-07-10 06:18:47 +00:00
|
|
|
corner = OB_CORNER_TOPRIGHT;
|
2003-04-14 21:34:35 +00:00
|
|
|
else if (data[3] == prop_atoms.net_wm_bottomright)
|
2003-07-10 06:18:47 +00:00
|
|
|
corner = OB_CORNER_BOTTOMRIGHT;
|
2003-04-14 21:34:35 +00:00
|
|
|
else if (data[3] == prop_atoms.net_wm_bottomleft)
|
2003-07-10 06:18:47 +00:00
|
|
|
corner = OB_CORNER_BOTTOMLEFT;
|
|
|
|
else
|
|
|
|
goto screen_update_layout_bail;
|
2003-04-14 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fill in a zero rows/columns */
|
2003-07-10 06:18:47 +00:00
|
|
|
if ((data[1] == 0 && data[2] == 0) || /* both 0's is bad data.. */
|
|
|
|
(data[1] != 0 && data[2] != 0)) { /* no 0's is bad data.. */
|
|
|
|
goto screen_update_layout_bail;
|
|
|
|
} else {
|
2003-04-14 21:34:35 +00:00
|
|
|
if (data[1] == 0) {
|
|
|
|
data[1] = (screen_num_desktops +
|
|
|
|
screen_num_desktops % data[2]) / data[2];
|
|
|
|
} else if (data[2] == 0) {
|
|
|
|
data[2] = (screen_num_desktops +
|
|
|
|
screen_num_desktops % data[1]) / data[1];
|
|
|
|
}
|
2003-07-10 06:18:47 +00:00
|
|
|
cols = data[1];
|
|
|
|
rows = data[2];
|
2003-04-14 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bounds checking */
|
2003-07-10 06:18:47 +00:00
|
|
|
if (orient == OB_ORIENTATION_HORZ) {
|
|
|
|
rows = MIN(rows, screen_num_desktops);
|
|
|
|
cols = MIN(cols, ((screen_num_desktops +
|
|
|
|
(screen_num_desktops % rows)) / rows));
|
2003-04-14 21:34:35 +00:00
|
|
|
} else {
|
2003-07-10 06:18:47 +00:00
|
|
|
cols = MIN(cols, screen_num_desktops);
|
|
|
|
rows = MIN(rows, ((screen_num_desktops +
|
|
|
|
(screen_num_desktops % cols)) / cols));
|
2003-04-14 21:34:35 +00:00
|
|
|
}
|
2003-07-10 06:18:47 +00:00
|
|
|
|
|
|
|
valid = TRUE;
|
2003-04-14 21:34:35 +00:00
|
|
|
}
|
2003-07-10 06:18:47 +00:00
|
|
|
screen_update_layout_bail:
|
|
|
|
g_free(data);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
2003-07-10 06:18:47 +00:00
|
|
|
|
|
|
|
if (!valid) {
|
|
|
|
/* defaults */
|
|
|
|
orient = OB_ORIENTATION_HORZ;
|
|
|
|
corner = OB_CORNER_TOPLEFT;
|
|
|
|
rows = 1;
|
|
|
|
cols = screen_num_desktops;
|
|
|
|
}
|
|
|
|
|
|
|
|
screen_desktop_layout.orientation = orient;
|
|
|
|
screen_desktop_layout.start_corner = corner;
|
|
|
|
screen_desktop_layout.rows = rows;
|
|
|
|
screen_desktop_layout.columns = cols;
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void screen_update_desktop_names()
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
/* empty the array */
|
2003-04-14 21:34:35 +00:00
|
|
|
g_strfreev(screen_desktop_names);
|
2003-04-14 23:38:54 +00:00
|
|
|
screen_desktop_names = NULL;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-04-14 22:39:47 +00:00
|
|
|
if (PROP_GETSS(ob_root, net_desktop_names, utf8, &screen_desktop_names))
|
|
|
|
for (i = 0; screen_desktop_names[i] && i <= screen_num_desktops; ++i);
|
|
|
|
else
|
|
|
|
i = 0;
|
2003-04-14 22:31:22 +00:00
|
|
|
if (i <= screen_num_desktops) {
|
2003-04-14 21:34:35 +00:00
|
|
|
screen_desktop_names = g_renew(char*, screen_desktop_names,
|
|
|
|
screen_num_desktops + 1);
|
2003-04-14 22:25:17 +00:00
|
|
|
screen_desktop_names[screen_num_desktops] = NULL;
|
2003-04-14 21:34:35 +00:00
|
|
|
for (; i < screen_num_desktops; ++i)
|
|
|
|
screen_desktop_names[i] = g_strdup("Unnamed Desktop");
|
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void screen_show_desktop(gboolean show)
|
|
|
|
{
|
|
|
|
GList *it;
|
|
|
|
|
|
|
|
if (show == screen_showing_desktop) return; /* no change */
|
|
|
|
|
|
|
|
screen_showing_desktop = show;
|
|
|
|
|
|
|
|
if (show) {
|
|
|
|
/* bottom to top */
|
|
|
|
for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
|
2003-05-11 20:19:00 +00:00
|
|
|
if (WINDOW_IS_CLIENT(it->data)) {
|
2003-07-10 06:38:42 +00:00
|
|
|
ObClient *client = it->data;
|
2003-05-11 20:19:00 +00:00
|
|
|
if (client->frame->visible && !client_should_show(client))
|
|
|
|
frame_hide(client->frame);
|
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* top to bottom */
|
|
|
|
for (it = stacking_list; it != NULL; it = it->next) {
|
2003-05-11 20:19:00 +00:00
|
|
|
if (WINDOW_IS_CLIENT(it->data)) {
|
2003-07-10 06:38:42 +00:00
|
|
|
ObClient *client = it->data;
|
2003-05-11 20:19:00 +00:00
|
|
|
if (!client->frame->visible && client_should_show(client))
|
|
|
|
frame_show(client->frame);
|
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-17 17:32:09 +00:00
|
|
|
if (show) {
|
|
|
|
/* focus desktop */
|
|
|
|
for (it = focus_order[screen_desktop]; it; it = it->next)
|
2003-07-10 06:38:42 +00:00
|
|
|
if (((ObClient*)it->data)->type == Type_Desktop &&
|
2003-04-17 17:32:09 +00:00
|
|
|
client_focus(it->data))
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
focus_fallback(Fallback_NoFocus);
|
|
|
|
}
|
|
|
|
|
2003-03-18 05:29:01 +00:00
|
|
|
show = !!show; /* make it boolean */
|
2003-03-16 21:11:39 +00:00
|
|
|
PROP_SET32(ob_root, net_showing_desktop, cardinal, show);
|
2003-03-17 20:16:32 +00:00
|
|
|
|
2003-03-18 05:29:01 +00:00
|
|
|
dispatch_ob(Event_Ob_ShowDesktop, show, 0);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 06:38:42 +00:00
|
|
|
void screen_install_colormap(ObClient *client, gboolean install)
|
2003-03-16 21:11:39 +00:00
|
|
|
{
|
2003-03-21 10:33:26 +00:00
|
|
|
XWindowAttributes wa;
|
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
if (client == NULL) {
|
|
|
|
if (install)
|
2003-06-21 00:42:47 +00:00
|
|
|
XInstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
|
2003-03-16 21:11:39 +00:00
|
|
|
else
|
2003-06-21 00:42:47 +00:00
|
|
|
XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
|
2003-03-16 21:11:39 +00:00
|
|
|
} else {
|
2003-03-21 09:54:54 +00:00
|
|
|
if (XGetWindowAttributes(ob_display, client->window, &wa) &&
|
|
|
|
wa.colormap != None) {
|
2003-05-20 05:02:24 +00:00
|
|
|
xerror_set_ignore(TRUE);
|
2003-03-16 21:11:39 +00:00
|
|
|
if (install)
|
2003-06-21 00:42:47 +00:00
|
|
|
XInstallColormap(RrDisplay(ob_rr_inst), wa.colormap);
|
2003-03-16 21:11:39 +00:00
|
|
|
else
|
2003-06-21 00:42:47 +00:00
|
|
|
XUninstallColormap(RrDisplay(ob_rr_inst), wa.colormap);
|
2003-05-20 05:02:24 +00:00
|
|
|
xerror_set_ignore(FALSE);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-27 04:20:30 +00:00
|
|
|
void screen_update_areas()
|
2003-03-16 21:11:39 +00:00
|
|
|
{
|
2003-06-27 04:20:30 +00:00
|
|
|
guint i, x;
|
|
|
|
guint32 *dims;
|
|
|
|
Rect **old_area = area;
|
|
|
|
Rect **rit;
|
2003-04-05 20:27:03 +00:00
|
|
|
GList *it;
|
2003-05-16 19:15:56 +00:00
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
g_free(monitor_area);
|
|
|
|
extensions_xinerama_screens(&monitor_area, &screen_num_monitors);
|
2003-05-16 19:15:56 +00:00
|
|
|
|
2003-06-27 04:20:30 +00:00
|
|
|
if (area) {
|
|
|
|
for (i = 0; area[i]; ++i)
|
|
|
|
g_free(area[i]);
|
|
|
|
g_free(area);
|
|
|
|
}
|
2003-03-21 10:34:44 +00:00
|
|
|
|
2003-06-27 04:20:30 +00:00
|
|
|
area = g_new(Rect*, screen_num_desktops + 2);
|
|
|
|
for (i = 0; i < screen_num_desktops + 1; ++i)
|
2003-07-10 05:44:23 +00:00
|
|
|
area[i] = g_new(Rect, screen_num_monitors + 1);
|
2003-06-27 04:20:30 +00:00
|
|
|
area[i] = NULL;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-04-14 21:34:35 +00:00
|
|
|
dims = g_new(guint32, 4 * screen_num_desktops);
|
2003-06-27 04:20:30 +00:00
|
|
|
|
|
|
|
rit = old_area;
|
2003-03-16 21:11:39 +00:00
|
|
|
for (i = 0; i < screen_num_desktops + 1; ++i) {
|
2003-06-27 04:20:30 +00:00
|
|
|
Strut s;
|
|
|
|
int l, r, t, b;
|
|
|
|
|
|
|
|
/* calc the xinerama areas */
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 0; x < screen_num_monitors; ++x) {
|
|
|
|
area[i][x] = monitor_area[x];
|
2003-06-27 04:20:30 +00:00
|
|
|
if (x == 0) {
|
2003-07-10 05:44:23 +00:00
|
|
|
l = monitor_area[x].x;
|
|
|
|
t = monitor_area[x].y;
|
|
|
|
r = monitor_area[x].x + monitor_area[x].width - 1;
|
|
|
|
b = monitor_area[x].y + monitor_area[x].height - 1;
|
2003-06-27 04:20:30 +00:00
|
|
|
} else {
|
2003-07-10 05:44:23 +00:00
|
|
|
l = MIN(l, monitor_area[x].x);
|
|
|
|
t = MIN(t, monitor_area[x].y);
|
|
|
|
r = MAX(r, monitor_area[x].x + monitor_area[x].width - 1);
|
|
|
|
b = MAX(b, monitor_area[x].y + monitor_area[x].height - 1);
|
2003-06-27 04:20:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RECT_SET(area[i][x], l, t, r - l + 1, b - t + 1);
|
|
|
|
|
|
|
|
/* apply struts */
|
|
|
|
STRUT_SET(s, 0, 0, 0, 0);
|
|
|
|
for (it = client_list; it; it = it->next)
|
2003-07-10 06:38:42 +00:00
|
|
|
STRUT_ADD(s, ((ObClient*)it->data)->strut);
|
2003-06-27 04:20:30 +00:00
|
|
|
STRUT_ADD(s, dock_strut);
|
|
|
|
|
|
|
|
if (s.left) {
|
|
|
|
int o;
|
|
|
|
|
|
|
|
/* find the left-most xin heads, i do this in 2 loops :| */
|
|
|
|
o = area[i][0].x;
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 1; x < screen_num_monitors; ++x)
|
2003-06-27 04:20:30 +00:00
|
|
|
o = MIN(o, area[i][x].x);
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 0; x < screen_num_monitors; ++x) {
|
2003-06-27 04:20:30 +00:00
|
|
|
int edge = o + s.left - area[i][x].x;
|
|
|
|
if (edge > 0) {
|
|
|
|
area[i][x].x += edge;
|
|
|
|
area[i][x].width -= edge;
|
|
|
|
}
|
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
area[i][screen_num_monitors].x += s.left;
|
|
|
|
area[i][screen_num_monitors].width -= s.left;
|
2003-06-27 04:20:30 +00:00
|
|
|
}
|
|
|
|
if (s.top) {
|
|
|
|
int o;
|
|
|
|
|
|
|
|
/* find the left-most xin heads, i do this in 2 loops :| */
|
|
|
|
o = area[i][0].y;
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 1; x < screen_num_monitors; ++x)
|
2003-06-27 04:20:30 +00:00
|
|
|
o = MIN(o, area[i][x].y);
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 0; x < screen_num_monitors; ++x) {
|
2003-06-27 04:20:30 +00:00
|
|
|
int edge = o + s.top - area[i][x].y;
|
|
|
|
if (edge > 0) {
|
|
|
|
area[i][x].y += edge;
|
|
|
|
area[i][x].height -= edge;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
area[i][screen_num_monitors].y += s.top;
|
|
|
|
area[i][screen_num_monitors].height -= s.top;
|
2003-06-27 04:20:30 +00:00
|
|
|
}
|
|
|
|
if (s.right) {
|
|
|
|
int o;
|
|
|
|
|
|
|
|
/* find the bottom-most xin heads, i do this in 2 loops :| */
|
|
|
|
o = area[i][0].x + area[i][0].width - 1;
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 1; x < screen_num_monitors; ++x)
|
2003-06-27 04:20:30 +00:00
|
|
|
o = MAX(o, area[i][x].x + area[i][x].width - 1);
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 0; x < screen_num_monitors; ++x) {
|
2003-06-27 04:20:30 +00:00
|
|
|
int edge = (area[i][x].x + area[i][x].width - 1) -
|
|
|
|
(o - s.right);
|
|
|
|
if (edge > 0)
|
|
|
|
area[i][x].width -= edge;
|
|
|
|
}
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
area[i][screen_num_monitors].width -= s.right;
|
2003-06-27 04:20:30 +00:00
|
|
|
}
|
|
|
|
if (s.bottom) {
|
|
|
|
int o;
|
|
|
|
|
|
|
|
/* find the bottom-most xin heads, i do this in 2 loops :| */
|
|
|
|
o = area[i][0].y + area[i][0].height - 1;
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 1; x < screen_num_monitors; ++x)
|
2003-06-27 04:20:30 +00:00
|
|
|
o = MAX(o, area[i][x].y + area[i][x].height - 1);
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 0; x < screen_num_monitors; ++x) {
|
2003-06-27 04:20:30 +00:00
|
|
|
int edge = (area[i][x].y + area[i][x].height - 1) -
|
|
|
|
(o - s.bottom);
|
|
|
|
if (edge > 0)
|
|
|
|
area[i][x].height -= edge;
|
|
|
|
}
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
area[i][screen_num_monitors].height -= s.bottom;
|
2003-06-27 04:20:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX when dealing with partial struts, if its in a single
|
|
|
|
xinerama area, then only subtract it from that area's space
|
2003-07-10 05:44:23 +00:00
|
|
|
for (x = 0; x < screen_num_monitors; ++x) {
|
2003-04-05 20:27:03 +00:00
|
|
|
GList *it;
|
2003-06-27 04:20:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
do something smart with it for the 'all xinerama areas' one...
|
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
for (it = client_list; it; it = it->next) {
|
|
|
|
|
2003-06-27 04:20:30 +00:00
|
|
|
XXX if gunna test this shit, then gotta worry about when
|
|
|
|
the client moves between xinerama heads..
|
|
|
|
|
2003-07-10 06:38:42 +00:00
|
|
|
if (RECT_CONTAINS_RECT(((ObClient*)it->data)->frame->area,
|
2003-06-27 04:20:30 +00:00
|
|
|
area[i][x])) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* XXX optimize when this is run? */
|
|
|
|
|
|
|
|
/* the area has changed, adjust all the maximized
|
|
|
|
windows */
|
|
|
|
for (it = client_list; it; it = it->next) {
|
2003-07-10 06:38:42 +00:00
|
|
|
ObClient *c = it->data;
|
2003-06-27 04:20:30 +00:00
|
|
|
if (i < screen_num_desktops) {
|
|
|
|
if (c->desktop == i)
|
|
|
|
client_reconfigure(c);
|
|
|
|
} else if (c->desktop == DESKTOP_ALL)
|
|
|
|
client_reconfigure(c);
|
|
|
|
}
|
|
|
|
if (i < screen_num_desktops) {
|
|
|
|
/* don't set these for the 'all desktops' area */
|
2003-07-10 05:44:23 +00:00
|
|
|
dims[(i * 4) + 0] = area[i][screen_num_monitors].x;
|
|
|
|
dims[(i * 4) + 1] = area[i][screen_num_monitors].y;
|
|
|
|
dims[(i * 4) + 2] = area[i][screen_num_monitors].width;
|
|
|
|
dims[(i * 4) + 3] = area[i][screen_num_monitors].height;
|
2003-06-27 04:20:30 +00:00
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
2003-04-14 21:34:35 +00:00
|
|
|
PROP_SETA32(ob_root, net_workarea, cardinal,
|
2003-03-16 21:11:39 +00:00
|
|
|
dims, 4 * screen_num_desktops);
|
2003-06-27 04:20:30 +00:00
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
g_free(dims);
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect *screen_area(guint desktop)
|
|
|
|
{
|
2003-07-10 05:44:23 +00:00
|
|
|
return screen_area_monitor(desktop, screen_num_monitors);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
Rect *screen_area_monitor(guint desktop, guint head)
|
2003-03-16 21:11:39 +00:00
|
|
|
{
|
2003-07-10 05:44:23 +00:00
|
|
|
if (head > screen_num_monitors)
|
2003-06-27 04:20:30 +00:00
|
|
|
return NULL;
|
2003-03-16 21:11:39 +00:00
|
|
|
if (desktop >= screen_num_desktops) {
|
|
|
|
if (desktop == DESKTOP_ALL)
|
2003-06-27 04:20:30 +00:00
|
|
|
return &area[screen_num_desktops][head];
|
2003-03-16 21:11:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-06-27 04:20:30 +00:00
|
|
|
return &area[desktop][head];
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect *screen_physical_area()
|
|
|
|
{
|
2003-07-10 05:44:23 +00:00
|
|
|
return screen_physical_area_monitor(screen_num_monitors);
|
2003-06-27 04:20:30 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 05:44:23 +00:00
|
|
|
Rect *screen_physical_area_monitor(guint head)
|
2003-06-27 04:20:30 +00:00
|
|
|
{
|
2003-07-10 05:44:23 +00:00
|
|
|
if (head > screen_num_monitors)
|
2003-06-27 04:20:30 +00:00
|
|
|
return NULL;
|
2003-07-10 05:44:23 +00:00
|
|
|
return &monitor_area[head];
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
2003-05-18 02:10:26 +00:00
|
|
|
|
|
|
|
static void set_root_cursor()
|
|
|
|
{
|
|
|
|
#ifdef USE_LIBSN
|
|
|
|
if (sn_busy_cnt)
|
2003-07-10 06:18:47 +00:00
|
|
|
XDefineCursor(ob_display, ob_root, ob_cursor(OB_CURSOR_BUSY));
|
2003-05-18 02:10:26 +00:00
|
|
|
else
|
|
|
|
#endif
|
2003-07-10 06:18:47 +00:00
|
|
|
XDefineCursor(ob_display, ob_root, ob_cursor(OB_CURSOR_POINTER));
|
2003-05-18 02:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_LIBSN
|
|
|
|
static void sn_timeout(void *data)
|
|
|
|
{
|
|
|
|
timer_stop(sn_timer);
|
|
|
|
sn_timer = NULL;
|
|
|
|
sn_busy_cnt = 0;
|
|
|
|
|
|
|
|
set_root_cursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sn_event_func(SnMonitorEvent *ev, void *data)
|
|
|
|
{
|
|
|
|
SnStartupSequence *seq;
|
|
|
|
const char *seq_id, *bin_name;
|
|
|
|
int cnt = sn_busy_cnt;
|
|
|
|
|
|
|
|
if (!(seq = sn_monitor_event_get_startup_sequence(ev)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
seq_id = sn_startup_sequence_get_id(seq);
|
|
|
|
bin_name = sn_startup_sequence_get_binary_name(seq);
|
|
|
|
|
|
|
|
if (!(seq_id && bin_name))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (sn_monitor_event_get_type(ev)) {
|
|
|
|
case SN_MONITOR_EVENT_INITIATED:
|
|
|
|
++sn_busy_cnt;
|
|
|
|
if (sn_timer)
|
|
|
|
timer_stop(sn_timer);
|
|
|
|
/* 30 second timeout for apps to start */
|
|
|
|
sn_timer = timer_start(30 * 1000000, sn_timeout, NULL);
|
|
|
|
break;
|
|
|
|
case SN_MONITOR_EVENT_CHANGED:
|
|
|
|
break;
|
|
|
|
case SN_MONITOR_EVENT_COMPLETED:
|
|
|
|
if (sn_busy_cnt) --sn_busy_cnt;
|
|
|
|
if (sn_timer) {
|
|
|
|
timer_stop(sn_timer);
|
|
|
|
sn_timer = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SN_MONITOR_EVENT_CANCELED:
|
|
|
|
if (sn_busy_cnt) --sn_busy_cnt;
|
|
|
|
if (sn_timer) {
|
|
|
|
timer_stop(sn_timer);
|
|
|
|
sn_timer = NULL;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sn_busy_cnt != cnt)
|
|
|
|
set_root_cursor();
|
|
|
|
}
|
|
|
|
#endif
|