This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Provide access to GLFW window in plugins #8806
Merged
stuartmorgan-g
merged 7 commits into
flutter:master
from
stuartmorgan-g:glfw-plugin-window-access
May 6, 2019
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3ef173d
Provide access to GLFW window in plugins
stuartmorgan-g ede8a67
Rename a header to match class name
stuartmorgan-g 9d1fe86
Fold new header back into flutter_glfw to avoid recipe changes
stuartmorgan-g bb29d0d
Fix link bugs
stuartmorgan-g 71fb7f5
GN format
stuartmorgan-g fb62eef
Add new files to license list
stuartmorgan-g 2dbc269
Add a way to destroy a window without running the runloop
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
shell/platform/glfw/client_wrapper/include/flutter/flutter_window.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_WINDOW_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_WINDOW_H_ | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include <flutter_glfw.h> | ||
|
|
||
| #include "plugin_registrar.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| // A window displaying Flutter content. | ||
| class FlutterWindow { | ||
| public: | ||
| explicit FlutterWindow(FlutterDesktopWindowRef window) : window_(window) {} | ||
|
|
||
| ~FlutterWindow() = default; | ||
|
|
||
| // Prevent copying. | ||
| FlutterWindow(FlutterWindow const&) = delete; | ||
| FlutterWindow& operator=(FlutterWindow const&) = delete; | ||
|
|
||
| // Enables or disables hover tracking. | ||
| // | ||
| // If hover is enabled, mouse movement will send hover events to the Flutter | ||
| // engine, rather than only tracking the mouse while the button is pressed. | ||
| // Defaults to off. | ||
| void SetHoverEnabled(bool enabled) { | ||
| FlutterDesktopWindowSetHoverEnabled(window_, enabled); | ||
| } | ||
|
|
||
| // Sets the displayed title of the window. | ||
| void SetTitle(const std::string& title) { | ||
| FlutterDesktopWindowSetTitle(window_, title.c_str()); | ||
| } | ||
|
|
||
| // Sets the displayed icon for the window. | ||
| // | ||
| // The pixel format is 32-bit RGBA. The provided image data only needs to be | ||
| // valid for the duration of the call to this method. Pass a nullptr to revert | ||
| // to the default icon. | ||
| void SetIcon(uint8_t* pixel_data, int width, int height) { | ||
| FlutterDesktopWindowSetIcon(window_, pixel_data, width, height); | ||
| } | ||
|
|
||
| private: | ||
| // Handle for interacting with the C API's window. | ||
| // | ||
| // Note: window_ is conceptually owned by the controller, not this object. | ||
| FlutterDesktopWindowRef window_; | ||
stuartmorgan-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_WINDOW_H_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
shell/platform/glfw/client_wrapper/include/flutter/plugin_registrar_glfw.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRAR_GLFW_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRAR_GLFW_H_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include <flutter_glfw.h> | ||
|
|
||
| #include "flutter_window.h" | ||
| #include "plugin_registrar.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| // An extension to PluginRegistrar providing access to GLFW-shell-specific | ||
| // functionality. | ||
| class PluginRegistrarGlfw : public PluginRegistrar { | ||
| public: | ||
| // Creates a new PluginRegistrar. |core_registrar| and the messenger it | ||
| // provides must remain valid as long as this object exists. | ||
| explicit PluginRegistrarGlfw(FlutterDesktopPluginRegistrarRef core_registrar) | ||
| : PluginRegistrar(core_registrar) { | ||
| window_ = std::make_unique<FlutterWindow>( | ||
| FlutterDesktopRegistrarGetWindow(core_registrar)); | ||
| } | ||
|
|
||
| virtual ~PluginRegistrarGlfw() = default; | ||
|
|
||
| // Prevent copying. | ||
| PluginRegistrarGlfw(PluginRegistrarGlfw const&) = delete; | ||
| PluginRegistrarGlfw& operator=(PluginRegistrarGlfw const&) = delete; | ||
|
|
||
| FlutterWindow* window() { return window_.get(); } | ||
|
|
||
| private: | ||
| // The owned FlutterWindow, if any. | ||
| std::unique_ptr<FlutterWindow> window_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRAR_GLFW_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.