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