зеркало из https://github.com/electron/electron.git
feat: add BrowserWindow.isTabletMode API (#25209)
This commit is contained in:
Родитель
2dd7ad268b
Коммит
c50ded2b71
|
@ -1346,6 +1346,17 @@ Enters or leaves kiosk mode.
|
|||
|
||||
Returns `Boolean` - Whether the window is in kiosk mode.
|
||||
|
||||
#### `win.isTabletMode()` _Windows_
|
||||
|
||||
Returns `Boolean` - Whether the window is in Windows 10 tablet mode.
|
||||
|
||||
Since Windows 10 users can [use their PC as tablet](https://support.microsoft.com/en-us/help/17210/windows-10-use-your-pc-like-a-tablet),
|
||||
under this mode apps can choose to optimize their UI for tablets, such as
|
||||
enlarging the titlebar and hiding titlebar buttons.
|
||||
|
||||
This API returns whether the window is in tablet mode, and the `resize` event
|
||||
can be be used to listen to changes to tablet mode.
|
||||
|
||||
#### `win.getMediaSourceId()`
|
||||
|
||||
Returns `String` - Window id in the format of DesktopCapturerSource's id. For example "window:1234:0".
|
||||
|
|
|
@ -622,6 +622,10 @@ bool BaseWindow::IsKiosk() {
|
|||
return window_->IsKiosk();
|
||||
}
|
||||
|
||||
bool BaseWindow::IsTabletMode() const {
|
||||
return window_->IsTabletMode();
|
||||
}
|
||||
|
||||
void BaseWindow::SetBackgroundColor(const std::string& color_name) {
|
||||
SkColor color = ParseHexColor(color_name);
|
||||
window_->SetBackgroundColor(color);
|
||||
|
@ -1160,6 +1164,7 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("isSimpleFullScreen", &BaseWindow::IsSimpleFullScreen)
|
||||
.SetMethod("setKiosk", &BaseWindow::SetKiosk)
|
||||
.SetMethod("isKiosk", &BaseWindow::IsKiosk)
|
||||
.SetMethod("isTabletMode", &BaseWindow::IsTabletMode)
|
||||
.SetMethod("setBackgroundColor", &BaseWindow::SetBackgroundColor)
|
||||
.SetMethod("getBackgroundColor", &BaseWindow::GetBackgroundColor)
|
||||
.SetMethod("setHasShadow", &BaseWindow::SetHasShadow)
|
||||
|
|
|
@ -152,6 +152,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
|||
bool IsSimpleFullScreen();
|
||||
void SetKiosk(bool kiosk);
|
||||
bool IsKiosk();
|
||||
bool IsTabletMode() const;
|
||||
virtual void SetBackgroundColor(const std::string& color_name);
|
||||
std::string GetBackgroundColor();
|
||||
void SetHasShadow(bool has_shadow);
|
||||
|
|
|
@ -310,6 +310,10 @@ double NativeWindow::GetSheetOffsetY() {
|
|||
return sheet_offset_y_;
|
||||
}
|
||||
|
||||
bool NativeWindow::IsTabletMode() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void NativeWindow::SetRepresentedFilename(const std::string& filename) {}
|
||||
|
||||
std::string NativeWindow::GetRepresentedFilename() {
|
||||
|
|
|
@ -148,6 +148,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual bool IsSimpleFullScreen() = 0;
|
||||
virtual void SetKiosk(bool kiosk) = 0;
|
||||
virtual bool IsKiosk() = 0;
|
||||
virtual bool IsTabletMode() const;
|
||||
virtual void SetBackgroundColor(SkColor color) = 0;
|
||||
virtual SkColor GetBackgroundColor() = 0;
|
||||
virtual void SetHasShadow(bool has_shadow) = 0;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
|
||||
#include "ui/views/window/native_frame_view.h"
|
||||
#elif defined(OS_WIN)
|
||||
#include "base/win/win_util.h"
|
||||
#include "shell/browser/ui/views/win_frame_view.h"
|
||||
#include "shell/browser/ui/win/electron_desktop_native_widget_aura.h"
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
|
@ -901,6 +902,14 @@ bool NativeWindowViews::IsKiosk() {
|
|||
return IsFullscreen();
|
||||
}
|
||||
|
||||
bool NativeWindowViews::IsTabletMode() const {
|
||||
#if defined(OS_WIN)
|
||||
return base::win::IsWindows10TabletMode(GetAcceleratedWidget());
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
SkColor NativeWindowViews::GetBackgroundColor() {
|
||||
return root_view_->background()->get_color();
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool IsSimpleFullScreen() override;
|
||||
void SetKiosk(bool kiosk) override;
|
||||
bool IsKiosk() override;
|
||||
bool IsTabletMode() const override;
|
||||
void SetBackgroundColor(SkColor color) override;
|
||||
void SetHasShadow(bool has_shadow) override;
|
||||
bool HasShadow() override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче