Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a35167d
README fix
stuartmorgan-g May 1, 2023
69dc81b
Direct copy of Windows
stuartmorgan-g May 1, 2023
b110acf
Remove Windows examples, add template-created macOS and Linux examples
stuartmorgan-g May 1, 2023
e311f04
Add new platform interface pieces
stuartmorgan-g May 1, 2023
1558aa2
Update Windows implementation
stuartmorgan-g May 1, 2023
9f0f245
Add macOS and Linux implementations
stuartmorgan-g May 1, 2023
e8e6c98
Add integration test config exemptions
stuartmorgan-g May 1, 2023
5d8b155
Fix some lingering references to Windows
stuartmorgan-g May 1, 2023
fd7655d
Add TODO about PHFilePicker
stuartmorgan-g May 1, 2023
e48478e
Update desktop implementation examples to use newer APIs
stuartmorgan-g May 1, 2023
047b32a
Fix macOS
stuartmorgan-g May 1, 2023
4af92e2
Add app-facing API, update examples
stuartmorgan-g May 2, 2023
1361f31
Add README notes, version bumps, and endorsement
stuartmorgan-g May 2, 2023
094b763
Adjust labels
stuartmorgan-g May 2, 2023
c384211
Add codeowners
stuartmorgan-g May 2, 2023
ba3a86b
Update OS support table in README
stuartmorgan-g May 2, 2023
3f0161a
Fix pubspec overrides
stuartmorgan-g May 2, 2023
1d99ee1
Add desktop support to app-facing example
stuartmorgan-g May 2, 2023
7a509e3
Copyright for template-generated files
stuartmorgan-g May 2, 2023
471f87d
Revert auto-changes to existing platforms
stuartmorgan-g May 2, 2023
42ac084
Sort overrides
stuartmorgan-g May 2, 2023
a2eb725
Autoformat boilerplate code
stuartmorgan-g May 2, 2023
9174b4f
Add missing version bump
stuartmorgan-g May 2, 2023
3e4b21c
Initial review comments
stuartmorgan-g May 3, 2023
0281b4c
Remove examples for ease of review
stuartmorgan-g May 3, 2023
4ada117
Reverts removing examples for ease of review
stuartmorgan-g May 3, 2023
16ab8c2
Merge branch 'main' into image-picker-macos-linux
stuartmorgan-g May 3, 2023
921e295
Merge branch 'main' into image-picker-macos-linux
stuartmorgan-g Jun 7, 2023
7b4ebf5
Address review comments
stuartmorgan-g Jun 7, 2023
d18936d
Missing awaits
stuartmorgan-g Jun 7, 2023
9296999
Merge branch 'main' into image-picker-macos-linux
stuartmorgan-g Jun 9, 2023
ff710c6
Scrub platform interface overrides
stuartmorgan-g Jun 9, 2023
c79601e
Merge branch 'main' into image-picker-macos-linux
stuartmorgan-g Jun 9, 2023
dba80d2
Remove overrides
stuartmorgan-g Jun 9, 2023
6a86c5d
Update macOS version
stuartmorgan-g Jun 9, 2023
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
Prev Previous commit
Next Next commit
Autoformat boilerplate code
  • Loading branch information
stuartmorgan-g committed May 2, 2023
commit a2eb725e1554b0376f60b40d7213c48064e91efc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static void my_application_activate(GApplication* application) {
gtk_widget_show(GTK_WIDGET(window));

g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
fl_dart_project_set_dart_entrypoint_arguments(
project, self->dart_entrypoint_arguments);

FlView* view = fl_view_new(project);
gtk_widget_show(GTK_WIDGET(view));
Expand All @@ -67,16 +68,18 @@ static void my_application_activate(GApplication* application) {
}

// Implements GApplication::local_command_line.
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
static gboolean my_application_local_command_line(GApplication* application,
gchar*** arguments,
int* exit_status) {
MyApplication* self = MY_APPLICATION(application);
// Strip out the first argument as it is the binary name.
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);

g_autoptr(GError) error = nullptr;
if (!g_application_register(application, nullptr, &error)) {
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}

g_application_activate(application);
Expand All @@ -94,15 +97,15 @@ static void my_application_dispose(GObject* object) {

static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
G_APPLICATION_CLASS(klass)->local_command_line =
my_application_local_command_line;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
}

static void my_application_init(MyApplication* self) {}

MyApplication* my_application_new() {
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
nullptr));
"application-id", APPLICATION_ID, "flags",
G_APPLICATION_NON_UNIQUE, nullptr));
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ bool FlutterWindow::OnCreate() {
RegisterPlugins(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());

flutter_controller_->engine()->SetNextFrameCallback([&]() {
this->Show();
});
flutter_controller_->engine()->SetNextFrameCallback([&]() { this->Show(); });

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "utils.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
_In_ wchar_t* command_line, _In_ int show_command) {
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
Expand All @@ -23,8 +23,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,

flutter::DartProject project(L"data");

std::vector<std::string> command_line_arguments =
GetCommandLineArguments();
std::vector<std::string> command_line_arguments = GetCommandLineArguments();

project.set_dart_entrypoint_arguments(std::move(command_line_arguments));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Microsoft Visual C++ generated include file.
// Used by Runner.rc
//
#define IDI_APP_ICON 101
#define IDI_APP_ICON 101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
FILE* unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
Expand Down Expand Up @@ -49,17 +49,16 @@ std::string Utf8FromUtf16(const wchar_t* utf16_string) {
if (utf16_string == nullptr) {
return std::string();
}
int target_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
-1, nullptr, 0, nullptr, nullptr);
int target_length =
::WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1,
nullptr, 0, nullptr, nullptr);
std::string utf8_string;
if (target_length == 0 || target_length > utf8_string.max_size()) {
return utf8_string;
}
utf8_string.resize(target_length);
int converted_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
-1, utf8_string.data(),
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1, utf8_string.data(),
target_length, nullptr, nullptr);
if (converted_length == 0) {
return std::string();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace {
///
/// Redefined in case the developer's machine has a Windows SDK older than
/// version 10.0.22000.0.
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
/// See:
/// https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
#endif
Expand All @@ -27,8 +28,9 @@ constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
/// A value of 0 indicates apps should use dark mode. A non-zero or missing
/// value indicates apps should use light mode.
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
constexpr const wchar_t kGetPreferredBrightnessRegValue[] =
L"AppsUseLightTheme";

// The number of Win32Window objects that currently exist.
static int g_active_window_count = 0;
Expand Down Expand Up @@ -115,17 +117,14 @@ void WindowClassRegistrar::UnregisterWindowClass() {
class_registered_ = false;
}

Win32Window::Win32Window() {
++g_active_window_count;
}
Win32Window::Win32Window() { ++g_active_window_count; }

Win32Window::~Win32Window() {
--g_active_window_count;
Destroy();
}

bool Win32Window::Create(const std::wstring& title,
const Point& origin,
bool Win32Window::Create(const std::wstring& title, const Point& origin,
const Size& size) {
Destroy();

Expand Down Expand Up @@ -153,13 +152,10 @@ bool Win32Window::Create(const std::wstring& title,
return OnCreate();
}

bool Win32Window::Show() {
return ShowWindow(window_handle_, SW_SHOWNORMAL);
}
bool Win32Window::Show() { return ShowWindow(window_handle_, SW_SHOWNORMAL); }

// static
LRESULT CALLBACK Win32Window::WndProc(HWND const window,
UINT const message,
LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
if (message == WM_NCCREATE) {
Expand All @@ -178,9 +174,7 @@ LRESULT CALLBACK Win32Window::WndProc(HWND const window,
}

LRESULT
Win32Window::MessageHandler(HWND hwnd,
UINT const message,
WPARAM const wparam,
Win32Window::MessageHandler(HWND hwnd, UINT const message, WPARAM const wparam,
LPARAM const lparam) noexcept {
switch (message) {
case WM_DESTROY:
Expand Down Expand Up @@ -259,9 +253,7 @@ RECT Win32Window::GetClientArea() {
return frame;
}

HWND Win32Window::GetHandle() {
return window_handle_;
}
HWND Win32Window::GetHandle() { return window_handle_; }

void Win32Window::SetQuitOnClose(bool quit_on_close) {
quit_on_close_ = quit_on_close;
Expand All @@ -279,10 +271,10 @@ void Win32Window::OnDestroy() {
void Win32Window::UpdateTheme(HWND const window) {
DWORD light_mode;
DWORD light_mode_size = sizeof(light_mode);
LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
kGetPreferredBrightnessRegValue,
RRF_RT_REG_DWORD, nullptr, &light_mode,
&light_mode_size);
LSTATUS result =
RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD, nullptr,
&light_mode, &light_mode_size);

if (result == ERROR_SUCCESS) {
BOOL enable_dark_mode = light_mode == 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ class Win32Window {
// Processes and route salient window messages for mouse handling,
// size change and DPI. Delegates handling of these to member overloads that
// inheriting classes can handle.
virtual LRESULT MessageHandler(HWND window,
UINT const message,
virtual LRESULT MessageHandler(HWND window, UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept;

Expand All @@ -83,8 +82,7 @@ class Win32Window {
// non-client DPI scaling so that the non-client area automatically
// responsponds to changes in DPI. All other messages are handled by
// MessageHandler.
static LRESULT CALLBACK WndProc(HWND const window,
UINT const message,
static LRESULT CALLBACK WndProc(HWND const window, UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static void my_application_activate(GApplication* application) {
gtk_widget_show(GTK_WIDGET(window));

g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
fl_dart_project_set_dart_entrypoint_arguments(
project, self->dart_entrypoint_arguments);

FlView* view = fl_view_new(project);
gtk_widget_show(GTK_WIDGET(view));
Expand All @@ -67,16 +68,18 @@ static void my_application_activate(GApplication* application) {
}

// Implements GApplication::local_command_line.
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
static gboolean my_application_local_command_line(GApplication* application,
gchar*** arguments,
int* exit_status) {
MyApplication* self = MY_APPLICATION(application);
// Strip out the first argument as it is the binary name.
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);

g_autoptr(GError) error = nullptr;
if (!g_application_register(application, nullptr, &error)) {
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}

g_application_activate(application);
Expand All @@ -94,15 +97,15 @@ static void my_application_dispose(GObject* object) {

static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
G_APPLICATION_CLASS(klass)->local_command_line =
my_application_local_command_line;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
}

static void my_application_init(MyApplication* self) {}

MyApplication* my_application_new() {
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
nullptr));
"application-id", APPLICATION_ID, "flags",
G_APPLICATION_NON_UNIQUE, nullptr));
}