Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for v3.0 #137

Merged
merged 16 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions Photino.Native.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Photino.Test", "Photino.Tes
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|Any CPU.ActiveCfg = Debug|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|Any CPU.Build.0 = Debug|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|ARM64.ActiveCfg = Debug|ARM64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|ARM64.Build.0 = Debug|ARM64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|x64.ActiveCfg = Debug|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|x64.Build.0 = Debug|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|x86.ActiveCfg = Debug|Win32
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Debug|x86.Build.0 = Debug|Win32
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|Any CPU.ActiveCfg = Release|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|Any CPU.Build.0 = Release|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|ARM64.ActiveCfg = Release|ARM64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|ARM64.Build.0 = Release|ARM64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|x64.ActiveCfg = Release|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|x64.Build.0 = Release|x64
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|x86.ActiveCfg = Release|Win32
{B326B50A-F623-40F1-92F7-1EC6A5A48DAC}.Release|x86.Build.0 = Release|Win32
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|Any CPU.Build.0 = Debug|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|ARM64.ActiveCfg = Debug|ARM64
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|ARM64.Build.0 = Debug|ARM64
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|x64.ActiveCfg = Debug|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|x64.Build.0 = Debug|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|x86.ActiveCfg = Debug|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Debug|x86.Build.0 = Debug|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Release|Any CPU.ActiveCfg = Release|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Release|Any CPU.Build.0 = Release|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Release|ARM64.ActiveCfg = Release|ARM64
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Release|ARM64.Build.0 = Release|ARM64
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Release|x64.ActiveCfg = Release|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Release|x64.Build.0 = Release|Any CPU
{056ABF92-CFED-4800-8439-ECFA5C55B029}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
101 changes: 77 additions & 24 deletions Photino.Native/Photino.Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Photino::Photino(PhotinoInitParams *initParams) : _webview(nullptr)
_mediaStreamEnabled = initParams->MediaStreamEnabled;
_smoothScrollingEnabled = initParams->SmoothScrollingEnabled;
_ignoreCertificateErrorsEnabled = initParams->IgnoreCertificateErrorsEnabled;
_isFullScreen = initParams->FullScreen;

_zoom = initParams->Zoom;
_minWidth = initParams->MinWidth;
Expand Down Expand Up @@ -242,6 +243,18 @@ Photino::Photino(PhotinoInitParams *initParams) : _webview(nullptr)
G_CALLBACK(on_widget_deleted),
this);

//if (initParams->Transparent)
//{
// GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(_window));
// GdkVisual *rgba_visual = gdk_screen_get_rgba_visual(screen);

// if (rgba_visual)
// {
// gtk_widget_set_visual(GTK_WIDGET(_window), rgba_visual);
// gtk_widget_set_app_paintable(GTK_WIDGET(_window), true);
// }
//}

Photino::Show(false);

g_signal_connect(G_OBJECT(_window), "focus-in-event",
Expand All @@ -263,6 +276,9 @@ Photino::Photino(PhotinoInitParams *initParams) : _webview(nullptr)

Photino::AddCustomSchemeHandlers();

if (initParams->Transparent)
Photino::SetTransparentEnabled(true);

if (_zoom != 100.0)
SetZoom(_zoom);

Expand All @@ -282,6 +298,24 @@ void Photino::Center()
gtk_window_get_size(GTK_WINDOW(_window), &windowWidth, &windowHeight);

GdkRectangle screen = {0};

GdkDisplay *d = gdk_display_get_default();
if (d == NULL)
{
GtkWidget *dialog = gtk_message_dialog_new(
nullptr, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "gdk_display_get_default() returned NULL");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
GdkMonitor *m = gdk_display_get_primary_monitor(d);
if (m == NULL)
{
GtkWidget *dialog = gtk_message_dialog_new(
nullptr, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "gdk_display_get_primary_monitor() returned NULL");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}

gdk_monitor_get_geometry(gdk_display_get_primary_monitor(gdk_display_get_default()), &screen);

gtk_window_move(GTK_WINDOW(_window),
Expand All @@ -301,24 +335,19 @@ void Photino::Close()

void Photino::GetTransparentEnabled(bool *enabled)
{
//! Not implemented in Linux
// if (_transparentEnabled)
// *enabled = true;
*enabled = false;
*enabled = _transparentEnabled;
}

void Photino::GetContextMenuEnabled(bool *enabled)
{
if (_contextMenuEnabled)
*enabled = true;
*enabled = _contextMenuEnabled;
}

void Photino::GetDevToolsEnabled(bool *enabled)
{
WebKitSettings *settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(_webview));
_devToolsEnabled = webkit_settings_get_enable_developer_extras(settings);
if (_devToolsEnabled)
*enabled = true;
*enabled = _devToolsEnabled;
}

void Photino::GetFullScreen(bool *fullScreen)
Expand All @@ -328,8 +357,7 @@ void Photino::GetFullScreen(bool *fullScreen)

void Photino::GetGrantBrowserPermissions(bool *grant)
{
if (_grantBrowserPermissions)
*grant = true;
*grant = _grantBrowserPermissions;
}

AutoString Photino::GetUserAgent()
Expand Down Expand Up @@ -374,7 +402,11 @@ void Photino::GetIgnoreCertificateErrorsEnabled(bool* enabled)

void Photino::GetMaximized(bool *isMaximized)
{
*isMaximized = gtk_window_is_maximized(GTK_WINDOW(_window));
//gboolean maximized = gtk_window_is_maximized(GTK_WINDOW(_window)); //this method doesn't work
//*isMaximized = maximized;
GdkWindow *gdk_window = gtk_widget_get_window(GTK_WIDGET(_window));
GdkWindowState flags = gdk_window_get_state(gdk_window);
*isMaximized = flags & GDK_WINDOW_STATE_MAXIMIZED;
}

void Photino::GetMinimized(bool *isMinimized)
Expand Down Expand Up @@ -408,14 +440,16 @@ void Photino::GetSize(int *width, int *height)
{
gtk_window_get_size(GTK_WINDOW(_window), width, height);

// TODO: Uncomment this and it works properly. Commented, it only changes width.
// TODO: When calling set height, then set width...
// calling set size works fine.
// Uncomment this and it works properly. Commented, it only changes width.
// GtkWidget* dialog = gtk_message_dialog_new(
// nullptr
// , GTK_DIALOG_DESTROY_WITH_PARENT
// , GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE
// , "width: %i bytes, height %i"
// , *width
// , *height);
// nullptr
// , GTK_DIALOG_DESTROY_WITH_PARENT
// , GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE
// , "width: %i bytes, height %i"
// , *width
// , *height);
// gtk_dialog_run(GTK_DIALOG(dialog));
// gtk_widget_destroy(dialog);
}
Expand Down Expand Up @@ -540,12 +574,6 @@ void Photino::SendWebMessage(AutoString message)
}
}

void Photino::SetTransparentEnabled(bool enabled)
{
// _transparentEnabled = enabled;
//! Not implemented in Linux
}

void Photino::SetContextMenuEnabled(bool enabled)
{
_contextMenuEnabled = enabled;
Expand Down Expand Up @@ -645,6 +673,30 @@ void Photino::SetZoom(int zoom)
webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(_webview), newZoom);
}

void Photino::SetTransparentEnabled(bool enabled)
{
_transparentEnabled = enabled;

gtk_window_set_decorated(GTK_WINDOW(_window), !enabled); //hide/show window chrome

GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(_window));
GdkVisual* rgba_visual = gdk_screen_get_rgba_visual(screen);
if (rgba_visual)
{
gtk_widget_set_visual(GTK_WIDGET(_window), rgba_visual);
gtk_widget_set_app_paintable(GTK_WIDGET(_window), true);

GdkRGBA color;
webkit_web_view_get_background_color(WEBKIT_WEB_VIEW(_webview), &color);
if (enabled)
color.alpha = 0;
else
color.alpha = 1;

webkit_web_view_set_background_color(WEBKIT_WEB_VIEW(_webview), &color);
}
}

void Photino::ShowNotification(AutoString title, AutoString message)
{
NotifyNotification *notification = notify_notification_new(title, message, nullptr);
Expand Down Expand Up @@ -1013,4 +1065,5 @@ void Photino::AddCustomSchemeHandlers()
context, value, (WebKitURISchemeRequestCallback)HandleCustomSchemeRequest, (void *)_customSchemeCallback, NULL);
}
}

#endif
6 changes: 4 additions & 2 deletions Photino.Native/Photino.Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ Photino::Photino(PhotinoInitParams* initParams)
}

if (initParams->Height > initParams->MaxHeight) initParams->Height = initParams->MaxHeight;
if (initParams->Height < initParams->MinHeight) initParams->Height = initParams->MinHeight;
if (initParams->Height < initParams->MinHeight && initParams->MinHeight > 0) initParams->Height = initParams->MinHeight;
if (initParams->Width > initParams->MaxWidth) initParams->Width = initParams->MaxWidth;
if (initParams->Width < initParams->MinWidth) initParams->Width = initParams->MinWidth;
if (initParams->Width < initParams->MinWidth && initParams->MinWidth > 0) initParams->Width = initParams->MinWidth;

//Create the window
_hWnd = CreateWindowEx(
Expand Down Expand Up @@ -492,6 +492,7 @@ void Photino::GetFullScreen(bool* fullScreen)
{
LONG lStyles = GetWindowLong(_hWnd, GWL_STYLE);
if (lStyles & WS_POPUP) *fullScreen = true;
else *fullScreen = false;
}

void Photino::GetGrantBrowserPermissions(bool* grant)
Expand Down Expand Up @@ -596,6 +597,7 @@ void Photino::GetTopmost(bool* topmost)
{
LONG lStyles = GetWindowLong(_hWnd, GWL_STYLE);
if (lStyles & WS_EX_TOPMOST) *topmost = true;
else *topmost = false;
}

void Photino::GetZoom(int* zoom)
Expand Down
2 changes: 1 addition & 1 deletion Photino.Native/Photino.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class Photino
void ClearBrowserAutoFill();
void Close();

void GetTransparentEnabled(bool* enabled);
void GetTransparentEnabled(bool *enabled);
void GetContextMenuEnabled(bool *enabled);
void GetDevToolsEnabled(bool *enabled);
void GetFullScreen(bool *fullScreen);
Expand Down
30 changes: 19 additions & 11 deletions Photino.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static void FluentStyle()
//.SetIconFile(iconFile)
//.SetTitle($"My Photino Window {_windowNumber++}")
//.SetChromeless(true)
.SetTransparent(true)
//.SetTransparent(true)
//.SetFullScreen(true)
//.SetMaximized(true)
//.SetMaxSize(640, 480)
Expand All @@ -82,9 +82,9 @@ private static void FluentStyle()
//.SetResizable(false)
//.SetTopMost(true)
//.SetUseOsDefaultLocation(false)
.SetUseOsDefaultSize(false)
//.SetUseOsDefaultSize(false)
//.Center()
.SetSize(new Size(800, 600))
//.SetSize(new Size(800, 600))
//.SetHeight(600)
//.SetWidth(800)
//.SetLocation(new Point(50, 50))
Expand All @@ -98,7 +98,7 @@ private static void FluentStyle()
//Browser settings
//.SetContextMenuEnabled(false)
//.SetDevToolsEnabled(false)
//.SetGrantBrowserPermissions(true)
//.SetGrantBrowserPermissions(false)
//.SetZoom(150)

//Browser startup flags
Expand Down Expand Up @@ -272,9 +272,9 @@ private static void MessageReceivedFromWindow(object sender, string message)
//.SetIconFile(iconFile)
.Load("wwwroot/main.html")

.SetUseOsDefaultLocation(true)
.SetHeight(600)
.SetWidth(800)
//.SetUseOsDefaultLocation(true)
//.SetHeight(600)
//.SetWidth(800)

.SetGrantBrowserPermissions(false)

Expand Down Expand Up @@ -351,19 +351,27 @@ private static void MessageReceivedFromWindow(object sender, string message)
currentWindow.SetLeft(currentWindow.Left + 5);
currentWindow.SetTop(currentWindow.Top + 5);
}
else if (string.Compare(message, "settransparent", true) == 0)
{
var t = currentWindow.Transparent;
Log(sender, $"Transparent: {t}");
currentWindow.SetTransparent(!t);
}
else if (string.Compare(message, "setresizable", true) == 0)
{
currentWindow.SetResizable(!currentWindow.Resizable);
}
else if (string.Compare(message, "setsize-up", true) == 0)
{
currentWindow.SetHeight(currentWindow.Height + 5);
currentWindow.SetWidth(currentWindow.Width + 5);
currentWindow.SetSize(new Size(currentWindow.Width + 5, currentWindow.Height + 5));
//currentWindow.SetHeight(currentWindow.Height + 5);
//currentWindow.SetWidth(currentWindow.Width + 5);
}
else if (string.Compare(message, "setsize-down", true) == 0)
{
currentWindow.SetHeight(currentWindow.Height - 5);
currentWindow.SetWidth(currentWindow.Width - 5);
currentWindow.SetSize(new Size(currentWindow.Width - 5, currentWindow.Height - 5));
//currentWindow.SetHeight(currentWindow.Height - 5);
//currentWindow.SetWidth(currentWindow.Width - 5);
}
else if (string.Compare(message, "settitle", true) == 0)
{
Expand Down
5 changes: 5 additions & 0 deletions Photino.Test/wwwroot/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
window.external.sendMessage('settopmost');
}

function SetTransparent() {
window.external.sendMessage('settransparent');
}

function ShowState() {
window.external.sendMessage('showproperties');
}
Expand Down Expand Up @@ -259,6 +263,7 @@ <h1 id="Title">Test Bench</h1>
<button onclick="Center()">Center</button>
<button onclick="SetPosition()">Position</button>
<button onclick="SetTopmost()">Topmost</button>
<button onclick="SetTransparent()">Transparent</button>
<button onclick="SetFullScreen()">Kiosk</button>
<button onclick="Close()">Close</button>
<br>
Expand Down
Loading