From 60a0b8f6458b15fd6f1a282010ad8d1b2aabf86a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 20 Mar 2017 16:31:42 +0100 Subject: Forward un/map events to NSGLView --- libs/canvas/canvas.cc | 29 +++++++++++++++++++++++++++++ libs/canvas/canvas/canvas.h | 6 ++++-- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'libs/canvas') diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 6ad4200cc1..9e47792758 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -1111,6 +1111,35 @@ GtkCanvas::on_leave_notify_event (GdkEventCrossing* ev) return true; } +void +GtkCanvas::on_map () +{ + Gtk::EventBox::on_map(); +#ifdef __APPLE__ + if (_nsglview) { + Gtkmm2ext::nsglview_set_visible (_nsglview, true); + Gtk::Allocation a = get_allocation(); + gint xx, yy; + gtk_widget_translate_coordinates( + GTK_WIDGET(gobj()), + GTK_WIDGET(get_toplevel()->gobj()), + 0, 0, &xx, &yy); + Gtkmm2ext::nsglview_resize (_nsglview, xx, yy, a.get_width(), a.get_height()); + } +#endif +} + +void +GtkCanvas::on_unmap () +{ + Gtk::EventBox::on_unmap(); +#ifdef __APPLE__ + if (_nsglview) { + Gtkmm2ext::nsglview_set_visible (_nsglview, false); + } +#endif +} + /** Called to request a redraw of our canvas. * @param area Area to redraw, in window coordinates. */ diff --git a/libs/canvas/canvas/canvas.h b/libs/canvas/canvas/canvas.h index 3e554cacf2..60e75bf8bf 100644 --- a/libs/canvas/canvas/canvas.h +++ b/libs/canvas/canvas/canvas.h @@ -221,8 +221,10 @@ public: bool on_button_press_event (GdkEventButton *); bool on_button_release_event (GdkEventButton* event); bool on_motion_notify_event (GdkEventMotion *); - bool on_enter_notify_event (GdkEventCrossing*); - bool on_leave_notify_event (GdkEventCrossing*); + bool on_enter_notify_event (GdkEventCrossing*); + bool on_leave_notify_event (GdkEventCrossing*); + void on_map(); + void on_unmap(); void on_realize (); -- cgit v1.2.3