Help with popup/popdown with pointer grab.
- From: <Dave 0Bits COM>
- To: <gtk-list gnome org>
- Subject: Help with popup/popdown with pointer grab.
- Date: Sat, 16 Jun 2001 12:04:15 +0100 (BST)
Hi,
I'm writing a small app that should automatically deiconify a
window and warp the pointer to its location for text input. However
everytime i try and grab the pointer it fails ! If i manually
deiconify thru my window manager then the grab succeeds. This leads
me to believe that the deiconifying functions in gtk/gdk are not ICCM
compliant and don't set the WM_STATE properly, or am i doing something
wrong in my code ? I have appended my short example with all superfuolous
code taken out. The window should popup and popdown every 2 seconds in
this test example and grab the pointer when it is deiconized.
Can anyone help please ?
Thanx
Dave
% gcc `gtk-config --cflags` main.c -o main `gtk-config --libs`
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
GtkWidget *window;
GtkWidget *button;
static void
gdk_window_iconify (GdkWindow * win)
{
g_return_if_fail (win != NULL);
XIconifyWindow (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XWINDOW (win), 0);
}
static gint
toggle_popup ()
{
static gint iconized = 1;
if (iconized)
{
/* Popup window and grab pointer */
gdk_window_show(window->window);
gdk_window_raise(window->window);
if (gdk_pointer_grab (window->window,
FALSE, GDK_POINTER_MOTION_MASK,
window->window, NULL, GDK_CURRENT_TIME)==0)
printf("grab succeeded\n");
else
printf("grab failed\n");
}
else
{
/* Iconize window, release grab */
gdk_pointer_ungrab (GDK_CURRENT_TIME);
gdk_window_iconify (window->window);
}
iconized=!iconized;
return TRUE;
}
int
main (int argc, char *argv[])
{
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
button = gtk_button_new_with_label ("Hello World");
gtk_container_add (GTK_CONTAINER (window), button);
gtk_timeout_add (2 * 1000, toggle_popup, NULL);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_exit), NULL);
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();
return (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]