Mouse coordinate trouble
- From: Gawain Lynch <gawain freda homelinux org>
- To: gtk-app-devel-list gnome org
- Subject: Mouse coordinate trouble
- Date: Mon, 01 Dec 2003 22:30:17 +1100
Hi,
I am trying to get the mouse coordinates at the point when I release the
button, i.e. I click on the window and when I release the button I wish
to move the window to the position.
The code below seems to get me most of the way however I am getting
strange results WRT the 'y' values returned and therefore have lost
total confidence in my own efforts to achieve this.
Can anybody save this piece of code? ;)
Thanks,
Gawain
gdouble x, y;
GdkModifierType state;
while (gdk_events_pending())
{
event = gdk_event_get();
if (event)
{
switch (event->type)
{
case GDK_DESTROY:
gdk_exit(0);
exit(0);
break;
case GDK_BUTTON_PRESS:
if (event->button.button == 3)
{
exit(0);
break;
}
if (event->button.button == 1)
{
gdk_pointer_grab(appwin.win, FALSE,
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, gdk_cursor_new(GDK_HAND2), GDK_CURRENT_TIME);
gdk_window_get_pointer(appwin.win, &x, &y, &state);
}
break;
case GDK_BUTTON_RELEASE:
gdk_window_get_pointer(appwin.win, &x, &y, &state);
x = event->motion.x_root;
y = event->motion.y_root;
gdk_window_move(appwin.win, x, y);
gdk_pointer_ungrab(GDK_CURRENT_TIME);
break;
default:
break;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]