Window moving problem
- From: Matthew D Allen <s2mdalle titan vcu edu>
- To: gtk-list redhat com
- Subject: Window moving problem
- Date: Sat, 25 Sep 1999 01:51:33 -0400 (EDT)
Here is the source code to a simple 3 function program which demonstrates
a problem I've been having consistantly with window moving functions.
When I compile and run this program, I click on the button, and the
application goes to the upper left hand corner, and with each subsequent
click on the button, it goes a bit to the right and a bit down. The code
is supposed to make it go just 10 pixels to the right and that's it, but
instead I get sometimes jumpy behavior and never totally correct behavior.
If there are any suggestions on what I might be doing wrong, I would
appreciate hearing them, but as far as I can see I'm using the functoins
correctly.
At the heart of the problem are these calls: I call
gdk_window_get_position(window->window, &someint, &someotherint);
someint += 10;
gdk_window_move(window->window, someint, someotherint);
which should move the window only to the right but doesn't.
Sample code: This when compiled should act strangely.
#------------#
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
void silly_callback(GtkWidget *e, gpointer data)
{
GtkWidget *window = (GtkWidget *)data;
int x=0, y=0;
gdk_window_get_position(window->window, &x, &y);
/* Just shift the window to the right by 10 pixels. */
x += 10;
gdk_window_move(window->window, x, y);
} /* End callback */
void die_now(GtkWidget *e, gpointer data)
{
printf("Destroying..."); fflush(stdout);
gtk_widget_destroy((GtkWidget *)data);
printf("Exiting..."); fflush(stdout);
gtk_main_quit();
printf("Quitting.\n"); fflush(stdout);
exit(0);
} /* End die_now */
int main(int argc, char *argv[])
{
GtkWidget *window, *button;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("Click me");
gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, TRUE);
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_realize(window);
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(silly_callback), window);
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(die_now), window);
gtk_signal_connect(GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(die_now), window);
gtk_widget_show_all(window);
gtk_main();
exit(0);
} /* End main */
#----#
That's it. Any suggestions on what I'm screwing up here?
http://opop.nols.com/index.shtml - Linux software development
There are three kinds of people: Those who can count, and those who can't.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]