Results 1 to 3 of 3
today,I use gtk_window_set_gravity function to init window location on screen.
I use different parameter value in Gravity,window location always at top left of screen.
I use ubuntu 10.04. Code by ...
- 10-18-2010 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 4
gtk_window_set_gravity something wrong ?
today,I use gtk_window_set_gravity function to init window location on screen.
I use different parameter value in Gravity,window location always at top left of screen.
I use ubuntu 10.04. Code by follow:
GtkWidget * window, *label;
gtk_init(p_argc, p_argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
label = gtk_label_new(NULL);
gtk_window_set_title(GTK_WINDOW(window), "hello GTK 2!");
gtk_container_set_border_width (GTK_CONTAINER(window), 10);
gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
gtk_widget_set_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK);
//event binding
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(delete_event), NULL);
g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(kpress_on_main_window_handler), label);
gtk_label_set_markup(GTK_LABEL(label), "<b><i>Hello World!</i></b>");
gtk_label_set_selectable(GTK_LABEL(label), TRUE);
gtk_container_add(GTK_CONTAINER(window), label);
gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_NORTH);
gtk_widget_show_all(window);
gtk_main();
- 10-18-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
So, what's your problem? I see your code, and that you say you have a problem, but nothing about the problem itself other than that the window ends up at the upper left corner of the screen. I assume that the gtk_set_gravity() function ends up calling the XGravityEvent() function in XLib. If so, then the location is relative to the parent window, which in the case of a normal window would be the screen. What X,Y locations do you specify?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 10-18-2010 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Also, you should probably move this thread to the "Programming / Scripting" or "Desktop / X-Windows" forums.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote