diff --git a/README.md b/README.md index 3830e2b..da68d86 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # flwtch -A new Flutter application. +A Flutter based Cwtch UI ## Getting Started @@ -8,13 +8,19 @@ click the play button in android studio ### Linux -- libCwtch-go: the result of `make linux`, `libCwtch.so` should be in the link path +- libCwtch-go: required to be on the link path (linux/cwtch.destktop demonstrates with `env LD_LIBRARY_PATH=./lib/` on the front of the comman) + - fetch-libcwtch-go.sh will fetch a prebuilt version + - or compile from source from libcwtch-go with `make linux` - `tor` should be in the PATH ### Windows -- libCwtch-go: the result of `make windows`, `libCwtch.dll` should be placed in the source root -- tor is bundled in `windors/Tor` +- run `fetch-libcwtch-go.ps1` to get `libCwtch.dll` which is required to run +- run `fetch-tor-win.ps1` to fetch Tor for windows + +#### Issues + +- Flutter engine has a [known bug](https://github.com/flutter/flutter/issues/75675) around the Right Shift key being sticky. We have implemented the mostly work around, but until it is fixed, right shift occasionally acts permenent. If this happens, just tap left shift and it will reset ## l10n diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index a8e51aa..a1c031b 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.15) -project(flutter_app LANGUAGES CXX) +project(cwtch LANGUAGES CXX) -set(BINARY_NAME "flutter_app") +set(BINARY_NAME "cwtch") cmake_policy(SET CMP0063 NEW) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..9deaa4e 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -2,10 +2,11 @@ // Generated file. Do not edit. // -// clang-format off - #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + WindowSizePluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowSizePlugin")); } diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h index dc139d8..9846246 100644 --- a/windows/flutter/generated_plugin_registrant.h +++ b/windows/flutter/generated_plugin_registrant.h @@ -2,8 +2,6 @@ // Generated file. Do not edit. // -// clang-format off - #ifndef GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 4d10c25..154f238 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + window_size ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index 930c3e7..d0b3323 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -52,7 +52,16 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDI_APP_ICON ICON "resources\\app_icon.ico" +IDI_APP_ICON_LG ICON "resources\\knot_256.ico" +IDI_APP_ICON_SM ICON "resources\\knot_64.ico" + +IDI_APP_ICON_256 ICON "resources\\knot_256.ico" +IDI_APP_ICON_128 ICON "resources\\knot_128.ico" +IDI_APP_ICON_64 ICON "resources\\knot_64.ico" +IDI_APP_ICON_48 ICON "resources\\knot_48.ico" +IDI_APP_ICON_32 ICON "resources\\knot_32.ico" +IDI_APP_ICON_16 ICON "resources\\knot_16.ico" + ///////////////////////////////////////////////////////////////////////////// @@ -89,13 +98,13 @@ BEGIN BEGIN BLOCK "040904e4" BEGIN - VALUE "CompanyName", "com.example" "\0" - VALUE "FileDescription", "A new Flutter project." "\0" + VALUE "CompanyName", "Open Privacy Research Society" "\0" + VALUE "FileDescription", "Cwtch Instant Messenger" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" - VALUE "InternalName", "flutter_app" "\0" - VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0" - VALUE "OriginalFilename", "flutter_app.exe" "\0" - VALUE "ProductName", "flutter_app" "\0" + VALUE "InternalName", "cwtch" "\0" + VALUE "LegalCopyright", "Copyright (C) 2021 Open Privacy Research Society. All rights reserved." "\0" + VALUE "OriginalFilename", "cwtch.exe" "\0" + VALUE "ProductName", "Cwtch" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" END END diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index b67fe12..f52513a 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -30,7 +30,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(&run_loop, project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - if (!window.CreateAndShow(L"flutter_app", origin, size)) { + if (!window.CreateAndShow(L"cwtch", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); diff --git a/windows/runner/resource.h b/windows/runner/resource.h index 66a65d1..48e5f82 100644 --- a/windows/runner/resource.h +++ b/windows/runner/resource.h @@ -2,7 +2,16 @@ // Microsoft Visual C++ generated include file. // Used by Runner.rc // -#define IDI_APP_ICON 101 +#define IDI_APP_ICON_LG 101 +#define IDI_APP_ICON_SM 102 + +#define IDI_APP_ICON_256 103 +#define IDI_APP_ICON_128 104 +#define IDI_APP_ICON_64 105 +#define IDI_APP_ICON_48 106 +#define IDI_APP_ICON_32 107 +#define IDI_APP_ICON_16 108 + // Next default values for new objects // diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico deleted file mode 100644 index c04e20c..0000000 Binary files a/windows/runner/resources/app_icon.ico and /dev/null differ diff --git a/windows/runner/resources/knot_128.ico b/windows/runner/resources/knot_128.ico new file mode 100644 index 0000000..d35e28f Binary files /dev/null and b/windows/runner/resources/knot_128.ico differ diff --git a/windows/runner/resources/knot_16.ico b/windows/runner/resources/knot_16.ico new file mode 100644 index 0000000..42fa6e9 Binary files /dev/null and b/windows/runner/resources/knot_16.ico differ diff --git a/windows/runner/resources/knot_256.ico b/windows/runner/resources/knot_256.ico new file mode 100644 index 0000000..2e0f50a Binary files /dev/null and b/windows/runner/resources/knot_256.ico differ diff --git a/windows/runner/resources/knot_32.ico b/windows/runner/resources/knot_32.ico new file mode 100644 index 0000000..da12547 Binary files /dev/null and b/windows/runner/resources/knot_32.ico differ diff --git a/windows/runner/resources/knot_48.ico b/windows/runner/resources/knot_48.ico new file mode 100644 index 0000000..169ba2c Binary files /dev/null and b/windows/runner/resources/knot_48.ico differ diff --git a/windows/runner/resources/knot_64.ico b/windows/runner/resources/knot_64.ico new file mode 100644 index 0000000..74a28e0 Binary files /dev/null and b/windows/runner/resources/knot_64.ico differ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp index c10f08d..ad68d53 100644 --- a/windows/runner/win32_window.cpp +++ b/windows/runner/win32_window.cpp @@ -1,4 +1,5 @@ #include "win32_window.h" +#include "winuser.h" #include @@ -70,19 +71,49 @@ WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; const wchar_t* WindowClassRegistrar::GetWindowClass() { if (!class_registered_) { - WNDCLASS window_class{}; + WNDCLASSEX window_class{}; + window_class.cbSize = sizeof(WNDCLASSEX); window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); window_class.lpszClassName = kWindowClassName; window_class.style = CS_HREDRAW | CS_VREDRAW; window_class.cbClsExtra = 0; window_class.cbWndExtra = 0; window_class.hInstance = GetModuleHandle(nullptr); + int icon_sz = GetSystemMetrics(SM_CXICON); + int iconh_id = IDI_APP_ICON_32; + if (icon_sz > 128) { + iconh_id = IDI_APP_ICON_256; + } else if (icon_sz > 64) { + iconh_id = IDI_APP_ICON_128; + } else if (icon_sz > 48) { + iconh_id = IDI_APP_ICON_64; + } else if (icon_sz > 32) { + iconh_id = IDI_APP_ICON_48; + } window_class.hIcon = - LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(iconh_id)); + + + int icon_sm_sz = GetSystemMetrics(SM_CXSMICON); + int iconsmh_id = IDI_APP_ICON_16; + if (icon_sm_sz > 128) { + iconsmh_id = IDI_APP_ICON_256; + } else if (icon_sm_sz > 64) { + iconsmh_id = IDI_APP_ICON_128; + } else if (icon_sm_sz > 48) { + iconsmh_id = IDI_APP_ICON_64; + } else if (icon_sm_sz > 32) { + iconsmh_id = IDI_APP_ICON_48; + } else if (icon_sm_sz > 16) { + iconsmh_id = IDI_APP_ICON_32; + } + window_class.hIconSm = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(iconsmh_id)); + window_class.hbrBackground = 0; window_class.lpszMenuName = nullptr; window_class.lpfnWndProc = Win32Window::WndProc; - RegisterClass(&window_class); + RegisterClassEx(&window_class); class_registered_ = true; } return kWindowClassName;