Skip to content
Browse files

Add device reporting to button & wheel events in hl_cairo1

  • Loading branch information...
1 parent 155783d commit 57d49948db68b3bf729676c77add8d0c11a45383 @jtappin jtappin committed Jan 1, 2013
Showing with 15 additions and 2 deletions.
  1. +15 −2 examples/hl_cairo1.f90
View
17 examples/hl_cairo1.f90
@@ -47,7 +47,8 @@ module handlers
& cairo_paint, cairo_rectangle
use gdk, only: gdk_cairo_create, gdk_keyval_from_name, gdk_keyval_name, &
- & gdk_cairo_set_source_window
+ & gdk_cairo_set_source_window, gdk_device_get_name, &
+ & gdk_device_get_source
use g, only: g_usleep
@@ -78,7 +79,8 @@ function button_event_h(widget, event, gdata) result(rv) bind(c)
type(c_ptr), value, intent(in) :: widget, event, gdata
type(gdkeventbutton), pointer :: bevent
- integer(kind=c_int) :: event_mask
+ type(c_ptr) :: dcname
+ character(len=64) :: dname
print *, "Button press detected"
if (c_associated(event)) then
@@ -87,6 +89,11 @@ function button_event_h(widget, event, gdata) result(rv) bind(c)
print *, "Type:", bevent%type
print *, "State, Button:", bevent%state, bevent%button
print *, "Root x,y:", int(bevent%x_root), int(bevent%y_root)
+ dcname = gdk_device_get_name(bevent%device)
+ call c_f_string(dcname, dname)
+ print *, "Device: ",trim(dname), &
+ & gdk_device_get_source(bevent%device)
+
if (bevent%type == GDK_2BUTTON_PRESS .and. &
& bevent%button == 3) call gtk_main_quit
end if
@@ -114,13 +121,19 @@ function scroll_event_h(widget, event, gdata) bind(c) result(rv)
type(c_ptr), value, intent(in) :: widget, event, gdata
type(gdkeventscroll), pointer :: bevent
+ type(c_ptr) :: dcname
+ character(len=64) :: dname
print *, "Wheel event detected"
if (c_associated(event)) then
call c_f_pointer(event,bevent)
print *, "Clicked at:", int(bevent%x), int(bevent%y)
print *, "State, direction:", bevent%state, bevent%direction
print *, "Root x,y:", int(bevent%x_root), int(bevent%y_root)
+ dcname = gdk_device_get_name(bevent%device)
+ call c_f_string(dcname, dname)
+ print *, "Device: ",trim(dname), &
+ & gdk_device_get_source(bevent%device)
end if
print *
rv = FALSE

0 comments on commit 57d4994

Please sign in to comment.
Something went wrong with that request. Please try again.