Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Provide handler to remove border for frameless windows (Win32 only)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsclifton authored and bbondy committed Dec 29, 2016
1 parent b4ae045 commit d0c07b9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
17 changes: 15 additions & 2 deletions atom/browser/native_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ NativeWindowViews::NativeWindowViews(

if (enable_larger_than_screen())
// We need to set a default maximum window size here otherwise Windows
// will not allow us to resize the window larger than scree.
// Setting directly to INT_MAX somehow doesn't work, so we just devide
// will not allow us to resize the window larger than screen.
// Setting directly to INT_MAX somehow doesn't work, so we just divide
// by 10, which should still be large enough.
SetContentSizeConstraints(extensions::SizeConstraints(
gfx::Size(), gfx::Size(INT_MAX / 10, INT_MAX / 10)));
Expand Down Expand Up @@ -201,6 +201,19 @@ NativeWindowViews::NativeWindowViews(
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;

#if defined(OS_WIN)
/** Registers handlers used to:
* - listen for windows events via PreHandleMSG
* - events include WM_GETOBJECT / WM_COMMAND / WM_SIZE / WM_MOVING / WM_MOVE
* - \see src/electron/atom/browser/native_window_views_win.cc
* - override the client area inset
* - used to force border of 0 for frameless windows
* - \see src/electron/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc
*
* Important things to note:
* - views::Widget is located in Chromium at src/ui/views/widget/widget.cc
* - Widget acts as a proxy for DesktopNativeWidgetAura (it passes calls through)
* - DesktopNativeWidgetAura then calls AtomDesktopWindowTreeHostWin as needed
*/
if (parent)
params.parent = parent->GetNativeWindow();

Expand Down
13 changes: 12 additions & 1 deletion atom/browser/ui/win/atom_desktop_window_tree_host_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ AtomDesktopWindowTreeHostWin::AtomDesktopWindowTreeHostWin(

AtomDesktopWindowTreeHostWin::~AtomDesktopWindowTreeHostWin() {
}

/** Route Windows messages to delegate (NativeWindowViews)
* \see src/electron/atom/browser/native_window_views_win.cc
* \see src/electron/atom/browser/native_window_views.cc
*/
bool AtomDesktopWindowTreeHostWin::PreHandleMSG(
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
return delegate_->PreHandleMSG(message, w_param, l_param, result);
}

/** Override the client area inset
* Returning true forces a border of 0 for frameless windows
*/
bool AtomDesktopWindowTreeHostWin::GetClientAreaInsets(
gfx::Insets* insets) const {
return !HasFrame();
}

} // namespace atom
1 change: 1 addition & 0 deletions atom/browser/ui/win/atom_desktop_window_tree_host_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
protected:
bool PreHandleMSG(
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
bool GetClientAreaInsets(gfx::Insets* insets) const override;

private:
MessageHandlerDelegate* delegate_; // weak ref
Expand Down

0 comments on commit d0c07b9

Please sign in to comment.