1 | /* GTK - The GIMP Toolkit |
2 | * Copyright (C) 2012, One Laptop Per Child. |
3 | * Copyright (C) 2014, Red Hat, Inc. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | * |
18 | * Author(s): Carlos Garnacho <carlosg@gnome.org> |
19 | */ |
20 | #ifndef __GTK_EVENT_CONTROLLER_PRIVATE_H__ |
21 | #define __GTK_EVENT_CONTROLLER_PRIVATE_H__ |
22 | |
23 | #include "gtkeventcontroller.h" |
24 | |
25 | /* GdkCrossingType: |
26 | * @GTK_CROSSING_FOCUS: Focus moved from one widget to another |
27 | * @GTK_CROSSING_ACTIVE: The active window changed (the crossing |
28 | * events in this case leave from the old active window's focus |
29 | * location to the new active window's one. |
30 | * @GTK_CROSSING_POINTER: The pointer moved from one widget to another |
31 | * @GTK_CROSSING_POINTER: An active drag moved from one widget to another |
32 | * |
33 | * We emit various kinds of crossing events when the target widget |
34 | * for keyboard or pointer events changes. |
35 | */ |
36 | typedef enum { |
37 | GTK_CROSSING_FOCUS, |
38 | GTK_CROSSING_ACTIVE, |
39 | GTK_CROSSING_POINTER, |
40 | GTK_CROSSING_DROP |
41 | } GtkCrossingType; |
42 | |
43 | /* |
44 | * GdkCrossingirection: |
45 | * @GTK_CROSSING_IN: the event is on the downward slope, towards the new target |
46 | * @GTK_CROSSING_OUT: the event is on the upward slope, away from the old target |
47 | */ |
48 | typedef enum { |
49 | GTK_CROSSING_IN, |
50 | GTK_CROSSING_OUT |
51 | } GtkCrossingDirection; |
52 | |
53 | typedef struct _GtkCrossingData GtkCrossingData; |
54 | |
55 | /** |
56 | * GtkCrossingData: |
57 | * @type: the type of crossing event |
58 | * @direction: whether this is a focus-in or focus-out event |
59 | * @mode: the crossing mode |
60 | * @old_target: the old target |
61 | * @old_descendent: the direct child of the receiving widget that |
62 | * is an ancestor of @old_target, or %NULL if @old_target is not |
63 | * a descendent of the receiving widget |
64 | * @new_target: the new target |
65 | * @new_descendent: the direct child of the receiving widget that |
66 | * is an ancestor of @new_target, or %NULL if @new_target is not |
67 | * a descendent of the receiving widget |
68 | * @drop: the `GdkDrop` if this is info for a drop operation |
69 | * |
70 | * The struct that is passed to gtk_event_controller_handle_crossing(). |
71 | * |
72 | * The @old_target and @new_target fields are set to the old or new |
73 | * focus, drop or hover location. |
74 | */ |
75 | struct _GtkCrossingData { |
76 | GtkCrossingType type; |
77 | GtkCrossingDirection direction; |
78 | GdkCrossingMode mode; |
79 | GtkWidget *old_target; |
80 | GtkWidget *old_descendent; |
81 | GtkWidget *new_target; |
82 | GtkWidget *new_descendent; |
83 | GdkDrop *drop; |
84 | }; |
85 | |
86 | struct _GtkEventController |
87 | { |
88 | GObject parent_instance; |
89 | }; |
90 | |
91 | struct _GtkEventControllerClass |
92 | { |
93 | GObjectClass parent_class; |
94 | |
95 | void (* set_widget) (GtkEventController *controller, |
96 | GtkWidget *widget); |
97 | void (* unset_widget) (GtkEventController *controller); |
98 | gboolean (* handle_event) (GtkEventController *controller, |
99 | GdkEvent *event, |
100 | double x, |
101 | double y); |
102 | void (* reset) (GtkEventController *controller); |
103 | |
104 | void (* handle_crossing) (GtkEventController *controller, |
105 | const GtkCrossingData *crossing, |
106 | double x, |
107 | double y); |
108 | |
109 | /*<private>*/ |
110 | |
111 | /* Tells whether the event is filtered out, %TRUE makes |
112 | * the event unseen by the handle_event vfunc. |
113 | */ |
114 | gboolean (* filter_event) (GtkEventController *controller, |
115 | GdkEvent *event); |
116 | |
117 | gpointer padding[10]; |
118 | }; |
119 | |
120 | GtkWidget * gtk_event_controller_get_target (GtkEventController *controller); |
121 | |
122 | |
123 | gboolean gtk_event_controller_handle_event (GtkEventController *controller, |
124 | GdkEvent *event, |
125 | GtkWidget *target, |
126 | double x, |
127 | double y); |
128 | void gtk_event_controller_handle_crossing (GtkEventController *controller, |
129 | const GtkCrossingData *crossing, |
130 | double x, |
131 | double y); |
132 | |
133 | #endif /* __GTK_EVENT_CONTROLLER_PRIVATE_H__ */ |
134 | |