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 gdk.c.functions; 34 public import gdk.c.types; 35 private import glib.ListG; 36 private import gobject.ObjectG; 37 private import gobject.Signals; 38 public import gtkc.gdktypes; 39 private import std.algorithm; 40 41 42 /** 43 * The #GdkSeat object represents a collection of input devices 44 * that belong to a user. 45 */ 46 public class Seat : ObjectG 47 { 48 /** the main Gtk struct */ 49 protected GdkSeat* gdkSeat; 50 51 /** Get the main Gtk struct */ 52 public GdkSeat* getSeatStruct(bool transferOwnership = false) 53 { 54 if (transferOwnership) 55 ownedRef = false; 56 return gdkSeat; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)gdkSeat; 63 } 64 65 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (GdkSeat* gdkSeat, bool ownedRef = false) 69 { 70 this.gdkSeat = gdkSeat; 71 super(cast(GObject*)gdkSeat, ownedRef); 72 } 73 74 75 /** */ 76 public static GType getType() 77 { 78 return gdk_seat_get_type(); 79 } 80 81 /** 82 * Returns the capabilities this #GdkSeat currently has. 83 * 84 * Returns: the seat capabilities 85 * 86 * Since: 3.20 87 */ 88 public GdkSeatCapabilities getCapabilities() 89 { 90 return gdk_seat_get_capabilities(gdkSeat); 91 } 92 93 /** 94 * Returns the #GdkDisplay this seat belongs to. 95 * 96 * Returns: a #GdkDisplay. This object is owned by GTK+ 97 * and must not be freed. 98 */ 99 public Display getDisplay() 100 { 101 auto p = gdk_seat_get_display(gdkSeat); 102 103 if(p is null) 104 { 105 return null; 106 } 107 108 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 109 } 110 111 /** 112 * Returns the master device that routes keyboard events. 113 * 114 * Returns: a master #GdkDevice with keyboard 115 * capabilities. This object is owned by GTK+ and must not be freed. 116 * 117 * Since: 3.20 118 */ 119 public Device getKeyboard() 120 { 121 auto p = gdk_seat_get_keyboard(gdkSeat); 122 123 if(p is null) 124 { 125 return null; 126 } 127 128 return ObjectG.getDObject!(Device)(cast(GdkDevice*) p); 129 } 130 131 /** 132 * Returns the master device that routes pointer events. 133 * 134 * Returns: a master #GdkDevice with pointer 135 * capabilities. This object is owned by GTK+ and must not be freed. 136 * 137 * Since: 3.20 138 */ 139 public Device getPointer() 140 { 141 auto p = gdk_seat_get_pointer(gdkSeat); 142 143 if(p is null) 144 { 145 return null; 146 } 147 148 return ObjectG.getDObject!(Device)(cast(GdkDevice*) p); 149 } 150 151 /** 152 * Returns the slave devices that match the given capabilities. 153 * 154 * Params: 155 * capabilities = capabilities to get devices for 156 * 157 * Returns: A list of #GdkDevices. 158 * The list must be freed with g_list_free(), the elements are owned 159 * by GDK and must not be freed. 160 * 161 * Since: 3.20 162 */ 163 public ListG getSlaves(GdkSeatCapabilities capabilities) 164 { 165 auto p = gdk_seat_get_slaves(gdkSeat, capabilities); 166 167 if(p is null) 168 { 169 return null; 170 } 171 172 return new ListG(cast(GList*) p); 173 } 174 175 /** 176 * Grabs the seat so that all events corresponding to the given @capabilities 177 * are passed to this application until the seat is ungrabbed with gdk_seat_ungrab(), 178 * or the window becomes hidden. This overrides any previous grab on the 179 * seat by this client. 180 * 181 * As a rule of thumb, if a grab is desired over %GDK_SEAT_CAPABILITY_POINTER, 182 * all other "pointing" capabilities (eg. %GDK_SEAT_CAPABILITY_TOUCH) should 183 * be grabbed too, so the user is able to interact with all of those while 184 * the grab holds, you should thus use %GDK_SEAT_CAPABILITY_ALL_POINTING most 185 * commonly. 186 * 187 * Grabs are used for operations which need complete control over the 188 * events corresponding to the given capabilities. For example in GTK+ this 189 * is used for Drag and Drop operations, popup menus and such. 190 * 191 * Note that if the event mask of a #GdkWindow has selected both button press 192 * and button release events, or touch begin and touch end, then a press event 193 * will cause an automatic grab until the button is released, equivalent to a 194 * grab on the window with @owner_events set to %TRUE. This is done because most 195 * applications expect to receive paired press and release events. 196 * 197 * If you set up anything at the time you take the grab that needs to be 198 * cleaned up when the grab ends, you should handle the #GdkEventGrabBroken 199 * events that are emitted when the grab ends unvoluntarily. 200 * 201 * Params: 202 * window = the #GdkWindow which will own the grab 203 * capabilities = capabilities that will be grabbed 204 * ownerEvents = if %FALSE then all device events are reported with respect to 205 * @window and are only reported if selected by @event_mask. If 206 * %TRUE then pointer events for this application are reported 207 * as normal, but pointer events outside this application are 208 * reported with respect to @window and only if selected by 209 * @event_mask. In either mode, unreported events are discarded. 210 * cursor = the cursor to display while the grab is active. If 211 * this is %NULL then the normal cursors are used for 212 * @window and its descendants, and the cursor for @window is used 213 * elsewhere. 214 * event = the event that is triggering the grab, or %NULL if none 215 * is available. 216 * prepareFunc = function to 217 * prepare the window to be grabbed, it can be %NULL if @window is 218 * visible before this call. 219 * prepareFuncData = user data to pass to @prepare_func 220 * 221 * Returns: %GDK_GRAB_SUCCESS if the grab was successful. 222 * 223 * Since: 3.20 224 */ 225 public GdkGrabStatus grab(Window window, GdkSeatCapabilities capabilities, bool ownerEvents, Cursor cursor, Event event, GdkSeatGrabPrepareFunc prepareFunc, void* prepareFuncData) 226 { 227 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); 228 } 229 230 /** 231 * Releases a grab added through gdk_seat_grab(). 232 * 233 * Since: 3.20 234 */ 235 public void ungrab() 236 { 237 gdk_seat_ungrab(gdkSeat); 238 } 239 240 protected class OnDeviceAddedDelegateWrapper 241 { 242 void delegate(Device, Seat) dlg; 243 gulong handlerId; 244 245 this(void delegate(Device, Seat) dlg) 246 { 247 this.dlg = dlg; 248 onDeviceAddedListeners ~= this; 249 } 250 251 void remove(OnDeviceAddedDelegateWrapper source) 252 { 253 foreach(index, wrapper; onDeviceAddedListeners) 254 { 255 if (wrapper.handlerId == source.handlerId) 256 { 257 onDeviceAddedListeners[index] = null; 258 onDeviceAddedListeners = std.algorithm.remove(onDeviceAddedListeners, index); 259 break; 260 } 261 } 262 } 263 } 264 OnDeviceAddedDelegateWrapper[] onDeviceAddedListeners; 265 266 /** 267 * The ::device-added signal is emitted when a new input 268 * device is related to this seat. 269 * 270 * Params: 271 * device = the newly added #GdkDevice. 272 * 273 * Since: 3.20 274 */ 275 gulong addOnDeviceAdded(void delegate(Device, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 276 { 277 auto wrapper = new OnDeviceAddedDelegateWrapper(dlg); 278 wrapper.handlerId = Signals.connectData( 279 this, 280 "device-added", 281 cast(GCallback)&callBackDeviceAdded, 282 cast(void*)wrapper, 283 cast(GClosureNotify)&callBackDeviceAddedDestroy, 284 connectFlags); 285 return wrapper.handlerId; 286 } 287 288 extern(C) static void callBackDeviceAdded(GdkSeat* seatStruct, GdkDevice* device, OnDeviceAddedDelegateWrapper wrapper) 289 { 290 wrapper.dlg(ObjectG.getDObject!(Device)(device), wrapper.outer); 291 } 292 293 extern(C) static void callBackDeviceAddedDestroy(OnDeviceAddedDelegateWrapper wrapper, GClosure* closure) 294 { 295 wrapper.remove(wrapper); 296 } 297 298 protected class OnDeviceRemovedDelegateWrapper 299 { 300 void delegate(Device, Seat) dlg; 301 gulong handlerId; 302 303 this(void delegate(Device, Seat) dlg) 304 { 305 this.dlg = dlg; 306 onDeviceRemovedListeners ~= this; 307 } 308 309 void remove(OnDeviceRemovedDelegateWrapper source) 310 { 311 foreach(index, wrapper; onDeviceRemovedListeners) 312 { 313 if (wrapper.handlerId == source.handlerId) 314 { 315 onDeviceRemovedListeners[index] = null; 316 onDeviceRemovedListeners = std.algorithm.remove(onDeviceRemovedListeners, index); 317 break; 318 } 319 } 320 } 321 } 322 OnDeviceRemovedDelegateWrapper[] onDeviceRemovedListeners; 323 324 /** 325 * The ::device-removed signal is emitted when an 326 * input device is removed (e.g. unplugged). 327 * 328 * Params: 329 * device = the just removed #GdkDevice. 330 * 331 * Since: 3.20 332 */ 333 gulong addOnDeviceRemoved(void delegate(Device, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 334 { 335 auto wrapper = new OnDeviceRemovedDelegateWrapper(dlg); 336 wrapper.handlerId = Signals.connectData( 337 this, 338 "device-removed", 339 cast(GCallback)&callBackDeviceRemoved, 340 cast(void*)wrapper, 341 cast(GClosureNotify)&callBackDeviceRemovedDestroy, 342 connectFlags); 343 return wrapper.handlerId; 344 } 345 346 extern(C) static void callBackDeviceRemoved(GdkSeat* seatStruct, GdkDevice* device, OnDeviceRemovedDelegateWrapper wrapper) 347 { 348 wrapper.dlg(ObjectG.getDObject!(Device)(device), wrapper.outer); 349 } 350 351 extern(C) static void callBackDeviceRemovedDestroy(OnDeviceRemovedDelegateWrapper wrapper, GClosure* closure) 352 { 353 wrapper.remove(wrapper); 354 } 355 356 protected class OnToolAddedDelegateWrapper 357 { 358 void delegate(DeviceTool, Seat) dlg; 359 gulong handlerId; 360 361 this(void delegate(DeviceTool, Seat) dlg) 362 { 363 this.dlg = dlg; 364 onToolAddedListeners ~= this; 365 } 366 367 void remove(OnToolAddedDelegateWrapper source) 368 { 369 foreach(index, wrapper; onToolAddedListeners) 370 { 371 if (wrapper.handlerId == source.handlerId) 372 { 373 onToolAddedListeners[index] = null; 374 onToolAddedListeners = std.algorithm.remove(onToolAddedListeners, index); 375 break; 376 } 377 } 378 } 379 } 380 OnToolAddedDelegateWrapper[] onToolAddedListeners; 381 382 /** 383 * The ::tool-added signal is emitted whenever a new tool 384 * is made known to the seat. The tool may later be assigned 385 * to a device (i.e. on proximity with a tablet). The device 386 * will emit the #GdkDevice::tool-changed signal accordingly. 387 * 388 * A same tool may be used by several devices. 389 * 390 * Params: 391 * tool = the new #GdkDeviceTool known to the seat 392 * 393 * Since: 3.22 394 */ 395 gulong addOnToolAdded(void delegate(DeviceTool, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 396 { 397 auto wrapper = new OnToolAddedDelegateWrapper(dlg); 398 wrapper.handlerId = Signals.connectData( 399 this, 400 "tool-added", 401 cast(GCallback)&callBackToolAdded, 402 cast(void*)wrapper, 403 cast(GClosureNotify)&callBackToolAddedDestroy, 404 connectFlags); 405 return wrapper.handlerId; 406 } 407 408 extern(C) static void callBackToolAdded(GdkSeat* seatStruct, GdkDeviceTool* tool, OnToolAddedDelegateWrapper wrapper) 409 { 410 wrapper.dlg(ObjectG.getDObject!(DeviceTool)(tool), wrapper.outer); 411 } 412 413 extern(C) static void callBackToolAddedDestroy(OnToolAddedDelegateWrapper wrapper, GClosure* closure) 414 { 415 wrapper.remove(wrapper); 416 } 417 418 protected class OnToolRemovedDelegateWrapper 419 { 420 void delegate(DeviceTool, Seat) dlg; 421 gulong handlerId; 422 423 this(void delegate(DeviceTool, Seat) dlg) 424 { 425 this.dlg = dlg; 426 onToolRemovedListeners ~= this; 427 } 428 429 void remove(OnToolRemovedDelegateWrapper source) 430 { 431 foreach(index, wrapper; onToolRemovedListeners) 432 { 433 if (wrapper.handlerId == source.handlerId) 434 { 435 onToolRemovedListeners[index] = null; 436 onToolRemovedListeners = std.algorithm.remove(onToolRemovedListeners, index); 437 break; 438 } 439 } 440 } 441 } 442 OnToolRemovedDelegateWrapper[] onToolRemovedListeners; 443 444 /** 445 * This signal is emitted whenever a tool is no longer known 446 * to this @seat. 447 * 448 * Params: 449 * tool = the just removed #GdkDeviceTool 450 * 451 * Since: 3.22 452 */ 453 gulong addOnToolRemoved(void delegate(DeviceTool, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 454 { 455 auto wrapper = new OnToolRemovedDelegateWrapper(dlg); 456 wrapper.handlerId = Signals.connectData( 457 this, 458 "tool-removed", 459 cast(GCallback)&callBackToolRemoved, 460 cast(void*)wrapper, 461 cast(GClosureNotify)&callBackToolRemovedDestroy, 462 connectFlags); 463 return wrapper.handlerId; 464 } 465 466 extern(C) static void callBackToolRemoved(GdkSeat* seatStruct, GdkDeviceTool* tool, OnToolRemovedDelegateWrapper wrapper) 467 { 468 wrapper.dlg(ObjectG.getDObject!(DeviceTool)(tool), wrapper.outer); 469 } 470 471 extern(C) static void callBackToolRemovedDestroy(OnToolRemovedDelegateWrapper wrapper, GClosure* closure) 472 { 473 wrapper.remove(wrapper); 474 } 475 }