public void Start() { IsRenderHandler = true; _chrono.Restart(); IsActive = true; Gtk.Window parent = this.Toplevel as Gtk.Window; parent.FocusInEvent += Parent_FocusInEvent; parent.FocusOutEvent += Parent_FocusOutEvent; Gtk.Application.Invoke(delegate { parent.Present(); }); Thread renderLoopThread = new Thread(Render) { Name = "GUI.RenderLoop" }; renderLoopThread.Start(); MainLoop(); renderLoopThread.Join(); Exit(); }
public void Render() { // First take exclusivity on the OpenGL context. _renderer.InitializeBackgroundContext(GraphicsContext); Gtk.Window parent = Toplevel as Gtk.Window; parent.Present(); GraphicsContext.MakeCurrent(WindowInfo); _device.Gpu.Renderer.Initialize(_glLogLevel); // Make sure the first frame is not transparent. GL.ClearColor(OpenTK.Color.Black); GL.Clear(ClearBufferMask.ColorBufferBit); SwapBuffers(); _device.Gpu.InitializeShaderCache(); Translator.IsReadyForTranslation.Set(); while (_isActive) { if (_isStopped) { return; } _ticks += _chrono.ElapsedTicks; _chrono.Restart(); if (_device.WaitFifo()) { _device.Statistics.RecordFifoStart(); _device.ProcessFrame(); _device.Statistics.RecordFifoEnd(); } string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld"; float scale = Graphics.Gpu.GraphicsConfig.ResScale; if (scale != 1) { dockedMode += $" ({scale}x)"; } if (_ticks >= _ticksPerFrame) { _device.PresentFrame(SwapBuffers); StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( _device.EnableDeviceVsync, dockedMode, $"Game: {_device.Statistics.GetGameFrameRate():00.00} FPS", $"FIFO: {_device.Statistics.GetFifoPercent():0.00} %", $"GPU: {_renderer.GpuVendor}")); _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame); } } }
public static void PresentWindowWithNotification(this Gtk.Window window) { window.Present(); if (Platform.IsMac) { var dialog = window as Gtk.Dialog; MacRequestAttention(dialog == null? false : dialog.Modal); } }
public static void PresentWithServerTime(this Gtk.Window window) { if (window == null) { return; } var gdkWindow = window.GdkWindow; if (gdkWindow == null || !IsGdkX11Available) { window.Present(); return; } // HACK: disabled, see window.AddEvents() below /* * if ((gdkWindow.Events & Gdk.EventMask.PropertyChangeMask) == 0) { * // GDK_PROPERTY_CHANGE_MASK is not set thus we have to bail out * // else gdk_x11_get_server_time() will hang! * window.Present(); * return; * } */ // HACK: we can't obtain and check for GDK_PROPERTY_CHANGE_MASK as // gdk_window_x11_get_events() filters that mask, thus we have to // ignorantly set it using gtk_widget_add_events() else // gdk_x11_get_server_time() would hang if it wasn't set! window.AddEvents((int)Gdk.EventMask.PropertyChangeMask); try { // TODO: should we fallback to gdk_x11_display_get_user_time? var timestamp = gdk_x11_get_server_time(gdkWindow.Handle); window.PresentWithTime(timestamp); } catch (DllNotFoundException) { IsGdkX11Available = false; // no libgdk-x11 available (probably Mac OS X or Windows), thus // fallback to gtk_window_present() without a timestamp as they // don't require a timestamp to change the window focus window.Present(); } }
public void Start() { IsRenderHandler = true; _chrono.Restart(); _isActive = true; Gtk.Window parent = this.Toplevel as Gtk.Window; parent.FocusInEvent += Parent_FocusInEvent; parent.FocusOutEvent += Parent_FocusOutEvent; Gtk.Application.Invoke(delegate { parent.Present(); string titleNameSection = string.IsNullOrWhiteSpace(_device.Application.TitleName) ? string.Empty : $" - {_device.Application.TitleName}"; string titleVersionSection = string.IsNullOrWhiteSpace(_device.Application.DisplayVersion) ? string.Empty : $" v{_device.Application.DisplayVersion}"; string titleIdSection = string.IsNullOrWhiteSpace(_device.Application.TitleIdText) ? string.Empty : $" ({_device.Application.TitleIdText.ToUpper()})"; string titleArchSection = _device.Application.TitleIs64Bit ? " (64-bit)" : " (32-bit)"; parent.Title = $"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}"; }); Thread renderLoopThread = new Thread(Render) { Name = "GUI.RenderLoop" }; renderLoopThread.Start(); Thread nvStutterWorkaround = new Thread(NVStutterWorkaround) { Name = "GUI.NVStutterWorkaround" }; nvStutterWorkaround.Start(); MainLoop(); renderLoopThread.Join(); nvStutterWorkaround.Join(); Exit(); }
/// <summary> /// Grab the desktop focus for the window. /// </summary> internal virtual void GrabDesktopFocus(Gtk.Window window) { if (Platform.IsWindows && window.IsRealized) { /* On Windows calling Present() will break out of window edge snapping mode. */ window.GdkWindow.Focus(0); window.GdkWindow.Raise(); } else { window.Present(); } }
public static void PresentWindow(Gtk.Window window) { window.Present(); window.GdkWindow.Raise(); for (int i = 0; i < 100; i++) { if (TryGrabWindow(window)) { break; } Thread.Sleep(100); } }
public void Start() { IsRenderHandler = true; _chrono.Restart(); IsActive = true; Gtk.Window parent = this.Toplevel as Gtk.Window; parent.FocusInEvent += Parent_FocusInEvent; parent.FocusOutEvent += Parent_FocusOutEvent; Gtk.Application.Invoke(delegate { parent.Present(); string titleNameSection = string.IsNullOrWhiteSpace(_device.System.TitleName) ? string.Empty : $" - {_device.System.TitleName}"; string titleVersionSection = string.IsNullOrWhiteSpace(_device.System.TitleVersionString) ? string.Empty : $" v{_device.System.TitleVersionString}"; string titleIdSection = string.IsNullOrWhiteSpace(_device.System.TitleIdText) ? string.Empty : $" ({_device.System.TitleIdText.ToUpper()})"; string titleArchSection = _device.System.TitleIs64Bit ? " (64-bit)" : " (32-bit)"; parent.Title = $"PangoNX Debugger {PangoNX.Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}"; }); Thread renderLoopThread = new Thread(Render) { Name = "GUI.RenderLoop" }; renderLoopThread.Start(); MainLoop(); renderLoopThread.Join(); Exit(); }
public void Start() { IsRenderHandler = true; _chrono.Restart(); IsActive = true; Gtk.Window parent = this.Toplevel as Gtk.Window; parent.FocusInEvent += Parent_FocusInEvent; parent.FocusOutEvent += Parent_FocusOutEvent; Gtk.Application.Invoke(delegate { parent.Present(); string titleNameSection = string.IsNullOrWhiteSpace(_device.System.TitleName) ? string.Empty : " | " + _device.System.TitleName; string titleIdSection = string.IsNullOrWhiteSpace(_device.System.TitleIdText) ? string.Empty : " | " + _device.System.TitleIdText.ToUpper(); parent.Title = $"Ryujinx {Program.Version}{titleNameSection}{titleIdSection}"; }); Thread renderLoopThread = new Thread(Render) { Name = "GUI.RenderLoop" }; renderLoopThread.Start(); MainLoop(); renderLoopThread.Join(); Exit(); }
public void Present(bool giveFocus) { if (dockBarItem != null) { dockBarItem.Present(Status == DockItemStatus.AutoHide || giveFocus); } else if (floatingWindow != null) { if (giveFocus) { floatingWindow.Present(); } else { floatingWindow.Show(); } } else { frame.Present(this, Status == DockItemStatus.AutoHide || giveFocus); } }
/// <summary> /// Grab the desktop focus for the window. /// </summary> public virtual void GrabDesktopFocus(Gtk.Window window) { window.Present(); }
public override void GrabDesktopFocus(Gtk.Window window) { window.Present(); NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); }
static void GlobalSetup () { if (initedGlobal || setupFail) return; initedGlobal = true; //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate (object sender, ApplicationQuitEventArgs e) { if (!IdeApp.Exit ()) e.UserCancelled = true; e.Handled = true; }; ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify (); IdeApp.Workbench.RootWindow.Show (); // This is a workaround to a GTK+ bug. The HasTopLevelFocus flag is not properly // set when the main window is restored. The workaround is to create and quickly // destroy a top level window. GTK+ then detects that the top level focus has // changed and properly sets HasTopLevelFocus. Gtk.Window ww = new Gtk.Window (""); ww.Decorated = false; ww.SetDefaultSize (0, 0); ww.Present (); IdeApp.Workbench.RootWindow.Present (); GLib.Timeout.Add (1, delegate { // Without this small delay, GTK+ crashes when destroying the window ww.Destroy (); return false; }); e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate (object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add (10, delegate { IdeApp.OpenFiles (e.Documents.Select (doc => new FileOpenInformation (doc.Key, doc.Value, 1, OpenDocumentOptions.Default))); return false; }); e.Handled = true; }; //if not running inside an app bundle, assume usual MD build layout and load the app icon FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly ().Location; if (!exePath.ToString ().Contains ("MonoDevelop.app")) { var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; var icons = mdSrcMain.Combine ("theme-icons", "Mac", "monodevelop.icns"); if (File.Exists (icons)) NSApplication.SharedApplication.ApplicationIconImage = new NSImage (icons); } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError ("Could not install app event handlers", ex); setupFail = true; } }