Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Commit

Permalink
Fix for issue #193.
Browse files Browse the repository at this point in the history
  • Loading branch information
piloitte committed May 10, 2020
1 parent c75bde1 commit 4f9943a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/Chromely.Core/Host/IChromelyNativeHost.cs
Expand Up @@ -20,6 +20,7 @@ public interface IChromelyNativeHost
void ResizeBrowser(IntPtr browserWindow, int width, int height);
void Exit();
void MessageBox(string message, int type);
void SetWindowTitle(string title);

/// <summary> Gets the current window state Maximised / Normal / Minimised etc. </summary>
/// <returns> The window state. </returns>
Expand Down
26 changes: 13 additions & 13 deletions src/Chromely/Native/LinuxGtk3/LinuxGtk3Host.cs
Expand Up @@ -212,6 +212,19 @@ public virtual void MessageBox(string message, int type)
}
}

public virtual void SetWindowTitle(string title)
{
try
{
gtk_window_set_title(_handle, title);
}
catch (Exception exception)
{
Logger.Instance.Log.Error("Error in LinuxGtk3Host::SetWindowTitle");
Logger.Instance.Log.Error(exception);
}
}

protected virtual void SetWindowMaximize()
{
try
Expand Down Expand Up @@ -326,19 +339,6 @@ protected virtual IntPtr CreateNewWindow(int windowType)
return IntPtr.Zero;
}

protected virtual void SetWindowTitle(string title)
{
try
{
gtk_window_set_title(_handle, title);
}
catch (Exception exception)
{
Logger.Instance.Log.Error("Error in LinuxGtk3Host::SetWindowTitle");
Logger.Instance.Log.Error(exception);
}
}

protected virtual void SetWindowDefaultSize(int width, int height)
{
try
Expand Down
6 changes: 5 additions & 1 deletion src/Chromely/Native/MacCocoa/MacCocoaHost.cs
Expand Up @@ -117,6 +117,11 @@ public virtual void MessageBox(string message, int type)
throw new NotImplementedException();
}

public virtual void SetWindowTitle(string title)
{
Logger.Instance.Log.Info("MacCocoaHost::SetWindowTitle is not implemented yet!");
}

#region CreateWindow

protected virtual void RunCallback()
Expand Down Expand Up @@ -199,6 +204,5 @@ protected virtual void QuitCallback()
}

#endregion

}
}
8 changes: 8 additions & 0 deletions src/Chromely/Native/WinAPI/WinAPIHost.cs
Expand Up @@ -242,6 +242,14 @@ public virtual void MessageBox(string message, int type)
{
}

public void SetWindowTitle(string title)
{
if (_handle != IntPtr.Zero)
{
SetWindowText(_handle, title);
}
}

#region CreateWindow

private IntPtr GetIconHandle()
Expand Down
3 changes: 3 additions & 0 deletions src/Chromely/Native/WinAPI/WinNativeMethods.cs
Expand Up @@ -812,6 +812,9 @@ public enum SystemMetrics
SYSTEMDOCKED = 0x2004,
}

[DllImport(User32DLL, SetLastError = true)]
public static extern bool SetWindowText(IntPtr hwnd, String lpString);

[DllImport(User32DLL)]
public static extern int GetSystemMetrics(SystemMetrics smIndex);

Expand Down

0 comments on commit 4f9943a

Please sign in to comment.