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

Merge Window into FlutterWindow #45542

Merged
merged 14 commits into from Sep 11, 2023

Conversation

yaakovschectman
Copy link
Contributor

Merge abstract base class Window into concrete derived class FlutterWindow to simplify future development.

flutter/flutter#132260

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@yaakovschectman yaakovschectman marked this pull request as ready for review September 7, 2023 18:05
Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the assumption that other than signatures being merged, the implementation details haven't changed in the bulk of this code.

Just a few quick initial comments.

shell/platform/windows/flutter_window.h Show resolved Hide resolved
void HandleResize(UINT width, UINT height);

// Retrieves a class instance pointer for |window|
static FlutterWindow* GetThisFromHandle(HWND const window) noexcept;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: We should consider gathering the static class methods together at the top of each public/protected/private section.


int current_dpi_ = 0;
int current_width_ = 0;
int current_height_ = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should order members in sections. I'll check the style guide but my recollection is: statics, regular methods, fields. Just make sure we keep fields ordered the same as constructor field initialisation to avoid undefined behaviour.

// input.
// See
// https://docs.microsoft.com/en-us/windows/win32/tablet/system-events-and-mouse-messages?redirectedfrom=MSDN#distinguishing-pen-input-from-mouse-and-touch.
static FlutterPointerDeviceKind GetFlutterPointerDeviceKind() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: For static functions (as opposed to class methods), for conistency, we should probably move these to the anonymous namespace instead of old-school static.

const static long kWmDpiChangedBeforeParent = 0x02E2;

// Timer identifier for DirectManipulation gesture polling.
const static int kDirectManipulationTimer = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and above, while you're in here, let's also switch these to static const for consistency with elsewhere.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - thanks!

@dkwingsmt
Copy link
Contributor

Haven't really compared the merged files line by line. Are there any lines worth checking? If not, it looks good to me. :)

@yaakovschectman
Copy link
Contributor Author

Are there any lines worth checking?

There's nothing that's really new code. Just existing code moved to new places and some type names updated to reflect that.

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

#include "gmock/gmock.h"

namespace flutter {
namespace testing {

/// Mock for the |Window| base class.
class MockWindow : public Window {
class MockWindow : public FlutterWindow {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming this type to MockFlutterWindow and this file to mock_flutter_window. I don't feel strongly about this though.


// Registers a window class with default style attributes, cursor and
// icon.
WNDCLASS RegisterWindowClass(std::wstring& title);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do a pass on protected members to check if they can be made private instead? It looks like RegisterWindowClass should be private, there may be more.

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for cleaning this up!

yaakovschectman and others added 3 commits September 8, 2023 15:45
Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com>
@yaakovschectman yaakovschectman merged commit 8389ad9 into flutter:main Sep 11, 2023
26 checks passed
@yaakovschectman yaakovschectman deleted the merge_windows branch September 11, 2023 21:59
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 11, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 11, 2023
…134469)

flutter/engine@06696e7...8389ad9

2023-09-11 109111084+yaakovschectman@users.noreply.github.com Merge `Window` into `FlutterWindow` (flutter/engine#45542)
2023-09-11 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from 7Zk_dvFh301kgQte4... to fSmVaZwp41ZGp5hKn... (flutter/engine#45665)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from 7Zk_dvFh301k to fSmVaZwp41ZG

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
5 participants