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 /** 241 * The ::device-added signal is emitted when a new input 242 * device is related to this seat. 243 * 244 * Params: 245 * device = the newly added #GdkDevice. 246 * 247 * Since: 3.20 248 */ 249 gulong addOnDeviceAdded(void delegate(Device, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 250 { 251 return Signals.connect(this, "device-added", dlg, connectFlags ^ ConnectFlags.SWAPPED); 252 } 253 254 /** 255 * The ::device-removed signal is emitted when an 256 * input device is removed (e.g. unplugged). 257 * 258 * Params: 259 * device = the just removed #GdkDevice. 260 * 261 * Since: 3.20 262 */ 263 gulong addOnDeviceRemoved(void delegate(Device, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 264 { 265 return Signals.connect(this, "device-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 266 } 267 268 /** 269 * The ::tool-added signal is emitted whenever a new tool 270 * is made known to the seat. The tool may later be assigned 271 * to a device (i.e. on proximity with a tablet). The device 272 * will emit the #GdkDevice::tool-changed signal accordingly. 273 * 274 * A same tool may be used by several devices. 275 * 276 * Params: 277 * tool = the new #GdkDeviceTool known to the seat 278 * 279 * Since: 3.22 280 */ 281 gulong addOnToolAdded(void delegate(DeviceTool, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 282 { 283 return Signals.connect(this, "tool-added", dlg, connectFlags ^ ConnectFlags.SWAPPED); 284 } 285 286 /** 287 * This signal is emitted whenever a tool is no longer known 288 * to this @seat. 289 * 290 * Params: 291 * tool = the just removed #GdkDeviceTool 292 * 293 * Since: 3.22 294 */ 295 gulong addOnToolRemoved(void delegate(DeviceTool, Seat) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 296 { 297 return Signals.connect(this, "tool-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 298 } 299 }