screen: Use meta_device_pointer_set_window_cursor() for startup sequence.

At the moment feedback is only provided for the Virtual Core Pointer
This commit is contained in:
Carlos Garnacho 2011-07-04 20:23:33 +02:00
parent 1dd50cf006
commit 972a9d231f
3 changed files with 41 additions and 24 deletions

View File

@ -4273,22 +4273,29 @@ meta_display_set_cursor_theme (const char *theme,
{ {
#ifdef HAVE_XCURSOR #ifdef HAVE_XCURSOR
GSList *tmp; GSList *tmp;
GList *devices, *d;
MetaDisplay *display = meta_get_display (); MetaDisplay *display = meta_get_display ();
XcursorSetTheme (display->xdisplay, theme); XcursorSetTheme (display->xdisplay, theme);
XcursorSetDefaultSize (display->xdisplay, size); XcursorSetDefaultSize (display->xdisplay, size);
devices = meta_device_map_list_devices (display->device_map);
tmp = display->screens; tmp = display->screens;
while (tmp != NULL) while (tmp != NULL)
{ {
MetaScreen *screen = tmp->data; MetaScreen *screen = tmp->data;
meta_screen_update_cursor (screen); for (d = devices; d; d = d->next)
{
if (META_IS_DEVICE_POINTER (d->data))
meta_screen_update_cursor (screen, d->data);
}
tmp = tmp->next; tmp = tmp->next;
} }
g_list_free (devices);
#endif #endif
} }

View File

@ -90,7 +90,8 @@ struct _MetaScreen
MetaStack *stack; MetaStack *stack;
MetaStackTracker *stack_tracker; MetaStackTracker *stack_tracker;
MetaCursor current_cursor; /* per-pointer cursors */
GHashTable *cursors;
Window flash_window; Window flash_window;
@ -158,8 +159,10 @@ void meta_screen_queue_frame_redraws (MetaScreen *scree
void meta_screen_queue_window_resizes (MetaScreen *screen); void meta_screen_queue_window_resizes (MetaScreen *screen);
void meta_screen_set_cursor (MetaScreen *screen, void meta_screen_set_cursor (MetaScreen *screen,
MetaDevice *pointer,
MetaCursor cursor); MetaCursor cursor);
void meta_screen_update_cursor (MetaScreen *screen); void meta_screen_update_cursor (MetaScreen *screen,
MetaDevice *pointer);
void meta_screen_tab_popup_create (MetaScreen *screen, void meta_screen_tab_popup_create (MetaScreen *screen,
MetaTabList list_type, MetaTabList list_type,

View File

@ -778,10 +778,10 @@ meta_screen_new (MetaDisplay *display,
screen->rect.x = screen->rect.y = 0; screen->rect.x = screen->rect.y = 0;
screen->rect.width = WidthOfScreen (screen->xscreen); screen->rect.width = WidthOfScreen (screen->xscreen);
screen->rect.height = HeightOfScreen (screen->xscreen); screen->rect.height = HeightOfScreen (screen->xscreen);
screen->current_cursor = -1; /* invalid/unset */
screen->default_xvisual = DefaultVisualOfScreen (screen->xscreen); screen->default_xvisual = DefaultVisualOfScreen (screen->xscreen);
screen->default_depth = DefaultDepthOfScreen (screen->xscreen); screen->default_depth = DefaultDepthOfScreen (screen->xscreen);
screen->flash_window = None; screen->flash_window = None;
screen->cursors = g_hash_table_new (NULL, NULL);
screen->wm_sn_selection_window = new_wm_sn_owner; screen->wm_sn_selection_window = new_wm_sn_owner;
screen->wm_sn_atom = wm_sn_atom; screen->wm_sn_atom = wm_sn_atom;
@ -806,8 +806,6 @@ meta_screen_new (MetaDisplay *display,
screen->last_monitor_index = 0; screen->last_monitor_index = 0;
reload_monitor_infos (screen); reload_monitor_infos (screen);
meta_screen_set_cursor (screen, META_CURSOR_DEFAULT);
/* Handle creating a no_focus_window for this screen */ /* Handle creating a no_focus_window for this screen */
screen->no_focus_window = screen->no_focus_window =
@ -969,6 +967,8 @@ meta_screen_free (MetaScreen *screen,
g_free (screen->screen_name); g_free (screen->screen_name);
g_hash_table_destroy (screen->cursors);
g_object_unref (screen); g_object_unref (screen);
XFlush (display->xdisplay); XFlush (display->xdisplay);
@ -1582,31 +1582,33 @@ update_focus_mode (MetaScreen *screen)
void void
meta_screen_set_cursor (MetaScreen *screen, meta_screen_set_cursor (MetaScreen *screen,
MetaDevice *pointer,
MetaCursor cursor) MetaCursor cursor)
{ {
Cursor xcursor; MetaCursor old_cursor;
if (cursor == screen->current_cursor) old_cursor = GPOINTER_TO_UINT (g_hash_table_lookup (screen->cursors, pointer));
if (cursor == old_cursor)
return; return;
screen->current_cursor = cursor; g_hash_table_insert (screen->cursors, pointer,
GUINT_TO_POINTER (cursor));
xcursor = meta_display_create_x_cursor (screen->display, cursor);
XDefineCursor (screen->display->xdisplay, screen->xroot, xcursor); meta_screen_update_cursor (screen, pointer);
XFlush (screen->display->xdisplay);
XFreeCursor (screen->display->xdisplay, xcursor);
} }
void void
meta_screen_update_cursor (MetaScreen *screen) meta_screen_update_cursor (MetaScreen *screen,
MetaDevice *pointer)
{ {
Cursor xcursor; MetaCursor cursor;
xcursor = meta_display_create_x_cursor (screen->display, cursor = GPOINTER_TO_UINT (g_hash_table_lookup (screen->cursors, pointer));
screen->current_cursor); meta_device_pointer_set_window_cursor (META_DEVICE_POINTER (pointer),
XDefineCursor (screen->display->xdisplay, screen->xroot, xcursor); screen->xroot,
cursor);
XFlush (screen->display->xdisplay); XFlush (screen->display->xdisplay);
XFreeCursor (screen->display->xdisplay, xcursor);
} }
void void
@ -3056,17 +3058,22 @@ static gboolean startup_sequence_timeout (void *data);
static void static void
update_startup_feedback (MetaScreen *screen) update_startup_feedback (MetaScreen *screen)
{ {
MetaDevice *pointer;
pointer = meta_device_map_lookup (screen->display->device_map,
META_CORE_POINTER_ID);
if (screen->startup_sequences != NULL) if (screen->startup_sequences != NULL)
{ {
meta_topic (META_DEBUG_STARTUP, meta_topic (META_DEBUG_STARTUP,
"Setting busy cursor\n"); "Setting busy cursor\n");
meta_screen_set_cursor (screen, META_CURSOR_BUSY); meta_screen_set_cursor (screen, pointer, META_CURSOR_BUSY);
} }
else else
{ {
meta_topic (META_DEBUG_STARTUP, meta_topic (META_DEBUG_STARTUP,
"Setting default cursor\n"); "Setting default cursor\n");
meta_screen_set_cursor (screen, META_CURSOR_DEFAULT); meta_screen_set_cursor (screen, pointer, META_CURSOR_DEFAULT);
} }
} }