/
electron_desktop_window_tree_host_win.cc
56 lines (46 loc) · 2.13 KB
/
electron_desktop_window_tree_host_win.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/ui/win/electron_desktop_window_tree_host_win.h"
#include "ui/base/win/hwnd_metrics.h"
namespace electron {
ElectronDesktopWindowTreeHostWin::ElectronDesktopWindowTreeHostWin(
NativeWindowViews* native_window_view,
views::DesktopNativeWidgetAura* desktop_native_widget_aura)
: views::DesktopWindowTreeHostWin(native_window_view->widget(),
desktop_native_widget_aura),
native_window_view_(native_window_view) {}
ElectronDesktopWindowTreeHostWin::~ElectronDesktopWindowTreeHostWin() {}
bool ElectronDesktopWindowTreeHostWin::PreHandleMSG(UINT message,
WPARAM w_param,
LPARAM l_param,
LRESULT* result) {
return native_window_view_->PreHandleMSG(message, w_param, l_param, result);
}
bool ElectronDesktopWindowTreeHostWin::ShouldPaintAsActive() const {
// Tell Chromium to use system default behavior when rendering inactive
// titlebar, otherwise it would render inactive titlebar as active under
// some cases.
// See also https://github.com/electron/electron/issues/24647.
return false;
}
bool ElectronDesktopWindowTreeHostWin::HasNativeFrame() const {
// Since we never use chromium's titlebar implementation, we can just say
// that we use a native titlebar. This will disable the repaint locking when
// DWM composition is disabled.
return true;
}
bool ElectronDesktopWindowTreeHostWin::GetClientAreaInsets(
gfx::Insets* insets,
HMONITOR monitor) const {
if (IsMaximized() && !native_window_view_->has_frame()) {
// Windows automatically adds a standard width border to all sides when a
// window is maximized.
int frame_thickness = ui::GetFrameThickness(monitor) - 1;
*insets = gfx::Insets(frame_thickness, frame_thickness, frame_thickness,
frame_thickness);
return true;
}
return false;
}
} // namespace electron