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.Display; 30 private import gdk.Event; 31 private import gdk.Window; 32 private import glib.ListG; 33 private import gobject.ObjectG; 34 private import gobject.Signals; 35 private import gtkc.gdk; 36 public import gtkc.gdktypes; 37 38 39 /** 40 * The #GdkSeat object represents a collection of input devices 41 * that belong to an user. 42 */ 43 public class Seat : ObjectG 44 { 45 /** the main Gtk struct */ 46 protected GdkSeat* gdkSeat; 47 48 /** Get the main Gtk struct */ 49 public GdkSeat* getSeatStruct() 50 { 51 return gdkSeat; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected override void* getStruct() 56 { 57 return cast(void*)gdkSeat; 58 } 59 60 protected override void setStruct(GObject* obj) 61 { 62 gdkSeat = cast(GdkSeat*)obj; 63 super.setStruct(obj); 64 } 65 66 /** 67 * Sets our main struct and passes it to the parent class. 68 */ 69 public this (GdkSeat* gdkSeat, bool ownedRef = false) 70 { 71 this.gdkSeat = gdkSeat; 72 super(cast(GObject*)gdkSeat, ownedRef); 73 } 74 75 76 /** */ 77 public static GType getType() 78 { 79 return gdk_seat_get_type(); 80 } 81 82 /** 83 * Returns the capabilities this #GdkSeat currently has. 84 * 85 * Return: the seat capabilities 86 * 87 * Since: 3.20 88 */ 89 public GdkSeatCapabilities getCapabilities() 90 { 91 return gdk_seat_get_capabilities(gdkSeat); 92 } 93 94 /** 95 * Returns the #GdkDisplay this seat belongs to. 96 * 97 * Return: a #GdkDisplay. This memory is owned by GTK+ and 98 * must not be freed. 99 */ 100 public Display getDisplay() 101 { 102 auto p = gdk_seat_get_display(gdkSeat); 103 104 if(p is null) 105 { 106 return null; 107 } 108 109 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 110 } 111 112 /** 113 * Returns the master device that routes keyboard events. 114 * 115 * Return: a master #GdkDevice with keyboard 116 * capabilities. This object is owned by GTK+ and must not be 117 * 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 138 * 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 * Return: A list of #GdkDevices. The list 161 * 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 performed as most 198 * applications expect to receive presses and releases in pairs. 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 prepare the window to be 220 * grabbed, it can be %NULL if @window is 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 }