Comment 3 for bug 1024482

Revision history for this message
Jason Conti (jconti) wrote :

I should also note that setting the cursor explicitly to the LEFT_PTR in any gtk app will cause that app to show cursor updates properly when hovered over (which is why I think Firefox still works when you hover over it as mentioned in bug #86184 ):

#include <gdk/gdk.h>
#include <gtk/gtk.h>

int
main()
{
  gtk_init(NULL, NULL);

  GdkCursor *default_cursor = gdk_cursor_new(GDK_ARROW);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  g_signal_connect(G_OBJECT(window), "destroy", gtk_main_quit, NULL);
  gtk_widget_realize(window);
  gtk_widget_show(window);

  gdk_window_set_cursor(gtk_widget_get_window(window), default_cursor);
  g_object_unref(default_cursor);

  gtk_main();
  return 0;
}

And we can force a cursor update by setting the LEFT_PTR on the root window (but this will also break future cursor updates if you had logged in with gdm or lightdm-gtk-greeter with the patch above):

#include <gdk/gdk.h>
#include <gtk/gtk.h>

gboolean idle_cb(gpointer user_data)
{
  gtk_main_quit();
  return FALSE;
}

int main()
{
  gtk_init (NULL, NULL);

  GdkCursor *cursor = gdk_cursor_new (GDK_LEFT_PTR);
  gdk_window_set_cursor (gdk_get_default_root_window (), cursor);
  g_object_unref (cursor);

  g_idle_add (idle_cb, NULL);

  gtk_main ();
  return 0;
}