[gtkmm] Add Gdk::Seat



commit a69c46d8de893bd76f00d335c452e8f9099f1817
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Tue Dec 29 16:57:46 2015 +0100

    Add Gdk::Seat
    
    .gitignore: Add seat.[h|cc].
    gdk/gdkmm.h: Add seat.h.
    gdk/src/filelist.am: Add seat.hg.
    gdk/src/gdk_extra_objects.defs: Add GdkSeat.
    gdk/src/seat.[hg|ccg]: New files.
    tools/m4/convert_gdk.m4: Add conversions for GdkSeat and GdkSeatCapabilities.
    Bug #759806.

 .gitignore                     |    2 +
 gdk/gdkmm.h                    |    3 +-
 gdk/src/filelist.am            |    1 +
 gdk/src/gdk_extra_objects.defs |    6 +++
 gdk/src/seat.ccg               |   37 ++++++++++++++++
 gdk/src/seat.hg                |   90 ++++++++++++++++++++++++++++++++++++++++
 tools/m4/convert_gdk.m4        |    6 +++
 7 files changed, 143 insertions(+), 2 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 09837f7..5d2a5d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,6 +84,8 @@ gdk/gdkmm/rgba.cc
 gdk/gdkmm/rgba.h
 gdk/gdkmm/screen.cc
 gdk/gdkmm/screen.h
+gdk/gdkmm/seat.cc
+gdk/gdkmm/seat.h
 gdk/gdkmm/timecoord.cc
 gdk/gdkmm/timecoord.h
 gdk/gdkmm/types.cc
diff --git a/gdk/gdkmm.h b/gdk/gdkmm.h
index 6848c11..256d420 100644
--- a/gdk/gdkmm.h
+++ b/gdk/gdkmm.h
@@ -1,5 +1,3 @@
-// This is -*- C++ -*-
-
 /*
  * gdkmm.h
  *
@@ -38,6 +36,7 @@
 #include <gdkmm/displaymanager.h>
 #include <gdkmm/devicemanager.h>
 #include <gdkmm/screen.h>
+#include <gdkmm/seat.h>
 #include <gdkmm/general.h>
 
 #endif /* _GDKMM_GDKMM_H_ */
diff --git a/gdk/src/filelist.am b/gdk/src/filelist.am
index bbd5860..dc7257a 100644
--- a/gdk/src/filelist.am
+++ b/gdk/src/filelist.am
@@ -30,6 +30,7 @@ gdkmm_files_any_hg =          \
        rectangle.hg            \
        rgba.hg                 \
        screen.hg               \
+       seat.hg         \
        timecoord.hg            \
        types.hg                \
        visual.hg               \
diff --git a/gdk/src/gdk_extra_objects.defs b/gdk/src/gdk_extra_objects.defs
index 0b19968..4cff431 100644
--- a/gdk/src/gdk_extra_objects.defs
+++ b/gdk/src/gdk_extra_objects.defs
@@ -106,6 +106,12 @@
   (gtype-id "GDK_TYPE_SCREEN")
 )
 
+(define-object Seat
+  (in-module "Gdk")
+  (c-name "GdkSeat")
+  (gtype-id "GDK_TYPE_SEAT")
+)
+
 (define-object Visual
   (in-module "Gdk")
   (c-name "GdkVisual")
diff --git a/gdk/src/seat.ccg b/gdk/src/seat.ccg
new file mode 100644
index 0000000..7bea554
--- /dev/null
+++ b/gdk/src/seat.ccg
@@ -0,0 +1,37 @@
+/* Copyright (C) 2015 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gdkmm/display.h>
+#include <gdkmm/window.h>
+
+namespace
+{
+
+void Seat_grab_callback(GdkSeat*, GdkWindow* window, gpointer user_data)
+{
+  auto slot = static_cast<Gdk::Seat::SlotGrabPrepare*>(user_data);
+
+  try
+  {
+    (*slot)(Glib::wrap(window, true));
+  }
+  catch(...)
+  {
+     Glib::exception_handlers_invoke();
+  }
+}
+
+} // anonymous namespace
diff --git a/gdk/src/seat.hg b/gdk/src/seat.hg
new file mode 100644
index 0000000..056dcd0
--- /dev/null
+++ b/gdk/src/seat.hg
@@ -0,0 +1,90 @@
+/* Copyright (C) 2015 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <vector>
+#include <glibmm/object.h>
+#include <gdkmm/cursor.h>
+#include <gdkmm/device.h>
+
+_DEFS(gdkmm,gdk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gdk
+{
+_WRAP_ENUM(SeatCapabilities, GdkSeatCapabilities)
+
+class Display;
+class Window;
+
+/** A Gdk::Seat object represents a collection of input devices that belong to a user.
+ *
+ * @newin{3,20}
+ */
+class Seat : public Glib::Object
+{
+  _CLASS_GOBJECT(Seat, GdkSeat, GDK_SEAT, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT()
+
+public:
+  /** For instance,<br>
+   *   void on_grab_prepare(const Glib::RefPtr<Gdk::Window>& window);
+   *
+   * Type of the callback used to set up @a window so it can be
+   * grabbed. A typical action would be ensuring the window is
+   * visible, although there's room for other initialization actions.
+   *
+   * @param window The Gdk::Window being grabbed.
+   *
+   * @newin{3,20}
+   */
+  typedef sigc::slot<void, const Glib::RefPtr<Window>&> SlotGrabPrepare;
+
+  _WRAP_METHOD(GrabStatus grab(const Glib::RefPtr<Window>& window,
+               SeatCapabilities capabilities,
+               bool owner_events,
+               const Glib::RefPtr<Cursor>& cursor = Glib::RefPtr<Cursor>(),
+               const GdkEvent* event = nullptr,
+               const SlotGrabPrepare& slot = SlotGrabPrepare()),
+               gdk_seat_grab, slot_name slot, slot_callback Seat_grab_callback, no_slot_copy)
+
+  _WRAP_METHOD(void ungrab(), gdk_seat_ungrab)
+  _WRAP_METHOD(Glib::RefPtr<Display> get_display(), gdk_seat_get_display, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Display> get_display() const, gdk_seat_get_display, refreturn, 
constversion)
+  _WRAP_METHOD(SeatCapabilities get_capabilities() const, gdk_seat_get_capabilities)
+
+//TODO: Wrap gdk_seat_get_slaves() when we can be sure that it's intended to return
+// a list of GdkDevice's. https://bugzilla.gnome.org/show_bug.cgi?id=759785
+//#m4 
_CONVERSION(`GList*',`std::vector<Glib::RefPtr<Device>>',`Glib::ListHandler<Glib::RefPtr<Device>>::list_to_vector($3,
 Glib::OWNERSHIP_SHALLOW)')
+//  _WRAP_METHOD(std::vector<Glib::RefPtr<Device>> get_slaves(SeatCapabilities capabilities), 
gdk_seat_get_slaves)
+//#m4 _CONVERSION(`GList*',`std::vector<Glib::RefPtr<const Device>>',`Glib::ListHandler<Glib::RefPtr<const 
Device>>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
+//  _WRAP_METHOD(std::vector<Glib::RefPtr<const Device>> get_slaves(SeatCapabilities capabilities) const, 
gdk_seat_get_slaves)
+
+  _WRAP_METHOD(Glib::RefPtr<Device> get_pointer(), gdk_seat_get_pointer, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Device> get_pointer() const, gdk_seat_get_pointer, refreturn, constversion)
+  _WRAP_METHOD(Glib::RefPtr<Device> get_keyboard(), gdk_seat_get_keyboard, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Device> get_keyboard() const, gdk_seat_get_keyboard, refreturn, 
constversion)
+
+  // We use no_default_handler because GdkSeatClass is private.
+#m4 _CONVERSION(`GdkDevice*',`const Glib::RefPtr<Device>&', Glib::wrap($3, true))
+  _WRAP_SIGNAL(void device_added(const Glib::RefPtr<Device>& device), "device-added", no_default_handler)
+  _WRAP_SIGNAL(void device_removed(const Glib::RefPtr<Device>& device), "device-removed", no_default_handler)
+
+  _WRAP_PROPERTY("display", Glib::RefPtr<Display>)
+};
+
+} // namespace Gdk
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index f1f35ba..d982889 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -55,6 +55,7 @@ _CONV_ENUM(Gdk,ModifierIntent)
 _CONV_ENUM(Gdk,OverlapType)
 _CONV_ENUM(Gdk,PixbufAlphaMode)
 _CONV_ENUM(Gdk,RgbDither)
+_CONV_ENUM(Gdk,SeatCapabilities)
 _CONV_ENUM(Gdk,Status)
 _CONV_ENUM(Gdk,SubwindowMode)
 _CONV_ENUM(Gdk,VisualType)
@@ -233,6 +234,11 @@ _CONVERSION(`GdkDevice*',`Glib::RefPtr<Gdk::Device>', `Glib::wrap($3)')
 _CONVERSION(`GdkDevice*',`Glib::RefPtr<const Device>', `Glib::wrap($3)')
 _CONVERSION(`GdkDevice*',`Glib::RefPtr<const Gdk::Device>', `Glib::wrap($3)')
 
+_CONVERSION(`GdkSeat*',`Glib::RefPtr<Seat>', `Glib::wrap($3)')
+_CONVERSION(`GdkSeat*',`Glib::RefPtr<Gdk::Seat>', `Glib::wrap($3)')
+_CONVERSION(`GdkSeat*',`Glib::RefPtr<const Seat>', `Glib::wrap($3)')
+_CONVERSION(`GdkSeat*',`Glib::RefPtr<const Gdk::Seat>', `Glib::wrap($3)')
+
 _CONVERSION(`GdkDeviceManager*',`Glib::RefPtr<DeviceManager>', `Glib::wrap($3)')
 _CONVERSION(`GdkDeviceManager*',`Glib::RefPtr<const DeviceManager>', `Glib::wrap($3)')
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]