コード例 #1
0
ファイル: GtkWindow.cs プロジェクト: wnf0000/Eto
            public void HandleWindowStateEvent(object o, Gtk.WindowStateEventArgs args)
            {
                var handler = Handler;

                if (handler == null)
                {
                    return;
                }
                var windowState = handler.WindowState;

                if (windowState == WindowState.Normal)
                {
                    if (args.Event.ChangedMask.HasFlag(Gdk.WindowState.Maximized) && !args.Event.NewWindowState.HasFlag(Gdk.WindowState.Maximized))
                    {
                        handler.restoreBounds = handler.Widget.Bounds;
                    }
                    else if (args.Event.ChangedMask.HasFlag(Gdk.WindowState.Iconified) && !args.Event.NewWindowState.HasFlag(Gdk.WindowState.Iconified))
                    {
                        handler.restoreBounds = handler.Widget.Bounds;
                    }
                    else if (args.Event.ChangedMask.HasFlag(Gdk.WindowState.Fullscreen) && !args.Event.NewWindowState.HasFlag(Gdk.WindowState.Fullscreen))
                    {
                        handler.restoreBounds = handler.Widget.Bounds;
                    }
                }

                if (windowState != OldState)
                {
                    OldState = windowState;
                    Handler.Callback.OnWindowStateChanged(Handler.Widget, EventArgs.Empty);
                }
            }
コード例 #2
0
        private static void HandleMainWindowStateChanged(object o, Gtk.WindowStateEventArgs args)
        {
            var window      = o as Gtk.Window;
            var windowState = args.Event.NewWindowState & SupportedRestoreStates;

            window.Data[Properties.Settings.WindowStateSettingName] = windowState;
        }
コード例 #3
0
ファイル: GtkWindow.cs プロジェクト: sami1971/Eto
            public void HandleWindowStateEvent(object o, Gtk.WindowStateEventArgs args)
            {
                var handler     = Handler;
                var windowState = handler.WindowState;

                if (windowState == WindowState.Normal)
                {
                    if ((args.Event.ChangedMask & Gdk.WindowState.Maximized) != 0 && (args.Event.NewWindowState & Gdk.WindowState.Maximized) != 0)
                    {
                        handler.restoreBounds = handler.Widget.Bounds;
                    }
                    else if ((args.Event.ChangedMask & Gdk.WindowState.Iconified) != 0 && (args.Event.NewWindowState & Gdk.WindowState.Iconified) != 0)
                    {
                        handler.restoreBounds = handler.Widget.Bounds;
                    }
                    else if ((args.Event.ChangedMask & Gdk.WindowState.Fullscreen) != 0 && (args.Event.NewWindowState & Gdk.WindowState.Fullscreen) != 0)
                    {
                        handler.restoreBounds = handler.Widget.Bounds;
                    }
                }

                if (windowState != OldState)
                {
                    OldState = windowState;
                    Handler.Widget.OnWindowStateChanged(EventArgs.Empty);
                }
            }
 void HandleWindowStateEvent(object o, Gtk.WindowStateEventArgs args)
 {
     if (args.Event.ChangedMask == Gdk.WindowState.Iconified)
     {
         if ((args.Event.NewWindowState & Gdk.WindowState.Iconified) == Gdk.WindowState.Iconified)
         {
             args.Event.Window.Deiconify();
         }
     }
 }
コード例 #5
0
        protected virtual void OnWindowStateEvent(object sender, Gtk.WindowStateEventArgs e)
        {
            Trace.Call(sender, e);

            try {
                // handle minimize / un-minimize
                if ((e.Event.ChangedMask & Gdk.WindowState.Iconified) != 0)
                {
                    IsMinimized = (e.Event.NewWindowState & Gdk.WindowState.Iconified) != 0;
#if LOG4NET
                    f_Logger.Debug("OnWindowStateEvent(): IsMinimized: " + IsMinimized);
#endif
                    #if DISABLED
                    // BUG: metacity is not allowing us to use the minimize state
                    // to hide and enable the notfication area icon as switching
                    // to a different workspace sets WindowState.Iconified on all
                    // windows, thus this code is disabled. For more details see:
                    // http://projects.qnetp.net/issues/show/158
                    Hide();
                    #endif
                    if (IsMinimized)
                    {
                        if (Minimized != null)
                        {
                            Minimized(this, EventArgs.Empty);
                        }
                    }
                    else
                    {
                        if (Unminimized != null)
                        {
                            Unminimized(this, EventArgs.Empty);
                        }
                    }
                }

                // handle maximize / un-maximize
                if ((e.Event.ChangedMask & Gdk.WindowState.Maximized) != 0)
                {
                    IsMaximized = (e.Event.NewWindowState & Gdk.WindowState.Maximized) != 0;
#if LOG4NET
                    f_Logger.Debug("OnWindowStateEvent(): IsMaximized: " + IsMaximized);
#endif
                    GLib.Idle.Add(() => {
                        CheckLayout();
                        return(false);
                    });
                }
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }
        void HandleWindowStateEvent(object o, Gtk.WindowStateEventArgs args)
        {
            if (args.Event.ChangedMask == Gdk.WindowState.Maximized)
            {
                Gtk.Window wndMax = (Gtk.Window)o;

                Gdk.Rectangle displayRect = wndMax.GdkWindow.FrameExtents;
                wndMax.Hide();

                if (displayRect.Width == 200)
                {
                    int w, h;
                    wndMax.GetSize(out w, out h);
                    System.Threading.Thread.Sleep(0);
                    Gtk.Application.RunIteration();
                    displayRect = wndMax.GdkWindow.FrameExtents;
                }

                Gdk.Rectangle windowRect = Screen.GetMonitorGeometry(Screen.GetMonitorAtPoint(wndMax.Allocation.X, wndMax.Allocation.Y));

                if (displayRect.Width == 200)
                {
                    displayRect.Location = Gdk.Point.Zero;
                    displayRect.Width    = windowRect.Width;
                    displayRect.Height   = windowRect.Height - 32;
                }

                int xLoc = windowRect.Right - BackgroundBitmap.Width - 1;
                int yLoc = windowRect.Bottom - BackgroundBitmap.Height - 1;
                if (displayRect.Right < windowRect.Right)
                {
                    xLoc = displayRect.Right - BackgroundBitmap.Width - 1;
                }
                else if (displayRect.Left > windowRect.Left)
                {
                    xLoc = displayRect.Left + 1;
                }
                if (displayRect.Top > windowRect.Top)
                {
                    yLoc = displayRect.Top + 1;
                }
                else if (displayRect.Bottom < windowRect.Bottom)
                {
                    yLoc = displayRect.Bottom - BackgroundBitmap.Height - 1;
                }

                switch (taskbarState)
                {
                case TaskbarStates.hidden:
                    if (timer != 0)
                    {
                        GLib.Source.Remove(timer);
                        timer = 0;
                    }
                    taskbarState       = TaskbarStates.appearing;
                    Opacity            = 0;
                    this.WidthRequest  = BackgroundBitmap.Width;
                    this.HeightRequest = BackgroundBitmap.Height;
                    this.Move(xLoc, yLoc);
                    timer = GLib.Timeout.Add(nShowEvents, OnTimer);
                    ShowAll();
                    Refresh(true);
                    break;

                case TaskbarStates.appearing:
                    Refresh(true);
                    break;

                case TaskbarStates.visible:
                    if (timer != 0)
                    {
                        GLib.Source.Remove(timer);
                        timer = 0;
                    }
                    if (nVisibleEvents > 0)
                    {
                        timer = GLib.Timeout.Add(nVisibleEvents, OnTimer);
                    }
                    Refresh(true);
                    break;

                case TaskbarStates.disappearing:
                    if (timer != 0)
                    {
                        GLib.Source.Remove(timer);
                        timer = 0;
                    }
                    taskbarState       = TaskbarStates.visible;
                    Opacity            = 1;
                    this.WidthRequest  = BackgroundBitmap.Width;
                    this.HeightRequest = BackgroundBitmap.Height;
                    this.Move(xLoc, yLoc);
                    if (nVisibleEvents > 0)
                    {
                        timer = GLib.Timeout.Add(nVisibleEvents, OnTimer);
                    }
                    Refresh(true);
                    break;
                }
            }
        }