Search
lxdream.org :: lxdream/src/gtkui/gtk_win.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gtkui/gtk_win.c
changeset 850:28782ebbd01d
prev849:bbe26d798fc2
next854:130928a3cdcb
author nkeynes
date Mon Sep 08 07:56:33 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Add lightgun support
file annotate diff log raw
1.1 --- a/src/gtkui/gtk_win.c Mon Sep 08 05:13:51 2008 +0000
1.2 +++ b/src/gtkui/gtk_win.c Mon Sep 08 07:56:33 2008 +0000
1.3 @@ -135,11 +135,23 @@
1.4 input_event_mousemove( x - win->mouse_x, y - win->mouse_y, FALSE );
1.5 video_window_center_pointer(win);
1.6 } else {
1.7 - input_event_mousemove( x, y, TRUE );
1.8 + int width, height;
1.9 + gdk_drawable_get_size(GDK_DRAWABLE(widget->window), &width, &height);
1.10 + input_event_mousemove( x * DISPLAY_WIDTH /width , y * DISPLAY_HEIGHT / height, TRUE );
1.11 }
1.12 return TRUE;
1.13 }
1.14
1.15 +static gboolean on_video_window_mouse_exited( GtkWidget *widget, GdkEventCrossing *event,
1.16 + gpointer user_data )
1.17 +{
1.18 + main_window_t win = (main_window_t)user_data;
1.19 + if( !win->is_grabbed ) {
1.20 + input_event_mousemove( -1, -1, TRUE );
1.21 + }
1.22 + return TRUE;
1.23 +}
1.24 +
1.25 static gboolean on_video_window_mouse_pressed( GtkWidget *widget, GdkEventButton *event,
1.26 gpointer user_data )
1.27 {
1.28 @@ -147,7 +159,10 @@
1.29 if( win->is_grabbed ) {
1.30 input_event_mousedown( event->button-1, 0, 0, FALSE );
1.31 } else {
1.32 - input_event_mousedown( event->button-1, (int32_t)event->x, (int32_t)event->y, TRUE );
1.33 + int width, height;
1.34 + gdk_drawable_get_size(GDK_DRAWABLE(widget->window), &width, &height);
1.35 + input_event_mousedown( event->button-1, (int32_t)event->x * DISPLAY_WIDTH / width,
1.36 + (int32_t)event->y * DISPLAY_HEIGHT / height, TRUE );
1.37 }
1.38 return TRUE;
1.39 }
1.40 @@ -161,7 +176,10 @@
1.41 } else if( win->use_grab) {
1.42 video_window_grab_display(win);
1.43 } else {
1.44 - input_event_mouseup( event->button-1, (int32_t)event->x, (int32_t)event->y, TRUE );
1.45 + int width, height;
1.46 + gdk_drawable_get_size(GDK_DRAWABLE(widget->window), &width, &height);
1.47 + input_event_mouseup( event->button-1, (int32_t)event->x * DISPLAY_WIDTH / width,
1.48 + (int32_t)event->y * DISPLAY_HEIGHT / height, TRUE );
1.49 }
1.50 return TRUE;
1.51 }
1.52 @@ -298,6 +316,8 @@
1.53 G_CALLBACK(on_video_window_key_released), win );
1.54 g_signal_connect( win->video, "motion-notify-event",
1.55 G_CALLBACK(on_video_window_mouse_motion), win );
1.56 + g_signal_connect( win->video, "leave-notify-event",
1.57 + G_CALLBACK(on_video_window_mouse_exited), win );
1.58 g_signal_connect( win->video, "button-press-event",
1.59 G_CALLBACK(on_video_window_mouse_pressed), win );
1.60 g_signal_connect( win->video, "button-release-event",
1.61 @@ -310,7 +330,8 @@
1.62 gtk_widget_add_events( win->video,
1.63 GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
1.64 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
1.65 - GDK_POINTER_MOTION_MASK | GDK_FOCUS_CHANGE_MASK );
1.66 + GDK_POINTER_MOTION_MASK | GDK_FOCUS_CHANGE_MASK |
1.67 + GDK_LEAVE_NOTIFY_MASK );
1.68
1.69 return win;
1.70 }
.