Skip to content

Commit

Permalink
Merge pull request #149 from tryphotino/debug
Browse files Browse the repository at this point in the history
Version 4.0
  • Loading branch information
MikeYeager authored Jan 23, 2025
2 parents ffa6813 + 1198c9e commit 3ba4b93
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 50 deletions.
2 changes: 0 additions & 2 deletions Photino.Native/Photino.Linux.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// For this to build on WSL (Ubuntu 18.04) you need to:
// sudo apt-get install libgtk-3-dev libwebkit2gtk-4.0-dev
#ifdef __linux__
#include "Photino.h"
#include "Photino.Dialog.h"
Expand Down
Binary file modified Photino.Native/Photino.Native.rc
Binary file not shown.
8 changes: 4 additions & 4 deletions Photino.Native/Photino.Native.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ COPY .\$(OutDir)WebView2Loader.dll ..\Photino.Test\bin\ARM64\Debug\net8.0\</Comm
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\Microsoft.Web.WebView2.1.0.664.37\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\packages\Microsoft.Web.WebView2.1.0.664.37\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1462.37\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1462.37\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1462.37\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1462.37\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
</Project>
50 changes: 41 additions & 9 deletions Photino.Native/Photino.Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ struct ShowMessageParams
};


const HBRUSH darkBrush = CreateSolidBrush(RGB(0, 0, 0));
const HBRUSH lightBrush = CreateSolidBrush(RGB(255, 255, 255));

void Photino::Register(HINSTANCE hInstance)
{
InitDarkModeSupport();
Expand All @@ -62,7 +65,7 @@ void Photino::Register(HINSTANCE hInstance)
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wcx.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcx.hbrBackground = IsDarkModeEnabled() ? darkBrush : lightBrush;
wcx.lpszMenuName = nullptr;
wcx.lpszClassName = CLASS_NAME;
wcx.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
Expand Down Expand Up @@ -110,17 +113,20 @@ Photino::Photino(PhotinoInitParams* initParams)
{
_startUrl = new wchar_t[2048];
if (_startUrl == NULL) exit(0);
AutoString wStartUrl = ToUTF16String(initParams->StartUrl);
wcscpy(_startUrl, wStartUrl);
//AutoString wStartUrl = ToUTF16String(initParams->StartUrl); //Conversion is done in Navigate method. Don't do it twice
//wcscpy(_startUrl, wStartUrl);
wcscpy(_startUrl, initParams->StartUrl);
}

_startString = NULL;
if (initParams->StartString != NULL)
{
AutoString wStartString = ToUTF16String(initParams->StartString);
_startString = new wchar_t[wcslen(wStartString) + 1];
//AutoString wStartString = ToUTF16String(initParams->StartString); //Conversion is done in Navigate method. Don't do it twice
//_startString = new wchar_t[wcslen(wStartString) + 1];
_startString = new wchar_t[wcslen(initParams->StartString) + 1];
if (_startString == NULL) exit(0);
wcscpy(_startString, wStartString);
//wcscpy(_startString, wStartString);
wcscpy(_startString, initParams->StartString);
}

_temporaryFilesPath = NULL;
Expand All @@ -130,7 +136,6 @@ Photino::Photino(PhotinoInitParams* initParams)
if (_temporaryFilesPath == NULL) exit(0);
AutoString wTemporaryFilesPath = ToUTF16String(initParams->TemporaryFilesPath);
wcscpy(_temporaryFilesPath, wTemporaryFilesPath);

}

_userAgent = NULL;
Expand Down Expand Up @@ -320,6 +325,7 @@ HWND Photino::getHwnd()
return _hWnd;
}


LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
Expand All @@ -328,21 +334,45 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
EnableDarkMode(hwnd, true);
if (IsDarkModeEnabled())
{
RefreshNonClientArea(hwnd);
}
break;
}
case WM_SETTINGCHANGE:
{
if (IsColorSchemeChange(lParam))
SendMessageW(hwnd, WM_THEMECHANGED, 0, 0);

break;
}
case WM_THEMECHANGED:
{
EnableDarkMode(hwnd, IsDarkModeEnabled());
RefreshNonClientArea(hwnd);
InvalidateRect(hwnd, NULL, TRUE);
break;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);

// Fill the background with the current theme color
if (IsDarkModeEnabled())
{
FillRect(hdc, &ps.rcPaint, darkBrush);
//SetTextColor(hdc, RGB(255,255,255));
}
else
{
FillRect(hdc, &ps.rcPaint, lightBrush);
//SetTextColor(hdc, RGB(0, 0, 0));
}

// Draw some text
//SetBkMode(hdc, TRANSPARENT);
//TextOut(hdc, 10, 10, L"Hello, World! (Dynamic Theme)", 31);

EndPaint(hwnd, &ps);
break;
}
case WM_ACTIVATE:
Expand Down Expand Up @@ -648,11 +678,13 @@ void Photino::GetZoom(int* zoom)

void Photino::NavigateToString(AutoString content)
{
content = ToUTF16String(content);
_webviewWindow->NavigateToString(content);
}

void Photino::NavigateToUrl(AutoString url)
{
url = ToUTF16String(url);
_webviewWindow->Navigate(url);
}

Expand Down
2 changes: 0 additions & 2 deletions Photino.Native/Photino.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#ifdef _WIN32
#define UNICODE
#define _UNICODE
#include <Windows.h>
#include <wil/com.h>
#include <WebView2.h>
Expand Down
4 changes: 2 additions & 2 deletions Photino.Native/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.1462.37" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2903.40" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240803.1" targetFramework="native" />
</packages>
8 changes: 7 additions & 1 deletion Photino.Test/Photino.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@
</None>
</ItemGroup>

<Target Name="CopyNativeLibs" AfterTargets="Build">
<Target Name="CopyNativeLibs" AfterTargets="Build" Condition="$(Platform) == 'x64'" >
<Copy SourceFiles="..\Photino.Native\x64\Debug\Photino.Native.dll" DestinationFolder="$(TargetDir)" Condition="$(IsWindows) == 'true'" />
<Copy SourceFiles="..\Photino.Native\x64\Debug\WebView2Loader.dll" DestinationFolder="$(TargetDir)" Condition="$(IsWindows) == 'true'" />
<Copy SourceFiles="../lib/x64/Photino.Native.dylib" DestinationFolder="$(TargetDir)" Condition="$(IsOSX) == 'true'" />
<Copy SourceFiles="../lib/x64/Photino.Native.so" DestinationFolder="$(TargetDir)" Condition="$(IsLinux) == 'true'" />
</Target>

<Target Name="CopyNativeLibs" AfterTargets="Build" Condition="$(Platform) == 'ARM64'">
<Copy SourceFiles="..\Photino.Native\ARM64\Debug\Photino.Native.dll" DestinationFolder="$(TargetDir)" Condition="$(IsWindows) == 'true'" />
<Copy SourceFiles="..\Photino.Native\ARM64\Debug\WebView2Loader.dll" DestinationFolder="$(TargetDir)" Condition="$(IsWindows) == 'true'" />
<Copy SourceFiles="../lib/ARM64/Photino.Native.dylib" DestinationFolder="$(TargetDir)" Condition="$(IsOSX) == 'true'" />
<Copy SourceFiles="../lib/ARM64/Photino.Native.so" DestinationFolder="$(TargetDir)" Condition="$(IsLinux) == 'true'" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions Photino.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ private static void FluentStyle()
//.SetMaximized(true)
//.SetMaxSize(640, 480)
//.SetMinimized(true)
.SetMinHeight(240)
.SetMinWidth(320)
.SetMinHeight(480)
.SetMinWidth(640)
//.SetMinSize(320, 240)
//.SetResizable(false)
//.SetTopMost(true)
Expand Down
Binary file added Photino.Test/binARM64Debugnet8.0
Binary file not shown.
2 changes: 1 addition & 1 deletion Photino.Test/wwwroot/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@

</script>
</head>
<body style="background-color: rgba(0,0,0,0)">
<body>
<h1 id="Title">Test Bench</h1>
<b>Window</b><br>
<button onclick="SetIconFile()">Icon</button>
Expand Down
14 changes: 3 additions & 11 deletions azure-pipelines-photino.native-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:

- job: "Build_Linux_x64"
pool:
vmImage: "ubuntu-20.04"
vmImage: "ubuntu-24.04"

steps:
- task: CmdLine@2
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:

- job: "Build_Mac_Universal"
pool:
vmImage: "macos-12"
vmImage: "macos-latest"

steps:
- task: CmdLine@2
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:

- job: "Copy_Manual_Arm64_Releases"
pool:
vmImage: "ubuntu-latest"
vmImage: "ubuntu-24.04"

steps:
- task: CmdLine@2
Expand All @@ -152,14 +152,6 @@ jobs:
script: |
mkdir -p ./Photino.Native/arm64/$(buildConfiguration)
mv ./manual-arm-release/linux-arm64/Photino.Native.so ./Photino.Native/arm64/$(buildConfiguration)/Photino.Native.so
#mv ./manual-arm-release/win-arm64/Photino.Native.dll ./Photino.Native/arm64/$(buildConfiguration)/Photino.Native.dll
#mv ./manual-arm-release/win-arm64/WebView2Loader.dll ./Photino.Native/arm64/$(buildConfiguration)/WebView2Loader.dll
#- task: PublishPipelineArtifact@1
# displayName: "Publish Windows (ARM64) libraries to artifacts"
# inputs:
# targetPath: "./Photino.Native/arm64/$(buildConfiguration)"
# artifactName: WindowsArm64Artifact
- task: PublishPipelineArtifact@1
displayName: "Publish Linux (ARM64) libraries to artifacts"
Expand Down
18 changes: 5 additions & 13 deletions azure-pipelines-photino.native-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ trigger:
- master

variables:
major: 3
minor: 2
major: 4
minor: 0
patch: $[counter(variables['minor'], 0)] #this will reset when we bump minor
buildConfiguration: "Release"

Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:

- job: "Build_Linux_x64"
pool:
vmImage: "ubuntu-latest"
vmImage: "ubuntu-24.04"

steps:
- task: CmdLine@2
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:

- job: "Build_Mac_Universal"
pool:
vmImage: "macos-12"
vmImage: "macos-latest"

steps:
- task: CmdLine@2
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:

- job: "Copy_Manual_Arm64_Releases"
pool:
vmImage: "ubuntu-latest"
vmImage: "ubuntu-24.04"

steps:
- task: CmdLine@2
Expand All @@ -154,14 +154,6 @@ jobs:
script: |
mkdir -p ./Photino.Native/arm64/$(buildConfiguration)
mv ./manual-arm-release/linux-arm64/Photino.Native.so ./Photino.Native/arm64/$(buildConfiguration)/Photino.Native.so
#mv ./manual-arm-release/win-arm64/Photino.Native.dll ./Photino.Native/arm64/$(buildConfiguration)/Photino.Native.dll
#mv ./manual-arm-release/win-arm64/WebView2Loader.dll ./Photino.Native/arm64/$(buildConfiguration)/WebView2Loader.dll
#- task: PublishPipelineArtifact@1
# displayName: "Publish Windows (ARM64) libraries to artifacts"
# inputs:
# targetPath: "./Photino.Native/arm64/$(buildConfiguration)"
# artifactName: WindowsArm64Artifact
- task: PublishPipelineArtifact@1
displayName: "Publish Linux (ARM64) libraries to artifacts"
Expand Down
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ build-photino-mac-universal:

install-linux-dependencies:
sudo apt-get update\
&& sudo apt-get install libgtk-3-dev libwebkit2gtk-4.0-dev libnotify4 libnotify-dev
&& sudo apt-get install libgtk-3-dev libwebkit2gtk-4.1-dev libnotify4 libnotify-dev

build-photino-linux-x64:
$(CC) -o $(DEST_PATH_X64)/$(DEST_FILE).so\
$(CFLAGS)\
$(SRC)/Photino.Linux.Dialog.cpp\
$(SRC)/Photino.Linux.cpp\
$(SRC)/Exports.cpp\
`pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0 libnotify`
`pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.1 libnotify`

build-photino-linux-arm64:
$(CC) -o $(DEST_PATH_ARM64)/$(DEST_FILE).so\
$(CFLAGS)\
$(SRC)/Photino.Linux.Dialog.cpp\
$(SRC)/Photino.Linux.cpp\
$(SRC)/Exports.cpp\
`pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0 libnotify`
`pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.1 libnotify`

clean-x64:
rm -rf $(DEST_PATH_X64)/* & mkdir -p $(DEST_PATH_X64)
Expand Down
Binary file modified manual-arm-release/linux-arm64/Photino.Native.so
Binary file not shown.
Binary file removed manual-arm-release/win-arm64/Photino.Native.dll
Binary file not shown.
Binary file removed manual-arm-release/win-arm64/WebView2Loader.dll
Binary file not shown.

0 comments on commit 3ba4b93

Please sign in to comment.