Add "busy cursor on app startup" support, conditionally - works only if
2002-10-25 Havoc Pennington <hp@pobox.com> Add "busy cursor on app startup" support, conditionally - works only if libstartup-notification is found, and in practice requires a GTK patch that's not in yet. * src/screen.c: monitor startup events and set busy cursor if appropriate * src/display.c (meta_display_open): create SnDisplay * configure.in: check for startup notification, and add the cute "configure summary" at the end
This commit is contained in:

committed by
Havoc Pennington

parent
c3a5c4c169
commit
cb27f0c4be
@ -1,7 +1,7 @@
|
||||
|
||||
SUBDIRS=wm-tester tools themes
|
||||
|
||||
INCLUDES=@METACITY_CFLAGS@ -DMETACITY_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\" -DMETACITY_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -DMETACITY_PKGDATADIR=\"$(pkgdatadir)\" -DMETACITY_DATADIR=\"$(datadir)\" -DG_LOG_DOMAIN=\"metacity\"
|
||||
INCLUDES=@METACITY_CFLAGS@ -DMETACITY_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\" -DMETACITY_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -DMETACITY_PKGDATADIR=\"$(pkgdatadir)\" -DMETACITY_DATADIR=\"$(datadir)\" -DG_LOG_DOMAIN=\"metacity\" -DSN_API_NOT_YET_FROZEN=1
|
||||
|
||||
EGGFILES= \
|
||||
eggaccelerators.c \
|
||||
|
@ -129,7 +129,8 @@ typedef enum
|
||||
META_CURSOR_NE_RESIZE,
|
||||
META_CURSOR_NW_RESIZE,
|
||||
META_CURSOR_MOVE_WINDOW,
|
||||
META_CURSOR_RESIZE_WINDOW
|
||||
META_CURSOR_RESIZE_WINDOW,
|
||||
META_CURSOR_BUSY
|
||||
|
||||
} MetaCursor;
|
||||
|
||||
|
@ -138,6 +138,27 @@ remove_pending_pings_for_window (MetaDisplay *display, Window xwindow)
|
||||
g_slist_free (dead);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sn_error_trap_push (SnDisplay *sn_display,
|
||||
Display *xdisplay)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
if (display != NULL)
|
||||
meta_error_trap_push (display);
|
||||
}
|
||||
|
||||
static void
|
||||
sn_error_trap_pop (SnDisplay *sn_display,
|
||||
Display *xdisplay)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
if (display != NULL)
|
||||
meta_error_trap_pop (display, FALSE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_display_open (const char *name)
|
||||
{
|
||||
@ -372,6 +393,12 @@ meta_display_open (const char *name)
|
||||
display->groups_by_leader = NULL;
|
||||
|
||||
display->screens = NULL;
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
display->sn_display = sn_display_new (display->xdisplay,
|
||||
sn_error_trap_push,
|
||||
sn_error_trap_pop);
|
||||
#endif
|
||||
|
||||
#ifdef USE_GDK_DISPLAY
|
||||
display->events = NULL;
|
||||
@ -594,14 +621,14 @@ meta_display_close (MetaDisplay *display)
|
||||
g_source_remove (display->autoraise_timeout_id);
|
||||
display->autoraise_timeout_id = 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_GDK_DISPLAY
|
||||
/* Stop caring about events */
|
||||
meta_ui_remove_event_func (display->xdisplay,
|
||||
event_callback,
|
||||
display);
|
||||
#endif
|
||||
|
||||
|
||||
/* Free all screens */
|
||||
tmp = display->screens;
|
||||
while (tmp != NULL)
|
||||
@ -613,6 +640,14 @@ meta_display_close (MetaDisplay *display)
|
||||
|
||||
g_slist_free (display->screens);
|
||||
display->screens = NULL;
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
if (display->sn_display)
|
||||
{
|
||||
sn_display_unref (display->sn_display);
|
||||
display->sn_display = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Must be after all calls to meta_window_free() since they
|
||||
* unregister windows
|
||||
@ -967,6 +1002,10 @@ event_callback (XEvent *event,
|
||||
|
||||
if (dump_events)
|
||||
meta_spew_event (display, event);
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
sn_display_process_event (display->sn_display, event);
|
||||
#endif
|
||||
|
||||
filter_out_event = FALSE;
|
||||
display->current_time = event_get_time (display, event);
|
||||
@ -2192,7 +2231,10 @@ meta_display_create_x_cursor (MetaDisplay *display,
|
||||
case META_CURSOR_RESIZE_WINDOW:
|
||||
glyph = XC_fleur;
|
||||
break;
|
||||
|
||||
case META_CURSOR_BUSY:
|
||||
glyph = XC_watch;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
glyph = 0; /* silence compiler */
|
||||
|
@ -27,6 +27,10 @@
|
||||
#include "eventqueue.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
#include <libsn/sn.h>
|
||||
#endif
|
||||
|
||||
#define meta_XFree(p) do { if ((p)) XFree ((p)); } while (0)
|
||||
|
||||
/* this doesn't really belong here, oh well. */
|
||||
@ -149,6 +153,10 @@ struct _MetaDisplay
|
||||
Atom atom_net_wm_action_close;
|
||||
Atom atom_net_wm_state_above;
|
||||
Atom atom_net_wm_state_below;
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
SnDisplay *sn_display;
|
||||
#endif
|
||||
|
||||
/* This is the actual window from focus events,
|
||||
* not the one we last set
|
||||
|
218
src/screen.c
218
src/screen.c
@ -54,6 +54,11 @@ static void update_focus_mode (MetaScreen *screen);
|
||||
static void prefs_changed_callback (MetaPreference pref,
|
||||
gpointer data);
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
static void meta_screen_sn_event (SnMonitorEvent *event,
|
||||
void *user_data);
|
||||
#endif
|
||||
|
||||
static int
|
||||
set_wm_check_hint (MetaScreen *screen)
|
||||
{
|
||||
@ -580,6 +585,17 @@ meta_screen_new (MetaDisplay *display,
|
||||
screen->stack = meta_stack_new (screen);
|
||||
|
||||
meta_prefs_add_listener (prefs_changed_callback, screen);
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
screen->sn_context =
|
||||
sn_monitor_context_new (screen->display->sn_display,
|
||||
screen->number,
|
||||
meta_screen_sn_event,
|
||||
screen,
|
||||
NULL);
|
||||
screen->startup_sequences = NULL;
|
||||
screen->startup_sequence_timeout = 0;
|
||||
#endif
|
||||
|
||||
meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
|
||||
screen->number, screen->screen_name, screen->xroot);
|
||||
@ -604,6 +620,24 @@ meta_screen_free (MetaScreen *screen)
|
||||
|
||||
meta_screen_ungrab_keys (screen);
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
g_slist_foreach (screen->startup_sequences,
|
||||
(GFunc) sn_startup_sequence_unref, NULL);
|
||||
g_slist_free (screen->startup_sequences);
|
||||
screen->startup_sequences = NULL;
|
||||
|
||||
if (screen->startup_sequence_timeout != 0)
|
||||
{
|
||||
g_source_remove (screen->startup_sequence_timeout);
|
||||
screen->startup_sequence_timeout = 0;
|
||||
}
|
||||
if (screen->sn_context)
|
||||
{
|
||||
sn_monitor_context_unref (screen->sn_context);
|
||||
screen->sn_context = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
meta_ui_free (screen->ui);
|
||||
|
||||
meta_stack_free (screen->stack);
|
||||
@ -1619,3 +1653,187 @@ meta_screen_unshow_desktop (MetaScreen *screen)
|
||||
|
||||
meta_screen_focus_top_window (screen, NULL);
|
||||
}
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
static gboolean startup_sequence_timeout (void *data);
|
||||
|
||||
static void
|
||||
update_startup_feedback (MetaScreen *screen)
|
||||
{
|
||||
if (screen->startup_sequences != NULL)
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Setting busy cursor\n");
|
||||
meta_screen_set_cursor (screen, META_CURSOR_BUSY);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Setting default cursor\n");
|
||||
meta_screen_set_cursor (screen, META_CURSOR_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_sequence (MetaScreen *screen,
|
||||
SnStartupSequence *sequence)
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Adding sequence %s\n",
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
sn_startup_sequence_ref (sequence);
|
||||
screen->startup_sequences = g_slist_prepend (screen->startup_sequences,
|
||||
sequence);
|
||||
|
||||
/* our timeout just polls every second, instead of bothering
|
||||
* to compute exactly when we may next time out
|
||||
*/
|
||||
if (screen->startup_sequence_timeout == 0)
|
||||
screen->startup_sequence_timeout = g_timeout_add (1000,
|
||||
startup_sequence_timeout,
|
||||
screen);
|
||||
|
||||
update_startup_feedback (screen);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_sequence (MetaScreen *screen,
|
||||
SnStartupSequence *sequence)
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Removing sequence %s\n",
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
|
||||
screen->startup_sequences = g_slist_remove (screen->startup_sequences,
|
||||
sequence);
|
||||
sn_startup_sequence_unref (sequence);
|
||||
|
||||
if (screen->startup_sequences == NULL &&
|
||||
screen->startup_sequence_timeout != 0)
|
||||
{
|
||||
g_source_remove (screen->startup_sequence_timeout);
|
||||
screen->startup_sequence_timeout = 0;
|
||||
}
|
||||
|
||||
update_startup_feedback (screen);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GSList *list;
|
||||
GTimeVal now;
|
||||
} CollectTimedOutData;
|
||||
|
||||
#define STARTUP_TIMEOUT 5000
|
||||
|
||||
static void
|
||||
collect_timed_out_foreach (void *element,
|
||||
void *data)
|
||||
{
|
||||
CollectTimedOutData *ctod = data;
|
||||
SnStartupSequence *sequence = element;
|
||||
long tv_sec, tv_usec;
|
||||
double elapsed;
|
||||
|
||||
sn_startup_sequence_get_last_active_time (sequence, &tv_sec, &tv_usec);
|
||||
|
||||
elapsed =
|
||||
((((double)ctod->now.tv_sec - tv_sec) * G_USEC_PER_SEC +
|
||||
(ctod->now.tv_usec - tv_usec))) / 1000.0;
|
||||
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Sequence used %g seconds vs. %g max: %s\n",
|
||||
elapsed, (double) STARTUP_TIMEOUT,
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
|
||||
if (elapsed > STARTUP_TIMEOUT)
|
||||
ctod->list = g_slist_prepend (ctod->list, sequence);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
startup_sequence_timeout (void *data)
|
||||
{
|
||||
MetaScreen *screen = data;
|
||||
CollectTimedOutData ctod;
|
||||
GSList *tmp;
|
||||
|
||||
ctod.list = NULL;
|
||||
g_get_current_time (&ctod.now);
|
||||
g_slist_foreach (screen->startup_sequences,
|
||||
collect_timed_out_foreach,
|
||||
&ctod);
|
||||
|
||||
tmp = ctod.list;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
SnStartupSequence *sequence = tmp->data;
|
||||
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Timed out sequence %s\n",
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
|
||||
remove_sequence (screen, sequence);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
g_slist_free (ctod.list);
|
||||
|
||||
if (screen->startup_sequences != NULL)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* remove */
|
||||
screen->startup_sequence_timeout = 0;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_screen_sn_event (SnMonitorEvent *event,
|
||||
void *user_data)
|
||||
{
|
||||
MetaScreen *screen;
|
||||
SnStartupSequence *sequence;
|
||||
|
||||
screen = user_data;
|
||||
|
||||
sequence = sn_monitor_event_get_startup_sequence (event);
|
||||
|
||||
switch (sn_monitor_event_get_type (event))
|
||||
{
|
||||
case SN_MONITOR_EVENT_INITIATED:
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Received startup initiated for %s\n",
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
add_sequence (screen, sequence);
|
||||
}
|
||||
break;
|
||||
|
||||
case SN_MONITOR_EVENT_COMPLETED:
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Received startup completed for %s\n",
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
remove_sequence (screen,
|
||||
sn_monitor_event_get_startup_sequence (event));
|
||||
}
|
||||
break;
|
||||
|
||||
case SN_MONITOR_EVENT_CHANGED:
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Received startup changed for %s\n",
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
break;
|
||||
|
||||
case SN_MONITOR_EVENT_CANCELED:
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Received startup canceled for %s\n",
|
||||
sn_startup_sequence_get_id (sequence));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -79,6 +79,12 @@ struct _MetaScreen
|
||||
|
||||
/* Cache the current Xinerama */
|
||||
int last_xinerama_index;
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
SnMonitorContext *sn_context;
|
||||
GSList *startup_sequences;
|
||||
guint startup_sequence_timeout;
|
||||
#endif
|
||||
|
||||
guint work_area_idle;
|
||||
|
||||
|
@ -258,6 +258,8 @@ topic_name (MetaDebugTopic topic)
|
||||
return "SYNC";
|
||||
case META_DEBUG_ERRORS:
|
||||
return "ERRORS";
|
||||
case META_DEBUG_STARTUP:
|
||||
return "STARTUP";
|
||||
}
|
||||
|
||||
return "Window manager";
|
||||
|
@ -60,7 +60,8 @@ typedef enum
|
||||
META_DEBUG_XINERAMA = 1 << 11,
|
||||
META_DEBUG_KEYBINDINGS = 1 << 12,
|
||||
META_DEBUG_SYNC = 1 << 13,
|
||||
META_DEBUG_ERRORS = 1 << 14
|
||||
META_DEBUG_ERRORS = 1 << 14,
|
||||
META_DEBUG_STARTUP = 1 << 15
|
||||
|
||||
} MetaDebugTopic;
|
||||
|
||||
|
Reference in New Issue
Block a user