-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(effect): add deleted ref helper
This simplifies referencing windows by effects on deletion.
- Loading branch information
Showing
12 changed files
with
91 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
SPDX-FileCopyrightText: 2023 Roman Gilg <[email protected]> | ||
SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
#pragma once | ||
|
||
#include <kwineffects/effect_window.h> | ||
|
||
namespace KWin | ||
{ | ||
|
||
class EffectWindow; | ||
|
||
/** | ||
* The EffectWindowDeletedRef provides a convenient way to prevent deleting a closed | ||
* window until an effect has finished animating it. | ||
*/ | ||
class EffectWindowDeletedRef | ||
{ | ||
public: | ||
EffectWindowDeletedRef() | ||
: m_window(nullptr) | ||
{ | ||
} | ||
|
||
explicit EffectWindowDeletedRef(EffectWindow* window) | ||
: m_window(window) | ||
{ | ||
m_window->refWindow(); | ||
} | ||
|
||
EffectWindowDeletedRef(EffectWindowDeletedRef const& other) | ||
: m_window(other.m_window) | ||
{ | ||
if (m_window) { | ||
m_window->refWindow(); | ||
} | ||
} | ||
|
||
~EffectWindowDeletedRef() | ||
{ | ||
if (m_window) { | ||
m_window->unrefWindow(); | ||
} | ||
} | ||
|
||
EffectWindowDeletedRef& operator=(EffectWindowDeletedRef const& other) | ||
{ | ||
if (other.m_window) { | ||
other.m_window->refWindow(); | ||
} | ||
if (m_window) { | ||
m_window->unrefWindow(); | ||
} | ||
m_window = other.m_window; | ||
return *this; | ||
} | ||
|
||
bool isNull() const | ||
{ | ||
return m_window == nullptr; | ||
} | ||
|
||
private: | ||
EffectWindow* m_window; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters