Problem with WM or gtk+ in gdk_window_get_position()



Hi,
I have a problem with gdk_window_get_position() and the
cause could be the Window Maker window manager.

When using Window Maker as the windowmanager, and when
you call gdk_window_get_position() without moving
the window, you get the position of the window like if
it is at position(0, 0);

But, if you move the window, and then call gdk_window_get_position()
you get the right position.

Please note that that the gdk_window_get_position() return the
position of the window including the window manager decoration.

Run this litle code and compare the result. The code is
helloworld.c from gtk+1.2.6 without comments.

Regards
Oliver
-- 
Oliver Schulze L.
oliver@pla.net.py
Asuncion-Paraguay
http://www.pla.net.py/home/oliver/
/* example-start helloworld helloworld.c */
/*
 *	helloworld_wm.c from the helloworld.c gtk+-1.2.6 distribution
 *	
 *	Modified by Oliver Schulze <oliver@pla.net.py> to reflect
 *	the gdk_window_get_position() behavior under the WindowMaker 
 *	window manager.
 *	
 *	Compile it with:
 *	gcc `gtk-config --cflags`  helloworld_wm.c -o helloworld_wm `gtk-config --libs`
 *	
 *	Instructions:
 *	1. First test: execute and click the buton
 *	2. Second test: execute, move the window and then click the button
 *	3. Compare the positions printed
 *	
 *	Tue Feb  8 16:55:32 PYST 2000
 */

#include <gtk/gtk.h>

void hello( GtkWidget *widget,
            GtkWidget *window )
{
	gint x, y;
	
  g_print ("Hello World\n");

	gdk_window_get_position(window->window, &x, &y);
	g_print("gdk_window_get_position    : (%d, %d)\n", x, y);

	gdk_window_get_root_origin(window->window, &x, &y);
	g_print("gdk_window_get_root_origin : (%d, %d)\n", x, y);
    
}

gint delete_event( GtkWidget *widget,
                   GdkEvent  *event,
		   gpointer   data )
{

    g_print ("delete event occurred\n");

    return(TRUE);
}

void destroy( GtkWidget *widget,
              gpointer   data )
{
    gtk_main_quit();
}

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    GtkWidget *button;
    
    /* This is called in all GTK applications. Arguments are parsed
     * from the command line and are returned to the application. */
    gtk_init(&argc, &argv);
    
    /* create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    
    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
			GTK_SIGNAL_FUNC (delete_event), NULL);
    
    gtk_signal_connect (GTK_OBJECT (window), "destroy",
			GTK_SIGNAL_FUNC (destroy), NULL);
    
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    
    button = gtk_button_new_with_label ("Hello World");
    
    gtk_signal_connect (GTK_OBJECT (button), "clicked",
			GTK_SIGNAL_FUNC (hello), window);
    
    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
			       GTK_SIGNAL_FUNC (gtk_widget_destroy),
			       GTK_OBJECT (window));
    
    gtk_container_add (GTK_CONTAINER (window), button);
    
    gtk_widget_show (button);
    
    gtk_widget_show (window);
    gtk_main ();
    
    return(0);
}
/* example-end */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]