meta-wayland-pointer.h 5.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Wayland Support
 *
 * Copyright (C) 2013 Intel Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

20 21
#ifndef META_WAYLAND_POINTER_H
#define META_WAYLAND_POINTER_H
22 23 24

#include <wayland-server.h>

25 26 27
#include <glib.h>

#include "meta-wayland-types.h"
28
#include "meta-wayland-pointer-gesture-swipe.h"
29
#include "meta-wayland-pointer-gesture-pinch.h"
30
#include "meta-wayland-surface.h"
31
#include "meta-wayland-pointer-constraints.h"
32

33 34
#include <meta/meta-cursor-tracker.h>

35 36
struct _MetaWaylandPointerGrabInterface
{
37
  void (*focus) (MetaWaylandPointerGrab *grab,
38
                 MetaWaylandSurface     *surface);
39 40 41 42
  void (*motion) (MetaWaylandPointerGrab *grab,
		  const ClutterEvent     *event);
  void (*button) (MetaWaylandPointerGrab *grab,
		  const ClutterEvent     *event);
43 44 45 46 47 48 49 50
};

struct _MetaWaylandPointerGrab
{
  const MetaWaylandPointerGrabInterface *interface;
  MetaWaylandPointer *pointer;
};

51 52 53
struct _MetaWaylandPointerClient
{
  struct wl_list pointer_resources;
54
  struct wl_list swipe_gesture_resources;
55
  struct wl_list pinch_gesture_resources;
56
  struct wl_list relative_pointer_resources;
57 58
};

59 60
struct _MetaWaylandPointer
{
61 62
  struct wl_display *display;

63 64
  MetaWaylandPointerClient *focus_client;
  GHashTable *pointer_clients;
65 66

  MetaWaylandSurface *focus_surface;
67
  struct wl_listener focus_surface_listener;
68
  guint32 focus_serial;
69
  guint32 click_serial;
70

71
  MetaWaylandSurface *cursor_surface;
72
  guint cursor_surface_destroy_id;
73

74 75 76 77 78
  MetaWaylandPointerGrab *grab;
  MetaWaylandPointerGrab default_grab;
  guint32 grab_button;
  guint32 grab_serial;
  guint32 grab_time;
79
  float grab_x, grab_y;
80

81
  ClutterInputDevice *device;
82 83 84 85
  MetaWaylandSurface *current;

  guint32 button_count;
};
86

87 88
void meta_wayland_pointer_init (MetaWaylandPointer *pointer,
                                struct wl_display  *display);
89

90
void meta_wayland_pointer_release (MetaWaylandPointer *pointer);
91

92 93
void meta_wayland_pointer_update (MetaWaylandPointer *pointer,
                                  const ClutterEvent *event);
94

95 96
gboolean meta_wayland_pointer_handle_event (MetaWaylandPointer *pointer,
                                            const ClutterEvent *event);
97

98 99 100
void meta_wayland_pointer_send_motion (MetaWaylandPointer *pointer,
                                       const ClutterEvent *event);

101 102 103
void meta_wayland_pointer_send_relative_motion (MetaWaylandPointer *pointer,
                                                const ClutterEvent *event);

104 105 106
void meta_wayland_pointer_send_button (MetaWaylandPointer *pointer,
                                       const ClutterEvent *event);

107 108
void meta_wayland_pointer_broadcast_frame (MetaWaylandPointer *pointer);

109 110
void meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
                                     MetaWaylandSurface *surface);
111

112 113
void meta_wayland_pointer_start_grab (MetaWaylandPointer *pointer,
                                      MetaWaylandPointerGrab *grab);
114

115
void meta_wayland_pointer_end_grab (MetaWaylandPointer *pointer);
116

117 118
MetaWaylandPopup *meta_wayland_pointer_start_popup_grab (MetaWaylandPointer      *pointer,
                                                         MetaWaylandPopupSurface *popup_surface);
119

120 121
void meta_wayland_pointer_end_popup_grab (MetaWaylandPointer *pointer);

122
void meta_wayland_pointer_repick (MetaWaylandPointer *pointer);
123

124 125 126 127
void meta_wayland_pointer_get_relative_coordinates (MetaWaylandPointer *pointer,
                                                    MetaWaylandSurface *surface,
                                                    wl_fixed_t         *x,
                                                    wl_fixed_t         *y);
128

129 130 131 132
void meta_wayland_pointer_create_new_resource (MetaWaylandPointer *pointer,
                                               struct wl_client   *client,
                                               struct wl_resource *seat_resource,
                                               uint32_t id);
133

134 135 136 137
gboolean meta_wayland_pointer_can_grab_surface (MetaWaylandPointer *pointer,
                                                MetaWaylandSurface *surface,
                                                uint32_t            serial);

138 139 140
gboolean meta_wayland_pointer_can_popup (MetaWaylandPointer *pointer,
                                         uint32_t            serial);

141 142
MetaWaylandSurface *meta_wayland_pointer_get_top_popup (MetaWaylandPointer *pointer);

143 144 145 146
MetaWaylandPointerClient * meta_wayland_pointer_get_pointer_client (MetaWaylandPointer *pointer,
                                                                    struct wl_client   *client);
void meta_wayland_pointer_unbind_pointer_client_resource (struct wl_resource *resource);

147 148
void meta_wayland_relative_pointer_init (MetaWaylandCompositor *compositor);

149 150
MetaWaylandSeat *meta_wayland_pointer_get_seat (MetaWaylandPointer *pointer);

151 152 153 154
void meta_wayland_surface_cursor_update (MetaWaylandSurface *cursor_surface);

void meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer);

155
#endif /* META_WAYLAND_POINTER_H */