mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* refactor: precache the IsWindowStateEvent() atom XAtoms never change after creation so we can perload the atoms we need. This is useful in WindowStateWatcher's XEvent handler, which is called on every XEvent, e.g. mouse movement... * empty commit for ci
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
namespace electron {
|
||||
|
||||
WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
|
||||
: window_(window), widget_(window->GetAcceleratedWidget()) {
|
||||
: window_(window),
|
||||
widget_(window->GetAcceleratedWidget()),
|
||||
window_state_atom_(gfx::GetAtom("_NET_WM_STATE")) {
|
||||
ui::X11EventSource::GetInstance()->AddXEventObserver(this);
|
||||
}
|
||||
|
||||
@@ -54,9 +56,8 @@ void WindowStateWatcher::DidProcessXEvent(XEvent* xev) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WindowStateWatcher::IsWindowStateEvent(XEvent* xev) {
|
||||
::Atom changed_atom = xev->xproperty.atom;
|
||||
return (changed_atom == gfx::GetAtom("_NET_WM_STATE") &&
|
||||
bool WindowStateWatcher::IsWindowStateEvent(XEvent* xev) const {
|
||||
return (xev->xproperty.atom == window_state_atom_ &&
|
||||
xev->type == PropertyNotify && xev->xproperty.window == widget_);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,11 @@ class WindowStateWatcher : public ui::XEventObserver {
|
||||
void DidProcessXEvent(XEvent* xev) override;
|
||||
|
||||
private:
|
||||
bool IsWindowStateEvent(XEvent* xev);
|
||||
bool IsWindowStateEvent(XEvent* xev) const;
|
||||
|
||||
NativeWindowViews* window_;
|
||||
gfx::AcceleratedWidget widget_;
|
||||
const ::XAtom window_state_atom_;
|
||||
|
||||
bool was_minimized_ = false;
|
||||
bool was_maximized_ = false;
|
||||
|
||||
Reference in New Issue
Block a user