Advertisement
Guest User

patch for qemu gtk ui

a guest
Oct 24th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.52 KB | None | 0 0
  1. diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
  2. index a77c25b..824beed 100644
  3. --- a/ui/gtk-egl.c
  4. +++ b/ui/gtk-egl.c
  5. @@ -231,9 +231,13 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl,
  6.                              uint32_t pos_x, uint32_t pos_y)
  7.  {
  8.      VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
  9. -
  10. -    vc->gfx.cursor_x = pos_x;
  11. -    vc->gfx.cursor_y = pos_y;
  12. +    uint32_t sw = surface_width(vc->gfx.ds);
  13. +    uint32_t sh = surface_height(vc->gfx.ds);
  14. +    GdkWindow *window = gtk_widget_get_window(vc->gfx.drawing_area);
  15. +    uint32_t ww = gdk_window_get_width(window);
  16. +    uint32_t wh = gdk_window_get_height(window);
  17. +    vc->gfx.cursor_x = pos_x * ww / sw;
  18. +    vc->gfx.cursor_y = pos_y * wh / sh;
  19.  }
  20.  
  21.  void gd_egl_release_dmabuf(DisplayChangeListener *dcl,
  22. diff --git a/ui/gtk.c b/ui/gtk.c
  23. index 579990b..6525377 100644
  24. --- a/ui/gtk.c
  25. +++ b/ui/gtk.c
  26. @@ -875,20 +875,27 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
  27.      x = (motion->x - mx) / vc->gfx.scale_x;
  28.      y = (motion->y - my) / vc->gfx.scale_y;
  29.  
  30. +    bool scaled = display_opengl && !gtk_use_gl_area && s->free_scale;
  31.      if (qemu_input_is_absolute()) {
  32. +        int max_w = scaled ? ww : surface_width(vc->gfx.ds);
  33. +        int max_h = scaled ? wh : surface_height(vc->gfx.ds);
  34.          if (x < 0 || y < 0 ||
  35. -            x >= surface_width(vc->gfx.ds) ||
  36. -            y >= surface_height(vc->gfx.ds)) {
  37. +            x >= max_w ||
  38. +            y >= max_h) {
  39.              return TRUE;
  40.          }
  41.          qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_X, x,
  42. -                             0, surface_width(vc->gfx.ds));
  43. +                             0, max_w);
  44.          qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_Y, y,
  45. -                             0, surface_height(vc->gfx.ds));
  46. +                             0, max_h);
  47.          qemu_input_event_sync();
  48.      } else if (s->last_set && s->ptr_owner == vc) {
  49. -        qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_X, x - s->last_x);
  50. -        qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_Y, y - s->last_y);
  51. +        int diff_x = scaled
  52. +            ? (x - s->last_x) * surface_width(vc->gfx.ds) / ww : (x - s->last_x);
  53. +        int diff_y = scaled
  54. +            ? (y - s->last_y) * surface_height(vc->gfx.ds) / wh : (y - s->last_y);
  55. +        qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_X, diff_x);
  56. +        qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_Y, diff_y);
  57.          qemu_input_event_sync();
  58.      }
  59.      s->last_x = x;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement