зеркало из https://github.com/electron/electron.git
The UpdateDraggableRegions does not share implementations
This commit is contained in:
Родитель
c2aa312e0c
Коммит
44e7282b4b
|
@ -671,15 +671,6 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message,
|
|||
return handled;
|
||||
}
|
||||
|
||||
void NativeWindow::UpdateDraggableRegions(
|
||||
content::RenderFrameHost* rfh,
|
||||
const std::vector<DraggableRegion>& regions) {
|
||||
// Draggable region is not supported for non-frameless window.
|
||||
if (has_frame_)
|
||||
return;
|
||||
draggable_region_ = DraggableRegionsToSkRegion(regions);
|
||||
}
|
||||
|
||||
void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||
if (!window_unresposive_closure_.IsCancelled())
|
||||
return;
|
||||
|
|
|
@ -216,6 +216,17 @@ class NativeWindow : public base::SupportsUserData,
|
|||
const std::string& display_name);
|
||||
virtual void CloseFilePreview();
|
||||
|
||||
// Converts between content bounds and window bounds.
|
||||
virtual gfx::Rect ContentBoundsToWindowBounds(
|
||||
const gfx::Rect& bounds) const = 0;
|
||||
virtual gfx::Rect WindowBoundsToContentBounds(
|
||||
const gfx::Rect& bounds) const = 0;
|
||||
|
||||
// Called when the window needs to update its draggable region.
|
||||
virtual void UpdateDraggableRegions(
|
||||
content::RenderFrameHost* rfh,
|
||||
const std::vector<DraggableRegion>& regions) = 0;
|
||||
|
||||
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
@ -287,7 +298,6 @@ class NativeWindow : public base::SupportsUserData,
|
|||
void set_has_frame(bool has_frame) { has_frame_ = has_frame; }
|
||||
|
||||
bool transparent() const { return transparent_; }
|
||||
SkRegion* draggable_region() const { return draggable_region_.get(); }
|
||||
bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
|
||||
|
||||
void set_is_offscreen_dummy(bool is_dummy) { is_osr_dummy_ = is_dummy; }
|
||||
|
@ -306,17 +316,6 @@ class NativeWindow : public base::SupportsUserData,
|
|||
std::unique_ptr<SkRegion> DraggableRegionsToSkRegion(
|
||||
const std::vector<DraggableRegion>& regions);
|
||||
|
||||
// Converts between content bounds and window bounds.
|
||||
virtual gfx::Rect ContentBoundsToWindowBounds(
|
||||
const gfx::Rect& bounds) const = 0;
|
||||
virtual gfx::Rect WindowBoundsToContentBounds(
|
||||
const gfx::Rect& bounds) const = 0;
|
||||
|
||||
// Called when the window needs to update its draggable region.
|
||||
virtual void UpdateDraggableRegions(
|
||||
content::RenderFrameHost* rfh,
|
||||
const std::vector<DraggableRegion>& regions);
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadDialogCancelled() override;
|
||||
bool OnMessageReceived(const IPC::Message& message,
|
||||
|
@ -335,10 +334,6 @@ class NativeWindow : public base::SupportsUserData,
|
|||
// Whether window is transparent.
|
||||
bool transparent_;
|
||||
|
||||
// For custom drag, the whole window is non-draggable and the draggable region
|
||||
// has to been explicitly provided.
|
||||
std::unique_ptr<SkRegion> draggable_region_; // used in custom drag.
|
||||
|
||||
// Minimum and maximum size, stored as content size.
|
||||
extensions::SizeConstraints size_constraints_;
|
||||
|
||||
|
|
|
@ -1072,6 +1072,64 @@ gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() const {
|
|||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
||||
const gfx::Rect& bounds) const {
|
||||
if (!has_frame())
|
||||
return bounds;
|
||||
|
||||
gfx::Rect window_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
gfx::Rect dpi_bounds = display::win::ScreenWin::DIPToScreenRect(hwnd, bounds);
|
||||
window_bounds = display::win::ScreenWin::ScreenToDIPRect(
|
||||
hwnd,
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_) {
|
||||
window_bounds.set_y(window_bounds.y() - kMenuBarHeight);
|
||||
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
||||
}
|
||||
return window_bounds;
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindowViews::WindowBoundsToContentBounds(
|
||||
const gfx::Rect& bounds) const {
|
||||
if (!has_frame())
|
||||
return bounds;
|
||||
|
||||
gfx::Rect content_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
content_bounds.set_size(
|
||||
display::win::ScreenWin::DIPToScreenSize(hwnd, content_bounds.size()));
|
||||
RECT rect;
|
||||
SetRectEmpty(&rect);
|
||||
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
||||
DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
|
||||
content_bounds.set_width(content_bounds.width() - (rect.right - rect.left));
|
||||
content_bounds.set_height(content_bounds.height() - (rect.bottom - rect.top));
|
||||
content_bounds.set_size(
|
||||
display::win::ScreenWin::ScreenToDIPSize(hwnd, content_bounds.size()));
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_) {
|
||||
content_bounds.set_y(content_bounds.y() + kMenuBarHeight);
|
||||
content_bounds.set_height(content_bounds.height() - kMenuBarHeight);
|
||||
}
|
||||
return content_bounds;
|
||||
}
|
||||
|
||||
void NativeWindowViews::UpdateDraggableRegions(
|
||||
content::RenderFrameHost* rfh,
|
||||
const std::vector<DraggableRegion>& regions) {
|
||||
// Draggable region is not supported for non-frameless window.
|
||||
if (has_frame())
|
||||
return;
|
||||
draggable_region_ = DraggableRegionsToSkRegion(regions);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
|
||||
// We are responsible for storing the images.
|
||||
|
@ -1270,55 +1328,6 @@ void NativeWindowViews::OnWidgetMove() {
|
|||
NotifyWindowMove();
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
||||
const gfx::Rect& bounds) const {
|
||||
if (!has_frame())
|
||||
return bounds;
|
||||
|
||||
gfx::Rect window_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
gfx::Rect dpi_bounds = display::win::ScreenWin::DIPToScreenRect(hwnd, bounds);
|
||||
window_bounds = display::win::ScreenWin::ScreenToDIPRect(
|
||||
hwnd,
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_) {
|
||||
window_bounds.set_y(window_bounds.y() - kMenuBarHeight);
|
||||
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
||||
}
|
||||
return window_bounds;
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindowViews::WindowBoundsToContentBounds(
|
||||
const gfx::Rect& bounds) const {
|
||||
if (!has_frame())
|
||||
return bounds;
|
||||
|
||||
gfx::Rect content_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
content_bounds.set_size(
|
||||
display::win::ScreenWin::DIPToScreenSize(hwnd, content_bounds.size()));
|
||||
RECT rect;
|
||||
SetRectEmpty(&rect);
|
||||
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
||||
DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
|
||||
content_bounds.set_width(content_bounds.width() - (rect.right - rect.left));
|
||||
content_bounds.set_height(content_bounds.height() - (rect.bottom - rect.top));
|
||||
content_bounds.set_size(
|
||||
display::win::ScreenWin::ScreenToDIPSize(hwnd, content_bounds.size()));
|
||||
#endif
|
||||
|
||||
if (menu_bar_ && menu_bar_visible_) {
|
||||
content_bounds.set_y(content_bounds.y() + kMenuBarHeight);
|
||||
content_bounds.set_height(content_bounds.height() - kMenuBarHeight);
|
||||
}
|
||||
return content_bounds;
|
||||
}
|
||||
|
||||
void NativeWindowViews::HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
|
|
|
@ -126,6 +126,12 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget() const override;
|
||||
|
||||
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;
|
||||
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;
|
||||
void UpdateDraggableRegions(
|
||||
content::RenderFrameHost* rfh,
|
||||
const std::vector<DraggableRegion>& regions) override;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void SetIcon(HICON small_icon, HICON app_icon);
|
||||
#elif defined(USE_X11)
|
||||
|
@ -135,6 +141,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetEnabled(bool enable) override;
|
||||
|
||||
views::Widget* widget() const { return window_.get(); }
|
||||
SkRegion* draggable_region() const { return draggable_region_.get(); }
|
||||
|
||||
#if defined(OS_WIN)
|
||||
TaskbarHost& taskbar_host() { return taskbar_host_; }
|
||||
|
@ -183,8 +190,6 @@ class NativeWindowViews : public NativeWindow,
|
|||
#endif
|
||||
|
||||
// NativeWindow:
|
||||
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;
|
||||
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;
|
||||
void HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
|
@ -289,6 +294,10 @@ class NativeWindowViews : public NativeWindow,
|
|||
// Map from accelerator to menu item's command id.
|
||||
accelerator_util::AcceleratorTable accelerator_table_;
|
||||
|
||||
// For custom drag, the whole window is non-draggable and the draggable region
|
||||
// has to been explicitly provided.
|
||||
std::unique_ptr<SkRegion> draggable_region_; // used in custom drag.
|
||||
|
||||
// How many times the Disable has been called.
|
||||
int disable_count_;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче