Beispiel #1
0
        internal static IDisposable ConnectEvents(WindowBaseImpl impl)
        {
            var subscription = new EventSubscription(impl.GtkWidget);
            var userData     = impl.GtkWidget.DangerousGetHandle();

            subscription.Connect <Native.D.signal_widget_draw>("draw", OnDraw, userData);
            subscription.Connect <Native.D.signal_generic>("realize", OnRealized, userData);
            subscription.Connect <Native.D.signal_generic>("destroy", OnDestroy, userData);
            subscription.Connect <Native.D.signal_generic>("show", OnShown, userData);

            subscription.ConnectEvent("configure-event", OnConfigured);
            subscription.ConnectEvent("button-press-event", OnButton);
            subscription.ConnectEvent("button-release-event", OnButton);
            subscription.ConnectEvent("motion-notify-event", OnMotion);
            subscription.ConnectEvent("scroll-event", OnScroll);
            subscription.ConnectEvent("window-state-event", OnStateChanged);
            subscription.ConnectEvent("key-press-event", OnKeyEvent);
            subscription.ConnectEvent("key-release-event", OnKeyEvent);
            subscription.ConnectEvent("leave-notify-event", OnLeaveNotifyEvent);
            subscription.ConnectEvent("delete-event", OnClosingEvent);

            if (Gtk3Platform.UseDeferredRendering)
            {
                Native.GtkWidgetSetDoubleBuffered(impl.GtkWidget, false);
                subscription.AddTickCallback(userData);
            }

            windowStack.Add(impl);

            if (!modalStack.Any())
            {
                modalStack.Add(impl);
            }
            else
            {
                var lastModal = modalStack.Last();
                if (!lastModal.GtkWidget.IsInvalid)
                {
                    Native.GtkWindowSetTransientFor(impl.GtkWidget, lastModal.GtkWidget);
                }
            }

            return(subscription);
        }