[gtkmm] Gdk, Gtk: Update for the latest gtk4 (Root::get_for_surface(), etc.)
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gdk, Gtk: Update for the latest gtk4 (Root::get_for_surface(), etc.)
- Date: Thu, 28 Feb 2019 12:42:45 +0000 (UTC)
commit 0e815b8021df9a07fc618ece6c41a1ce1ebcd070
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Thu Feb 28 13:37:48 2019 +0100
Gdk, Gtk: Update for the latest gtk4 (Root::get_for_surface(), etc.)
demos/gtk-demo/example_change_display.cc | 18 ++++--------------
gdk/src/event.hg | 2 --
gdk/src/events.hg | 2 +-
gdk/src/surface.hg | 4 ++--
gtk/src/container.hg | 8 ++++++--
gtk/src/root.ccg | 2 ++
gtk/src/root.hg | 4 ++++
gtk/src/widget.ccg | 28 +++++-----------------------
gtk/src/widget.hg | 25 +++++++++++--------------
9 files changed, 35 insertions(+), 58 deletions(-)
---
diff --git a/demos/gtk-demo/example_change_display.cc b/demos/gtk-demo/example_change_display.cc
index 94489a57..b31bd2d1 100644
--- a/demos/gtk-demo/example_change_display.cc
+++ b/demos/gtk-demo/example_change_display.cc
@@ -328,21 +328,11 @@ Gtk::Widget* Example_ChangeDisplay::find_toplevel_at_pointer(const Glib::RefPtr<
if (!device)
return nullptr;
- auto refPointerWindow = device->get_surface_at_position();
- if (refPointerWindow)
- {
- // The user data field of a GdkWindow is used to store a pointer
- // to the widget that created it.
- gpointer user_data = nullptr;
- refPointerWindow->get_user_data(&user_data);
- GtkWidget* cWidget = static_cast<GtkWidget*>(user_data);
-
- auto pWidget = Glib::wrap(cWidget);
- if(pWidget)
- return pWidget->get_toplevel();
- }
+ auto refPointerSurface = device->get_surface_at_position();
+ if (!refPointerSurface)
+ return nullptr;
- return nullptr;
+ return Gtk::Root::get_for_surface(refPointerSurface);
}
void Example_ChangeDisplay::on_popup_button_released(int /* n_press */, double /* x */, double /* y */)
diff --git a/gdk/src/event.hg b/gdk/src/event.hg
index f080b5ed..ff87641e 100644
--- a/gdk/src/event.hg
+++ b/gdk/src/event.hg
@@ -80,8 +80,6 @@ public:
*/
_WRAP_METHOD(bool is_sent() const, gdk_event_is_sent)
- _IGNORE(gdk_event_handler_set)dnl// Usually not useful for GTK+ applications
-
_WRAP_METHOD(static void set_show_events(bool show_events = true), gdk_set_show_events)
_WRAP_METHOD(static bool get_show_events(), gdk_get_show_events)
diff --git a/gdk/src/events.hg b/gdk/src/events.hg
index 90327627..1649abe7 100644
--- a/gdk/src/events.hg
+++ b/gdk/src/events.hg
@@ -102,7 +102,7 @@ public:
// Belong to the base class:
_IGNORE(gdk_event_get_event_type, gdk_event_get_surface, gdk_event_is_sent,
- gdk_event_get_seat, gdk_event_handler_set, gdk_event_set_device, gdk_event_get_device,
+ gdk_event_get_seat, gdk_event_set_device, gdk_event_get_device,
gdk_event_set_source_device, gdk_event_get_source_device, gdk_event_set_display,
gdk_event_get_display)
};
diff --git a/gdk/src/surface.hg b/gdk/src/surface.hg
index 0a87a7c2..7a39169e 100644
--- a/gdk/src/surface.hg
+++ b/gdk/src/surface.hg
@@ -116,7 +116,6 @@ public:
void restack(bool above);
_WRAP_METHOD(void focus(guint32 timestamp), gdk_surface_focus)
- _WRAP_METHOD(void set_user_data(gpointer user_data), gdk_surface_set_user_data)
_WRAP_METHOD(void input_shape_combine_region(const ::Cairo::RefPtr< ::Cairo::Region>& shape_region, int
offset_x, int offset_y), gdk_surface_input_shape_combine_region)
_WRAP_METHOD(void set_child_input_shapes(), gdk_surface_set_child_input_shapes)
@@ -156,7 +155,6 @@ public:
_WRAP_METHOD(Glib::RefPtr<Cursor> get_cursor(), gdk_surface_get_cursor, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Cursor> get_cursor() const, gdk_surface_get_cursor, refreturn,
constversion)
- _WRAP_METHOD(void get_user_data(gpointer* data), gdk_surface_get_user_data)
_WRAP_METHOD(void get_geometry(int& x, int& y, int& width, int& height) const, gdk_surface_get_geometry)
_WRAP_METHOD(int get_width() const, gdk_surface_get_width)
_WRAP_METHOD(int get_height() const, gdk_surface_get_height)
@@ -308,6 +306,8 @@ public:
#m4 _CONVERSION(`CairoRegion*',`const ::Cairo::RefPtr<const ::Cairo::Region>&',`Gdk::Cairo::wrap($3)')
_WRAP_SIGNAL(bool render(const ::Cairo::RefPtr<const ::Cairo::Region>& expose_region),
"render", no_default_handler)
+#m4 _CONVERSION(`GdkEvent*',`const Glib::RefPtr<const Event>&',`Glib::wrap($3, true)')
+ _WRAP_SIGNAL(bool event(const Glib::RefPtr<const Event>& event), "event", no_default_handler)
_WRAP_PROPERTY("cursor", Glib::RefPtr<Cursor>)
_WRAP_PROPERTY("display", Glib::RefPtr<Display>)
diff --git a/gtk/src/container.hg b/gtk/src/container.hg
index cf4539f4..96e698e0 100644
--- a/gtk/src/container.hg
+++ b/gtk/src/container.hg
@@ -144,8 +144,6 @@ public:
//so that we can write special code to check for deleted child widget parameters:
_WRAP_SIGNAL(void remove(Widget* widget), "remove", custom_c_callback)
- _WRAP_SIGNAL(void set_focus_child(Widget* child), "set-focus-child")
-
protected:
_CTOR_DEFAULT()
@@ -169,6 +167,12 @@ protected:
_WRAP_VFUNC(void forall(const ForeachSlot& slot{callback}), forall,
custom_vfunc_callback, slot_name slot, slot_callback container_foreach_callback, no_slot_copy)
+ /** Sets the focused child of container.
+ *
+ * @param child The child widget.
+ */
+ _WRAP_VFUNC(void set_focus_child(Widget* child), set_focus_child)
+
/** Sets a child property for this container and its child.
*
* Child properties are object properties that are not specific to either the
diff --git a/gtk/src/root.ccg b/gtk/src/root.ccg
index 2464f638..d60302c9 100644
--- a/gtk/src/root.ccg
+++ b/gtk/src/root.ccg
@@ -16,3 +16,5 @@
#include <gtk/gtk.h>
#include <gdkmm/display.h>
+#include <gdkmm/surface.h>
+#include <gtkmm/widget.h>
diff --git a/gtk/src/root.hg b/gtk/src/root.hg
index 0f0435e1..17e2a0d6 100644
--- a/gtk/src/root.hg
+++ b/gtk/src/root.hg
@@ -30,10 +30,12 @@ typedef struct _GtkRootInterface GtkRootInterface;
namespace Gdk
{
class Display;
+class Surface;
}
namespace Gtk
{
+class Widget;
/** Root widgets.
*
@@ -52,6 +54,8 @@ class Root : public Glib::Interface
_CLASS_INTERFACE(Root, GtkRoot, GTK_ROOT, GtkRootInterface)
public:
+ _WRAP_METHOD(static Widget* get_for_surface(const Glib::RefPtr<const Gdk::Surface>& surface),
+ gtk_root_get_for_surface)
protected:
#m4 _CONVERSION(`Glib::RefPtr<Gdk::Display>', `GdkDisplay*', __CONVERT_REFPTR_TO_P)
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index ca4453c5..48f20f80 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -330,6 +330,11 @@ void Widget::realize_if_needed()
realize();
}
+void Widget::unset_focus_child()
+{
+ gtk_widget_set_focus_child(gobj(), nullptr);
+}
+
void Widget::add_modal_grab()
{
gtk_grab_add(gobj());
@@ -364,29 +369,6 @@ void Widget::drag_dest_set(DestDefaults flags, Gdk::DragAction actions)
gtk_drag_dest_set(gobj(), (GtkDestDefaults)flags, nullptr, (GdkDragAction)actions);
}
-void Widget_Class::hierarchy_changed_callback_custom(GtkWidget* self, GtkWidget* p0)
-{
- //GTKMM_LIFECYCLE
- //Don't call wrap() on a GTK+ instance whose gtkmm instance has been deleted - just call the original C
callback.
- bool gtkmm_child_already_deleted = Glib::_gobject_cppinstance_already_deleted((GObject*)p0);
-
- if(!gtkmm_child_already_deleted)
- {
- //Call the regular, generated callback:
- Widget_Class::hierarchy_changed_callback(self, p0);
- }
- else
- {
- const auto base = static_cast<BaseClassType*>(
- g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The
original underlying C class).
- );
-
- //Call the original underlying C function:
- if(base && base->hierarchy_changed)
- (*base->hierarchy_changed)(self, p0);
- }
-}
-
void Widget_Class::dispose_vfunc_callback(GObject* self)
{
//Avoid disposal. See also Window_Class::dispose_vfunc_callback().
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 3567d436..700dc5ef 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -668,8 +668,6 @@ public:
_WRAP_SIGNAL(void state_flags_changed(Gtk::StateFlags previous_state_flags), "state-flags-changed")
- _WRAP_SIGNAL(void hierarchy_changed(Widget* previous_toplevel), "hierarchy_changed")
-
_WRAP_SIGNAL(void style_updated(), "style_updated")
_WRAP_SIGNAL(void direction_changed(TextDirection direction), "direction_changed")
@@ -679,7 +677,6 @@ public:
_WRAP_SIGNAL(void child_notify(GParamSpec* pspec), "child_notify", detail_name child_property_name)
_WRAP_SIGNAL(bool mnemonic_activate(bool group_cycling), "mnemonic_activate")
- _WRAP_SIGNAL(void grab_focus(), "grab_focus")
_WRAP_SIGNAL(bool focus(DirectionType direction), "focus")
#m4begin
@@ -769,9 +766,12 @@ protected:
//comment in GTK+ header: "seldomly overidden"
_WRAP_VFUNC(void dispatch_child_properties_changed(guint, GParamSpec**),
"dispatch_child_properties_changed")
+ _WRAP_VFUNC(void root(), root)
+ _WRAP_VFUNC(void unroot(), unroot)
_WRAP_VFUNC(SizeRequestMode get_request_mode() const, get_request_mode)
_WRAP_VFUNC(void measure(Orientation orientation, int for_size, int& minimum, int& natural,
int& minimum_baseline, int& natural_baseline) const, measure, custom_vfunc_callback)
+ _WRAP_VFUNC(void grab_focus(), grab_focus)
_WRAP_VFUNC(Glib::RefPtr<Atk::Object> get_accessible(), "get_accessible", refreturn, ifdef
GTKMM_ATKMM_ENABLED)
_WRAP_VFUNC(void compute_expand(bool& hexpand_p, bool& vexpand_p), compute_expand,
@@ -811,17 +811,14 @@ protected:
void realize_if_needed();
-#m4begin
-dnl// Hook in custom hierarchy_changed callback.
-dnl// It will use the generated callback.
-dnl
- _PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
- klass->hierarchy_changed = &hierarchy_changed_callback_custom;
- _SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
- static void hierarchy_changed_callback_custom(GtkWidget* self, GtkWidget* p0);
- _POP()
-#m4end
-
+ _WRAP_METHOD(void set_focus_child(Widget& child), gtk_widget_set_focus_child)
+ /** Unsets the focus child of the widget.
+ *
+ * The previous focus child will be unset.
+ *
+ * This function is only suitable for widget implementations.
+ */
+ void unset_focus_child();
};
} // namespace Gtk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]