1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gdk.Seat;
26 
27 private import gdk.Cursor;
28 private import gdk.Device;
29 private import gdk.DeviceTool;
30 private import gdk.Display;
31 private import gdk.Event;
32 private import gdk.Window;
33 private import glib.ListG;
34 private import gobject.ObjectG;
35 private import gobject.Signals;
36 private import gtkc.gdk;
37 public  import gtkc.gdktypes;
38 
39 
40 /**
41  * The #GdkSeat object represents a collection of input devices
42  * that belong to a user.
43  */
44 public class Seat : ObjectG
45 {
46 	/** the main Gtk struct */
47 	protected GdkSeat* gdkSeat;
48 
49 	/** Get the main Gtk struct */
50 	public GdkSeat* getSeatStruct()
51 	{
52 		return gdkSeat;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)gdkSeat;
59 	}
60 
61 	protected override void setStruct(GObject* obj)
62 	{
63 		gdkSeat = cast(GdkSeat*)obj;
64 		super.setStruct(obj);
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (GdkSeat* gdkSeat, bool ownedRef = false)
71 	{
72 		this.gdkSeat = gdkSeat;
73 		super(cast(GObject*)gdkSeat, ownedRef);
74 	}
75 
76 
77 	/** */
78 	public static GType getType()
79 	{
80 		return gdk_seat_get_type();
81 	}
82 
83 	/**
84 	 * Returns the capabilities this #GdkSeat currently has.
85 	 *
86 	 * Return: the seat capabilities
87 	 *
88 	 * Since: 3.20
89 	 */
90 	public GdkSeatCapabilities getCapabilities()
91 	{
92 		return gdk_seat_get_capabilities(gdkSeat);
93 	}
94 
95 	/**
96 	 * Returns the #GdkDisplay this seat belongs to.
97 	 *
98 	 * Return: a #GdkDisplay. This object is owned by GTK+
99 	 *     and must not be freed.
100 	 */
101 	public Display getDisplay()
102 	{
103 		auto p = gdk_seat_get_display(gdkSeat);
104 		
105 		if(p is null)
106 		{
107 			return null;
108 		}
109 		
110 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p);
111 	}
112 
113 	/**
114 	 * Returns the master device that routes keyboard events.
115 	 *
116 	 * Return: a master #GdkDevice with keyboard
117 	 *     capabilities. This object is owned by GTK+ and must not be freed.
118 	 *
119 	 * Since: 3.20
120 	 */
121 	public Device getKeyboard()
122 	{
123 		auto p = gdk_seat_get_keyboard(gdkSeat);
124 		
125 		if(p is null)
126 		{
127 			return null;
128 		}
129 		
130 		return ObjectG.getDObject!(Device)(cast(GdkDevice*) p);
131 	}
132 
133 	/**
134 	 * Returns the master device that routes pointer events.
135 	 *
136 	 * Return: a master #GdkDevice with pointer
137 	 *     capabilities. This object is owned by GTK+ and must not be freed.
138 	 *
139 	 * Since: 3.20
140 	 */
141 	public Device getPointer()
142 	{
143 		auto p = gdk_seat_get_pointer(gdkSeat);
144 		
145 		if(p is null)
146 		{
147 			return null;
148 		}
149 		
150 		return ObjectG.getDObject!(Device)(cast(GdkDevice*) p);
151 	}
152 
153 	/**
154 	 * Returns the slave devices that match the given capabilities.
155 	 *
156 	 * Params:
157 	 *     capabilities = capabilities to get devices for
158 	 *
159 	 * Return: A list of #GdkDevices.
160 	 *     The list must be freed with g_list_free(), the elements are owned
161 	 *     by GDK and must not be freed.
162 	 *
163 	 * Since: 3.20
164 	 */
165 	public ListG getSlaves(GdkSeatCapabilities capabilities)
166 	{
167 		auto p = gdk_seat_get_slaves(gdkSeat, capabilities);
168 		
169 		if(p is null)
170 		{
171 			return null;
172 		}
173 		
174 		return new ListG(cast(GList*) p);
175 	}
176 
177 	/**
178 	 * Grabs the seat so that all events corresponding to the given @capabilities
179 	 * are passed to this application until the seat is ungrabbed with gdk_seat_ungrab(),
180 	 * or the window becomes hidden. This overrides any previous grab on the
181 	 * seat by this client.
182 	 *
183 	 * As a rule of thumb, if a grab is desired over %GDK_SEAT_CAPABILITY_POINTER,
184 	 * all other "pointing" capabilities (eg. %GDK_SEAT_CAPABILITY_TOUCH) should
185 	 * be grabbed too, so the user is able to interact with all of those while
186 	 * the grab holds, you should thus use %GDK_SEAT_CAPABILITY_ALL_POINTING most
187 	 * commonly.
188 	 *
189 	 * Grabs are used for operations which need complete control over the
190 	 * events corresponding to the given capabilities. For example in GTK+ this
191 	 * is used for Drag and Drop operations, popup menus and such.
192 	 *
193 	 * Note that if the event mask of a #GdkWindow has selected both button press
194 	 * and button release events, or touch begin and touch end, then a press event
195 	 * will cause an automatic grab until the button is released, equivalent to a
196 	 * grab on the window with @owner_events set to %TRUE. This is done because most
197 	 * applications expect to receive paired press and release events.
198 	 *
199 	 * If you set up anything at the time you take the grab that needs to be
200 	 * cleaned up when the grab ends, you should handle the #GdkEventGrabBroken
201 	 * events that are emitted when the grab ends unvoluntarily.
202 	 *
203 	 * Params:
204 	 *     window = the #GdkWindow which will own the grab
205 	 *     capabilities = capabilities that will be grabbed
206 	 *     ownerEvents = if %FALSE then all device events are reported with respect to
207 	 *         @window and are only reported if selected by @event_mask. If
208 	 *         %TRUE then pointer events for this application are reported
209 	 *         as normal, but pointer events outside this application are
210 	 *         reported with respect to @window and only if selected by
211 	 *         @event_mask. In either mode, unreported events are discarded.
212 	 *     cursor = the cursor to display while the grab is active. If
213 	 *         this is %NULL then the normal cursors are used for
214 	 *         @window and its descendants, and the cursor for @window is used
215 	 *         elsewhere.
216 	 *     event = the event that is triggering the grab, or %NULL if none
217 	 *         is available.
218 	 *     prepareFunc = function to
219 	 *         prepare the window to be grabbed, it can be %NULL if @window is
220 	 *         visible before this call.
221 	 *     prepareFuncData = user data to pass to @prepare_func
222 	 *
223 	 * Return: %GDK_GRAB_SUCCESS if the grab was successful.
224 	 *
225 	 * Since: 3.20
226 	 */
227 	public GdkGrabStatus grab(Window window, GdkSeatCapabilities capabilities, bool ownerEvents, Cursor cursor, Event event, GdkSeatGrabPrepareFunc prepareFunc, void* prepareFuncData)
228 	{
229 		return gdk_seat_grab(gdkSeat, (window is null) ? null : window.getWindowStruct(), capabilities, ownerEvents, (cursor is null) ? null : cursor.getCursorStruct(), (event is null) ? null : event.getEventStruct(), prepareFunc, prepareFuncData);
230 	}
231 
232 	/**
233 	 * Releases a grab added through gdk_seat_grab().
234 	 *
235 	 * Since: 3.20
236 	 */
237 	public void ungrab()
238 	{
239 		gdk_seat_ungrab(gdkSeat);
240 	}
241 
242 	int[string] connectedSignals;
243 
244 	void delegate(Device, Seat)[] onDeviceAddedListeners;
245 	/**
246 	 * The ::device-added signal is emitted when a new input
247 	 * device is related to this seat.
248 	 *
249 	 * Params:
250 	 *     device = the newly added #GdkDevice.
251 	 *
252 	 * Since: 3.20
253 	 */
254 	void addOnDeviceAdded(void delegate(Device, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
255 	{
256 		if ( "device-added" !in connectedSignals )
257 		{
258 			Signals.connectData(
259 				this,
260 				"device-added",
261 				cast(GCallback)&callBackDeviceAdded,
262 				cast(void*)this,
263 				null,
264 				connectFlags);
265 			connectedSignals["device-added"] = 1;
266 		}
267 		onDeviceAddedListeners ~= dlg;
268 	}
269 	extern(C) static void callBackDeviceAdded(GdkSeat* seatStruct, GdkDevice* device, Seat _seat)
270 	{
271 		foreach ( void delegate(Device, Seat) dlg; _seat.onDeviceAddedListeners )
272 		{
273 			dlg(ObjectG.getDObject!(Device)(device), _seat);
274 		}
275 	}
276 
277 	void delegate(Device, Seat)[] onDeviceRemovedListeners;
278 	/**
279 	 * The ::device-removed signal is emitted when an
280 	 * input device is removed (e.g. unplugged).
281 	 *
282 	 * Params:
283 	 *     device = the just removed #GdkDevice.
284 	 *
285 	 * Since: 3.20
286 	 */
287 	void addOnDeviceRemoved(void delegate(Device, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
288 	{
289 		if ( "device-removed" !in connectedSignals )
290 		{
291 			Signals.connectData(
292 				this,
293 				"device-removed",
294 				cast(GCallback)&callBackDeviceRemoved,
295 				cast(void*)this,
296 				null,
297 				connectFlags);
298 			connectedSignals["device-removed"] = 1;
299 		}
300 		onDeviceRemovedListeners ~= dlg;
301 	}
302 	extern(C) static void callBackDeviceRemoved(GdkSeat* seatStruct, GdkDevice* device, Seat _seat)
303 	{
304 		foreach ( void delegate(Device, Seat) dlg; _seat.onDeviceRemovedListeners )
305 		{
306 			dlg(ObjectG.getDObject!(Device)(device), _seat);
307 		}
308 	}
309 
310 	void delegate(DeviceTool, Seat)[] onToolAddedListeners;
311 	/**
312 	 * The ::tool-added signal is emitted whenever a new tool
313 	 * is made known to the seat. The tool may later be assigned
314 	 * to a device (i.e. on proximity with a tablet). The device
315 	 * will emit the #GdkDevice::tool-changed signal accordingly.
316 	 *
317 	 * A same tool may be used by several devices.
318 	 *
319 	 * Params:
320 	 *     tool = the new #GdkDeviceTool known to the seat
321 	 *
322 	 * Since: 3.22
323 	 */
324 	void addOnToolAdded(void delegate(DeviceTool, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
325 	{
326 		if ( "tool-added" !in connectedSignals )
327 		{
328 			Signals.connectData(
329 				this,
330 				"tool-added",
331 				cast(GCallback)&callBackToolAdded,
332 				cast(void*)this,
333 				null,
334 				connectFlags);
335 			connectedSignals["tool-added"] = 1;
336 		}
337 		onToolAddedListeners ~= dlg;
338 	}
339 	extern(C) static void callBackToolAdded(GdkSeat* seatStruct, GdkDeviceTool* tool, Seat _seat)
340 	{
341 		foreach ( void delegate(DeviceTool, Seat) dlg; _seat.onToolAddedListeners )
342 		{
343 			dlg(ObjectG.getDObject!(DeviceTool)(tool), _seat);
344 		}
345 	}
346 
347 	void delegate(DeviceTool, Seat)[] onToolRemovedListeners;
348 	/**
349 	 * This signal is emitted whenever a tool is no longer known
350 	 * to this @seat.
351 	 *
352 	 * Params:
353 	 *     tool = the just removed #GdkDeviceTool
354 	 *
355 	 * Since: 3.22
356 	 */
357 	void addOnToolRemoved(void delegate(DeviceTool, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
358 	{
359 		if ( "tool-removed" !in connectedSignals )
360 		{
361 			Signals.connectData(
362 				this,
363 				"tool-removed",
364 				cast(GCallback)&callBackToolRemoved,
365 				cast(void*)this,
366 				null,
367 				connectFlags);
368 			connectedSignals["tool-removed"] = 1;
369 		}
370 		onToolRemovedListeners ~= dlg;
371 	}
372 	extern(C) static void callBackToolRemoved(GdkSeat* seatStruct, GdkDeviceTool* tool, Seat _seat)
373 	{
374 		foreach ( void delegate(DeviceTool, Seat) dlg; _seat.onToolRemovedListeners )
375 		{
376 			dlg(ObjectG.getDObject!(DeviceTool)(tool), _seat);
377 		}
378 	}
379 }