refactor: precache the IsWindowStateEvent() XAtom (#22706)
* 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:
parent
5e4e50c5eb
commit
83d5833b4f
2 changed files with 7 additions and 5 deletions
|
@ -9,7 +9,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);
|
||||
}
|
||||
|
||||
|
@ -53,9 +55,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;
|
||||
|
|
Loading…
Add table
Reference in a new issue