Skip to content

Commit

Permalink
Improve Kempston mouse handling under GTK+ 3.x.
Browse files Browse the repository at this point in the history
On X11, warp relative to the top-level window (improves things on Phil's
laptop). On Wayland, don't warp at all as it causes a crash.
  • Loading branch information
pak21 committed Oct 14, 2018
1 parent 1983a30 commit 5512a4a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
14 changes: 10 additions & 4 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
2018-09-?? Philip Kendall <[email protected]>

* UI improvements:
* GTK+ 3: Make the offset entry wider in memory browser (Derek
Fountain).
* Improve Fuse's window sizing under Wayland; still not right, but
better than it was before (Sergio Baldoví).
* Improve Fuse's Kempston mouse handling under GTK+ 3.x (Philip
Kendall).
* Stop Kempston mouse causing a crash under Wayland; still doesn't
work properly though (Philip Kendall).

* Miscellaneous improvements:
* "Save binary" command can now save 65536 bytes again (regression
introduced in 1.5.6; thanks, thrice) (Philip Kendall).
* GTK+ 3 UI: Make the offset entry wider in memory browser (Derek
Fountain).
* Improve Fuse's behaviour under Wayland; still not right, but
better than it was before (Sergio Baldoví).
* Remove gcc 8 string overflow warnings (Philip Kendall).

2018-08-06 Philip Kendall <[email protected]>
Expand Down
31 changes: 30 additions & 1 deletion ui/gtk/gtkmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "gtkinternals.h"
#include "ui/ui.h"

#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif

/* For XWarpPointer *only* - see below */
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
Expand All @@ -46,8 +50,33 @@ gtkmouse_reset_pointer( void )
* For Win32, use SetCursorPos() -- see sdpGtkWarpPointer() at
* http://k3d.cvs.sourceforge.net/k3d/projects/sdplibs/sdpgtk/sdpgtkutility.cpp?view=markup
*/
GdkWindow *window = gtk_widget_get_window( gtkui_drawing_area );
GtkWindow *gtkwindow;
GdkWindow *window;

/* The logic here is a bit hairy:
* On GTK+ 2.x, we warp relative to the drawing area
* On GTK+ 3.x on X11, we warp relative to the top-level window
* On GTK+ 3.x on Wayland, we don't warp at all because it causes a
segfault (see bug #435)
*/

#if GTK_CHECK_VERSION( 3, 0, 0 )

#ifdef GDK_WINDOWING_WAYLAND
GdkDisplay *display = gdk_display_get_default();
if( GDK_IS_WAYLAND_DISPLAY( display ) ) return;
#endif /* #ifdef GDK_WINDOWING_WAYLAND */

gtkwindow = gtkui_window;

#else /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */

gtkwindow = gtkui_drawing_area;

#endif /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */

window = gtk_widget_get_window( gtkwindow );
XWarpPointer( GDK_WINDOW_XDISPLAY( window ), None,
GDK_WINDOW_XID( window ), 0, 0, 0, 0, 128, 128 );
}
Expand Down

0 comments on commit 5512a4a

Please sign in to comment.