1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  In addition to a single pointer and keyboard for user interface input, GDK 
  26. --  contains support for a variety of input devices, including graphics 
  27. --  tablets, touchscreens and multiple pointers/keyboards interacting 
  28. --  simultaneously with the user interface. Such input devices often have 
  29. --  additional features, such as sub-pixel positioning information and 
  30. --  additional device-dependent information. 
  31. -- 
  32. --  In order to query the device hierarchy and be aware of changes in the 
  33. --  device hierarchy (such as virtual devices being created or removed, or 
  34. --  physical devices being plugged or unplugged), GDK provides 
  35. --  Gdk.Device_Manager.Gdk_Device_Manager. 
  36. -- 
  37. --  By default, and if the platform supports it, GDK is aware of multiple 
  38. --  keyboard/pointer pairs and multitouch devices. This behavior can be changed 
  39. --  by calling gdk_disable_multidevice before Gdk.Display.Open. There should 
  40. --  rarely be a need to do that though, since GDK defaults to a compatibility 
  41. --  mode in which it will emit just one enter/leave event pair for all devices 
  42. --  on a window. To enable per-device enter/leave events and other 
  43. --  multi-pointer interaction features, Gdk.Window.Set_Support_Multidevice must 
  44. --  be called on Gdk_Windows (or Gtk.Widget.Set_Support_Multidevice on 
  45. --  widgets). window. See the Gdk.Window.Set_Support_Multidevice documentation 
  46. --  for more information. 
  47. -- 
  48. --  On X11, multi-device support is implemented through XInput 2. Unless 
  49. --  gdk_disable_multidevice is called, the XInput 2 
  50. --  Gdk.Device_Manager.Gdk_Device_Manager implementation will be used as the 
  51. --  input source. Otherwise either the core or XInput 1 implementations will be 
  52. --  used. 
  53. -- 
  54. --  For simple applications that don't have any special interest in input 
  55. --  devices, the so-called 'client pointer' provides a reasonable approximation 
  56. --  to a simple setup with a single pointer and keyboard. The device that has 
  57. --  been set as the client pointer can be accessed via 
  58. --  Gdk.Device_Manager.Get_Client_Pointer. 
  59. -- 
  60. --  Conceptually, in multidevice mode there are 2 device types. Virtual 
  61. --  devices (or master devices) are represented by the pointer cursors and 
  62. --  keyboard foci that are seen on the screen. Physical devices (or slave 
  63. --  devices) represent the hardware that is controlling the virtual devices, 
  64. --  and thus have no visible cursor on the screen. 
  65. -- 
  66. --  Virtual devices are always paired, so there is a keyboard device for every 
  67. --  pointer device. Associations between devices may be inspected through 
  68. --  Gdk.Device.Get_Associated_Device. 
  69. -- 
  70. --  There may be several virtual devices, and several physical devices could 
  71. --  be controlling each of these virtual devices. Physical devices may also be 
  72. --  "floating", which means they are not attached to any virtual device. 
  73. -- 
  74. --  == Master and slave devices == 
  75. -- 
  76. --  <screen> carlosSacarino:~$ xinput list Virtual core pointer id=2 [master 
  77. --  pointer (3)] - Virtual core XTEST pointer id=4 [slave pointer (2)] - Wacom 
  78. --  ISDv4 E6 Pen stylus id=10 [slave pointer (2)] - Wacom ISDv4 E6 Finger touch 
  79. --  id=11 [slave pointer (2)] - SynPS/2 Synaptics TouchPad id=13 [slave pointer 
  80. --  (2)] - TPPS/2 IBM TrackPoint id=14 [slave pointer (2)] - Wacom ISDv4 E6 Pen 
  81. --  eraser id=16 [slave pointer (2)] 
  82. --  Virtual core keyboard id=3 [master keyboard (2)] - Virtual core XTEST 
  83. --  keyboard id=5 [slave keyboard (3)] - Power button id=6 [slave keyboard (3)] 
  84. --  - Video bus id=7 [slave keyboard (3)] - Sleep button id=8 [slave keyboard 
  85. --  (3)] - Integrated Camera id=9 [slave keyboard (3)] - AT Translated Set 2 
  86. --  keyboard id=12 [slave keyboard (3)] - Thinkpad Extra Buttons id=15 [slave 
  87. --  keyboard (3)] </screen> 
  88. -- 
  89. --  By default, GDK will automatically listen for events coming from all 
  90. --  master devices, setting the Gdk.Device.Gdk_Device for all events coming 
  91. --  from input devices. Events containing device information are 
  92. --  GDK_MOTION_NOTIFY, GDK_BUTTON_PRESS, GDK_2_BUTTON_PRESS, 
  93. --  GDK_3_BUTTON_PRESS, GDK_BUTTON_RELEASE, GDK_SCROLL, GDK_KEY_PRESS, 
  94. --  GDK_KEY_RELEASE, GDK_ENTER_NOTIFY, GDK_LEAVE_NOTIFY, GDK_FOCUS_CHANGE, 
  95. --  GDK_PROXIMITY_IN, GDK_PROXIMITY_OUT, GDK_DRAG_ENTER, GDK_DRAG_LEAVE, 
  96. --  GDK_DRAG_MOTION, GDK_DRAG_STATUS, GDK_DROP_START, GDK_DROP_FINISHED and 
  97. --  GDK_GRAB_BROKEN. When dealing with an event on a master device, it is 
  98. --  possible to get the source (slave) device that the event originated from 
  99. --  via gdk_event_get_source_device. 
  100. -- 
  101. --  In order to listen for events coming from devices other than a virtual 
  102. --  device, Gdk.Window.Set_Device_Events must be called. Generally, this 
  103. --  function can be used to modify the event mask for any given device. 
  104. -- 
  105. --  Input devices may also provide additional information besides X/Y. For 
  106. --  example, graphics tablets may also provide pressure and X/Y tilt 
  107. --  information. This information is device-dependent, and may be queried 
  108. --  through gdk_device_get_axis. In multidevice mode, virtual devices will 
  109. --  change axes in order to always represent the physical device that is 
  110. --  routing events through it. Whenever the physical device changes, the 
  111. --  Gdk.Device.Gdk_Device:n-axes property will be notified, and 
  112. --  gdk_device_list_axes will return the new device axes. 
  113. -- 
  114. --  Devices may also have associated 'keys' or macro buttons. Such keys can be 
  115. --  globally set to map into normal X keyboard events. The mapping is set using 
  116. --  Gdk.Device.Set_Key. 
  117. -- 
  118. --  </description> 
  119. pragma Ada_2005; 
  120.  
  121. pragma Warnings (Off, "*is already use-visible*"); 
  122. with Gdk.Device;      use Gdk.Device; 
  123. with Gdk.Display;     use Gdk.Display; 
  124. with Glib;            use Glib; 
  125. with Glib.Object;     use Glib.Object; 
  126. with Glib.Properties; use Glib.Properties; 
  127.  
  128. package Gdk.Device_Manager is 
  129.  
  130.    type Gdk_Device_Manager_Record is new GObject_Record with null record; 
  131.    type Gdk_Device_Manager is access all Gdk_Device_Manager_Record'Class; 
  132.  
  133.    ------------------ 
  134.    -- Constructors -- 
  135.    ------------------ 
  136.  
  137.    function Get_Type return Glib.GType; 
  138.    pragma Import (C, Get_Type, "gdk_device_manager_get_type"); 
  139.  
  140.    ------------- 
  141.    -- Methods -- 
  142.    ------------- 
  143.  
  144.    function Get_Client_Pointer 
  145.       (Self : not null access Gdk_Device_Manager_Record) 
  146.        return Gdk.Device.Gdk_Device; 
  147.    --  Returns the client pointer, that is, the master pointer that acts as 
  148.    --  the core pointer for this application. In X11, window managers may 
  149.    --  change this depending on the interaction pattern under the presence of 
  150.    --  several pointers. 
  151.    --  You should use this function sheldomly, only in code that isn't 
  152.    --  triggered by a Gdk.Event.Gdk_Event and there aren't other means to get a 
  153.    --  meaningful Gdk.Device.Gdk_Device to operate on. 
  154.    --  Since: gtk+ 3.0 
  155.  
  156.    function Get_Display 
  157.       (Self : not null access Gdk_Device_Manager_Record) 
  158.        return Gdk.Display.Gdk_Display; 
  159.    --  Gets the Gdk.Display.Gdk_Display associated to Device_Manager. 
  160.    --  Since: gtk+ 3.0 
  161.  
  162.    function List_Devices 
  163.       (Self     : not null access Gdk_Device_Manager_Record; 
  164.        The_Type : Gdk.Device.Gdk_Device_Type) 
  165.        return Gdk.Device.Device_List.Glist; 
  166.    --  Returns the list of devices of type Type currently attached to 
  167.    --  Device_Manager. 
  168.    --  Since: gtk+ 3.0 
  169.    --  "type": device type to get. 
  170.  
  171.    ---------------------- 
  172.    -- GtkAda additions -- 
  173.    ---------------------- 
  174.  
  175.    function Get_Device_Manager 
  176.      (Self : not null access Gdk.Display.Gdk_Display_Record'Class) 
  177.    return Gdk.Device_Manager.Gdk_Device_Manager; 
  178.    --  Returns the Gdk.Device_Manager.Gdk_Device_Manager associated to 
  179.    --  Display. 
  180.    --  Since: gtk+ 3.0 
  181.  
  182.    ---------------- 
  183.    -- Properties -- 
  184.    ---------------- 
  185.    --  The following properties are defined for this widget. See 
  186.    --  Glib.Properties for more information on properties) 
  187.  
  188.    Display_Property : constant Glib.Properties.Property_Boxed; 
  189.    --  Type: Display 
  190.  
  191.    ------------- 
  192.    -- Signals -- 
  193.    ------------- 
  194.  
  195.    Signal_Device_Added : constant Glib.Signal_Name := "device-added"; 
  196.    --  The ::device-added signal is emitted either when a new master pointer 
  197.    --  is created, or when a slave (Hardware) input device is plugged in. 
  198.    --    procedure Handler 
  199.    --       (Self   : access Gdk_Device_Manager_Record'Class; 
  200.    --        Device : Device) 
  201.  
  202.    Signal_Device_Changed : constant Glib.Signal_Name := "device-changed"; 
  203.    --  The ::device-changed signal is emitted whenever a device has changed in 
  204.    --  the hierarchy, either slave devices being disconnected from their master 
  205.    --  device or connected to another one, or master devices being added or 
  206.    --  removed a slave device. 
  207.    -- 
  208.    --  If a slave device is detached from all master devices 
  209.    --  (gdk_device_get_associated_device returns null), its 
  210.    --  Gdk.Device.Gdk_Device_Type will change to 
  211.    --  Gdk.Device.Gdk_Device_Type_Floating, if it's attached, it will change to 
  212.    --  Gdk.Device.Gdk_Device_Type_Slave. 
  213.    --    procedure Handler 
  214.    --       (Self   : access Gdk_Device_Manager_Record'Class; 
  215.    --        Device : Device) 
  216.  
  217.    Signal_Device_Removed : constant Glib.Signal_Name := "device-removed"; 
  218.    --  The ::device-removed signal is emitted either when a master pointer is 
  219.    --  removed, or when a slave (Hardware) input device is unplugged. 
  220.    --    procedure Handler 
  221.    --       (Self   : access Gdk_Device_Manager_Record'Class; 
  222.    --        Device : Device) 
  223.  
  224. private 
  225.    Display_Property : constant Glib.Properties.Property_Boxed := 
  226.      Glib.Properties.Build ("display"); 
  227. end Gdk.Device_Manager;