/// <summary> /// The platform quit message loop. /// </summary> protected override void QuitMessageLoop() { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { GtkNativeMethods.Quit(); } else { CefRuntime.QuitMessageLoop(); } }
/// <summary> /// The get size. /// </summary> /// <param name="width"> /// The width. /// </param> /// <param name="height"> /// The height. /// </param> protected virtual void GetSize(out int width, out int height) { width = 0; height = 0; if (mMainWindow == IntPtr.Zero) { return; } GtkNativeMethods.GetWindowSize(Host, out width, out height); }
/// <summary> /// The platform run message loop. /// </summary> protected override void RunMessageLoop() { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { /* run the GTK+ main loop */ GtkNativeMethods.Run(); } else { CefRuntime.RunMessageLoop(); } }
/// <summary> /// The on browser created. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void OnBrowserCreated(object sender, EventArgs e) { mBrowserWindowHandle = mBrowser.CefBrowser.GetHost().GetWindowHandle(); if (CefRuntime.Platform == CefRuntimePlatform.Windows) { if (mBrowserWindowHandle != IntPtr.Zero) { // ReSharper disable once InlineOutVariableDeclaration int width; // ReSharper disable once InlineOutVariableDeclaration int height; GetSize(out width, out height); GtkNativeMethods.SetWindowPos(mBrowserWindowHandle, IntPtr.Zero, 0, 0, width, height); } } }
/// <summary> /// The on resize. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected override void OnResize(object sender, EventArgs e) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { if (mBrowserWindowHandle != IntPtr.Zero) { // ReSharper disable once InlineOutVariableDeclaration int width; // ReSharper disable once InlineOutVariableDeclaration int height; GetSize(out width, out height); GtkNativeMethods.SetWindowPos(mBrowserWindowHandle, IntPtr.Zero, 0, 0, width, height); } } else { base.OnResize(sender, e); } }
/// <summary> /// The create window. /// </summary> private void CreateWindow() { var wndType = mHostConfig.HostFrameless ? GtkNativeMethods.GtkWindowType.GtkWindowPopup : GtkNativeMethods.GtkWindowType.GtkWindowToplevel; mMainWindow = GtkNativeMethods.NewWindow(wndType); GtkNativeMethods.SetTitle(mMainWindow, mHostConfig.HostTitle); GtkNativeMethods.SetIconFromFile(mMainWindow, mHostConfig.HostIconFile); GtkNativeMethods.SetSizeRequest(mMainWindow, mHostConfig.HostWidth, mHostConfig.HostHeight); if (mHostConfig.HostCenterScreen) { GtkNativeMethods.SetWindowPosition(mMainWindow, GtkNativeMethods.GtkWindowPosition.GtkWinPosCenter); } switch (mHostConfig.HostState) { case WindowState.Normal: break; case WindowState.Maximize: GtkNativeMethods.SetWindowMaximize(mMainWindow); break; case WindowState.Fullscreen: GtkNativeMethods.SetFullscreen(mMainWindow); break; } GtkNativeMethods.AddConfigureEvent(mMainWindow); Realized += OnRealized; Resized += OnResize; Exited += OnExit; GtkNativeMethods.ShowAll(mMainWindow); }
/// <summary> /// The platform initialize. /// </summary> protected override void Initialize() { GtkNativeMethods.InitWindow(0, null); }
/// <summary> /// The on exit. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected virtual void OnExit(object sender, EventArgs e) { GtkNativeMethods.Quit(); }
/// <summary> /// The on resize. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected virtual void OnResize(object sender, EventArgs e) { GetSize(out var width, out var height); GtkNativeMethods.SetWindowSize(Host, width, height); }
/// <summary> /// The resize host. /// </summary> /// <param name="host"> /// The host. /// </param> /// <param name="width"> /// The width. /// </param> /// <param name="height"> /// The height. /// </param> public virtual void ResizeHost(IntPtr host, int width, int height) { GtkNativeMethods.SetWindowSize(host, width, height); }