13
0

Forward un/map events to NSGLView

This commit is contained in:
Robin Gareus 2017-03-20 16:31:42 +01:00
parent c0828792f0
commit 60a0b8f645
4 changed files with 64 additions and 2 deletions

View File

@ -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.
*/

View File

@ -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 ();

View File

@ -472,6 +472,35 @@ CairoWidget::on_realize ()
#endif
}
void
CairoWidget::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
CairoWidget::on_unmap ()
{
Gtk::EventBox::on_unmap();
#ifdef __APPLE__
if (_nsglview) {
Gtkmm2ext::nsglview_set_visible (_nsglview, false);
}
#endif
}
void
CairoWidget::on_state_changed (Gtk::StateType)
{

View File

@ -123,6 +123,8 @@ protected:
void on_realize ();
bool on_button_press_event (GdkEventButton*);
Gdk::Color get_parent_bg ();
void on_map();
void on_unmap();
/* this is an additional virtual "on_..." method. Glibmm does not
provide a direct signal for name changes, so this acts as a proxy.