Re: Wait cursor animation does not work properly
- From: Stefan Salewski <mail ssalewski de>
- To: gtk-list gnome org
- Subject: Re: Wait cursor animation does not work properly
- Date: Sun, 03 Sep 2017 17:32:45 +0200
On Sun, 2017-09-03 at 16:43 +0200, Stefan Salewski wrote:
Since a few months I have observed that for my chess game the mouse
pointer/cursor animation stopped working properly.
Well, I have added the g_idle_add() problem also.
When I move the mouse pointer the first time into the button widget,
animation works fine. But when I click on the button, animation stops
while idle function is active, which is 5 seconds. After that period
animation works fine again.
But when I move the pointer out of the window and back again, animation
is stopped and will not start again.
May that be a Wayland problem? I do not really think so, but I am not
really sure.
// gcc t.c `pkg-config --libs --cflags gtk+-3.0`
#include <gtk/gtk.h>
//include <glib/glib.h>
#include <glib/gprintf.h>
static gboolean
idle_func(gpointer data)
{
int i;
i = 0;
while (i < 9)
{
g_usleep(1000000);
i++;
g_printf("busy\n");
}
return G_SOURCE_REMOVE;
}
static void
button_clicked (GtkButton *button,
gpointer user_data)
{
const char *old_label;
char *new_label;
old_label = gtk_button_get_label (button);
new_label = g_utf8_strreverse (old_label, -1);
gtk_button_set_label (button, new_label);
g_free (new_label);
g_idle_add(idle_func, NULL);
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *button;
GdkDisplay *display;
GdkCursor *cursor;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "GNOME Button");
gtk_window_set_default_size (GTK_WINDOW (window), 250, 50);
button = gtk_button_new_with_label ("Click Me");
gtk_container_add (GTK_CONTAINER (window), button);
g_signal_connect (GTK_BUTTON (button),
"clicked",
G_CALLBACK (button_clicked),
G_OBJECT (window));
gtk_widget_show_all (window);
display = gdk_display_get_default();
cursor = gdk_cursor_new_from_name(display, "wait");
gdk_window_set_cursor(gtk_widget_get_window(window), cursor);
}
int
main (int argc, char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]