Run clang-tidy with -checks=readability-braces-around-statements fixit

This fixes style issues in old code.
icc-effect-5.26.4
Vlad Zahorodnii 2022-03-25 14:20:32 +02:00
parent 0d223742ab
commit e293972eaa
95 changed files with 3421 additions and 1862 deletions

View File

@ -370,8 +370,9 @@ void KeyboardLayoutTest::testVirtualDesktopPolicy()
QCOMPARE(desktops.at(desktop), VirtualDesktopManager::self()->currentDesktop());
layout = (desktop + 1) % xkb->numberOfLayouts();
QCOMPARE(xkb->currentLayout(), layout);
if (--desktop >= VirtualDesktopManager::self()->count()) // overflow
if (--desktop >= VirtualDesktopManager::self()->count()) { // overflow
break;
}
VirtualDesktopManager::self()->setCurrent(desktops.at(desktop));
}

View File

@ -247,10 +247,11 @@ void NoGlobalShortcutsTest::testAxisShortcut()
// try to trigger the shortcut
quint32 timestamp = 1;
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
if (direction == Qt::Vertical)
if (direction == Qt::Vertical) {
Test::pointerAxisVertical(sign * 5.0, timestamp++);
else
} else {
Test::pointerAxisHorizontal(sign * 5.0, timestamp++);
}
QCoreApplication::instance()->processEvents();
QCOMPARE(actionSpy.count(), 0);
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);

View File

@ -29,8 +29,9 @@ struct ProcessKillBeforeDeleter
{
static inline void cleanup(QProcess *pointer)
{
if (pointer)
if (pointer) {
pointer->kill();
}
delete pointer;
}
};

View File

@ -96,14 +96,18 @@ void WindowQuadListTest::testMakeGrid()
auto vertexTest = [actualQuad, expectedQuad](int index) {
const KWin::WindowVertex &actualVertex = actualQuad[index];
const KWin::WindowVertex &expectedVertex = expectedQuad[index];
if (actualVertex.x() != expectedVertex.x())
if (actualVertex.x() != expectedVertex.x()) {
return false;
if (actualVertex.y() != expectedVertex.y())
}
if (actualVertex.y() != expectedVertex.y()) {
return false;
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u()))
}
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) {
return false;
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v()))
}
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) {
return false;
}
return true;
};
found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3);
@ -180,14 +184,18 @@ void WindowQuadListTest::testMakeRegularGrid()
auto vertexTest = [actualQuad, expectedQuad](int index) {
const KWin::WindowVertex &actualVertex = actualQuad[index];
const KWin::WindowVertex &expectedVertex = expectedQuad[index];
if (actualVertex.x() != expectedVertex.x())
if (actualVertex.x() != expectedVertex.x()) {
return false;
if (actualVertex.y() != expectedVertex.y())
}
if (actualVertex.y() != expectedVertex.y()) {
return false;
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u()))
}
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) {
return false;
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v()))
}
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) {
return false;
}
return true;
};
found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3);

View File

@ -17,8 +17,9 @@
int main(int argc, char *argv[])
{
if (argc != 2)
if (argc != 2) {
return 1;
}
QCoreApplication::setApplicationName("kwin_update_default_rules");
@ -42,8 +43,9 @@ int main(int argc, char *argv[])
KConfigGroup dcg2(&dest_cfg, QString::number(pos));
for (QMap<QString, QString>::ConstIterator it = entries.constBegin();
it != entries.constEnd();
++it)
++it) {
dcg2.writeEntry(it.key(), *it);
}
}
dcg.writeEntry("count", pos);
scg.sync();

File diff suppressed because it is too large Load Diff

View File

@ -217,11 +217,13 @@ namespace KWin
*/
void Workspace::setActiveClient(AbstractClient *c)
{
if (active_client == c)
if (active_client == c) {
return;
}
if (active_popup && active_popup_client != c && set_active_client_recursion == 0)
if (active_popup && active_popup_client != c && set_active_client_recursion == 0) {
closeActivePopup();
}
if (m_userActionsMenu->hasClient() && !m_userActionsMenu->isMenuClient(c) && set_active_client_recursion == 0) {
m_userActionsMenu->close();
}
@ -251,10 +253,11 @@ void Workspace::setActiveClient(AbstractClient *c)
}
updateToolWindows(false);
if (c)
if (c) {
disableGlobalShortcutsForClient(c->rules()->checkDisableGlobalShortcuts(false));
else
} else {
disableGlobalShortcutsForClient(false);
}
updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active
@ -299,15 +302,17 @@ void Workspace::activateClient(AbstractClient *c, bool force)
--block_focus;
}
#endif
if (c->isMinimized())
if (c->isMinimized()) {
c->unminimize();
}
// ensure the window is really visible - could eg. be a hidden utility window, see bug #348083
c->showClient();
// TODO force should perhaps allow this only if the window already contains the mouse
if (options->focusPolicyIsReasonable() || force)
if (options->focusPolicyIsReasonable() || force) {
requestFocus(c, force);
}
// Don't update user time for clients that have focus stealing workaround.
// As they usually belong to the current active window but fail to provide
@ -337,8 +342,9 @@ bool Workspace::requestFocus(AbstractClient *c, bool force)
bool Workspace::takeActivity(AbstractClient *c, ActivityFlags flags)
{
// the 'if ( c == active_client ) return;' optimization mustn't be done here
if (!focusChangeEnabled() && (c != active_client))
if (!focusChangeEnabled() && (c != active_client)) {
flags &= ~ActivityFocus;
}
if (!c) {
focusToNull();
@ -351,14 +357,16 @@ bool Workspace::takeActivity(AbstractClient *c, ActivityFlags flags)
if (modal->desktops() != c->desktops()) {
modal->setDesktops(c->desktops());
}
if (!modal->isShown() && !modal->isMinimized()) // forced desktop or utility window
if (!modal->isShown() && !modal->isMinimized()) { // forced desktop or utility window
activateClient(modal); // activating a minimized blocked window will unminimize its modal implicitly
}
// if the click was inside the window (i.e. handled is set),
// but it has a modal, there's no need to use handled mode, because
// the modal doesn't get the click anyway
// raising of the original window needs to be still done
if (flags & ActivityRaise)
if (flags & ActivityRaise) {
raiseClient(c);
}
c = modal;
}
cancelDelayFocus();
@ -385,10 +393,12 @@ bool Workspace::takeActivity(AbstractClient *c, ActivityFlags flags)
bool ret = true;
if (flags & ActivityFocus)
if (flags & ActivityFocus) {
ret &= c->takeFocus();
if (flags & ActivityRaise)
}
if (flags & ActivityRaise) {
workspace()->raiseClient(c);
}
if (!c->isOnActiveOutput()) {
setActiveOutput(c->output());
@ -421,8 +431,9 @@ AbstractClient *Workspace::clientUnderMouse(AbstractOutput *output) const
// rule out clients which are not really visible.
// the screen test is rather superfluous for xrandr & twinview since the geometry would differ -> TODO: might be dropped
if (!(client->isShown() && client->isOnCurrentDesktop() && client->isOnCurrentActivity() && client->isOnOutput(output) && !client->isShade()))
if (!(client->isShown() && client->isOnCurrentDesktop() && client->isOnCurrentActivity() && client->isOnOutput(output) && !client->isShade())) {
continue;
}
if (client->frameGeometry().contains(Cursors::self()->mouse()->pos())) {
return client;
@ -435,14 +446,16 @@ AbstractClient *Workspace::clientUnderMouse(AbstractOutput *output) const
bool Workspace::activateNextClient(AbstractClient *c)
{
// if 'c' is not the active or the to-become active one, do nothing
if (!(c == active_client || (should_get_focus.count() > 0 && c == should_get_focus.last())))
if (!(c == active_client || (should_get_focus.count() > 0 && c == should_get_focus.last()))) {
return false;
}
closeActivePopup();
if (c != nullptr) {
if (c == active_client)
if (c == active_client) {
setActiveClient(nullptr);
}
should_get_focus.removeAll(c);
}
@ -453,15 +466,17 @@ bool Workspace::activateNextClient(AbstractClient *c)
return true;
}
if (!options->focusPolicyIsReasonable())
if (!options->focusPolicyIsReasonable()) {
return false;
}
AbstractClient *get_focus = nullptr;
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
if (!get_focus && showingDesktop())
if (!get_focus && showingDesktop()) {
get_focus = findDesktop(true, desktop); // to not break the state
}
if (!get_focus && options->isNextFocusPrefersMouse()) {
get_focus = clientUnderMouse(c ? c->output() : workspace()->activeOutput());
@ -486,28 +501,33 @@ bool Workspace::activateNextClient(AbstractClient *c)
}
}
if (get_focus == nullptr) // last chance: focus the desktop
if (get_focus == nullptr) { // last chance: focus the desktop
get_focus = findDesktop(true, desktop);
}
if (get_focus != nullptr)
if (get_focus != nullptr) {
requestFocus(get_focus);
else
} else {
focusToNull();
}
return true;
}
void Workspace::switchToOutput(AbstractOutput *output)
{
if (!options->focusPolicyIsReasonable())
if (!options->focusPolicyIsReasonable()) {
return;
}
closeActivePopup();
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
AbstractClient *get_focus = FocusChain::self()->getForActivation(desktop, output);
if (get_focus == nullptr)
if (get_focus == nullptr) {
get_focus = findDesktop(true, desktop);
if (get_focus != nullptr && get_focus != mostRecentlyActivatedClient())
}
if (get_focus != nullptr && get_focus != mostRecentlyActivatedClient()) {
requestFocus(get_focus);
}
setActiveOutput(output);
}
@ -516,8 +536,9 @@ void Workspace::gotFocusIn(const AbstractClient *c)
if (should_get_focus.contains(const_cast<AbstractClient *>(c))) {
// remove also all sooner elements that should have got FocusIn,
// but didn't for some reason (and also won't anymore, because they were sooner)
while (should_get_focus.first() != c)
while (should_get_focus.first() != c) {
should_get_focus.pop_front();
}
should_get_focus.pop_front(); // remove 'c'
}
}
@ -552,37 +573,43 @@ bool Workspace::allowClientActivation(const KWin::AbstractClient *c, xcb_timesta
// 3 - high - new window gets focus only if it belongs to the active application,
// or when no window is currently active
// 4 - extreme - no window gets focus without user intervention
if (time == -1U)
if (time == -1U) {
time = c->userTime();
}
int level = c->rules()->checkFSP(options->focusStealingPreventionLevel());
if (sessionManager()->state() == SessionState::Saving && level <= FSP::Medium) { // <= normal
return true;
}
AbstractClient *ac = mostRecentlyActivatedClient();
if (focus_in) {
if (should_get_focus.contains(const_cast<AbstractClient *>(c)))
if (should_get_focus.contains(const_cast<AbstractClient *>(c))) {
return true; // FocusIn was result of KWin's action
}
// Before getting FocusIn, the active Client already
// got FocusOut, and therefore got deactivated.
ac = last_active_client;
}
if (time == 0) { // explicitly asked not to get focus
if (!c->rules()->checkAcceptFocus(false))
if (!c->rules()->checkAcceptFocus(false)) {
return false;
}
}
const int protection = ac ? ac->rules()->checkFPP(2) : 0;
// stealing is unconditionally allowed (NETWM behavior)
if (level == FSP::None || protection == FSP::None)
if (level == FSP::None || protection == FSP::None) {
return true;
}
// The active client "grabs" the focus or stealing is generally forbidden
if (level == FSP::Extreme || protection == FSP::Extreme)
if (level == FSP::Extreme || protection == FSP::Extreme) {
return false;
}
// Desktop switching is only allowed in the "no protection" case
if (!ignore_desktop && !c->isOnCurrentDesktop())
if (!ignore_desktop && !c->isOnCurrentDesktop()) {
return false; // allow only with level == 0
}
// No active client, it's ok to pass focus
// NOTICE that extreme protection needs to be handled before to allow protection on unmanged windows
@ -600,18 +627,21 @@ bool Workspace::allowClientActivation(const KWin::AbstractClient *c, xcb_timesta
return true;
}
if (!c->isOnCurrentDesktop()) // we allowed explicit self-activation across virtual desktops
if (!c->isOnCurrentDesktop()) { // we allowed explicit self-activation across virtual desktops
return false; // inside a client or if no client was active, but not otherwise
}
// High FPS, not intr-client change. Only allow if the active client has only minor interest
if (level > FSP::Medium && protection > FSP::Low)
if (level > FSP::Medium && protection > FSP::Low) {
return false;
}
if (time == -1U) { // no time known
qCDebug(KWIN_CORE) << "Activation: No timestamp at all";
// Only allow for Low protection unless active client has High interest in focus
if (level < FSP::Medium && protection < FSP::High)
if (level < FSP::Medium && protection < FSP::High) {
return true;
}
// no timestamp at all, don't activate - because there's also creation timestamp
// done on CreateNotify, this case should happen only in case application
// maps again already used window, i.e. this won't happen after app startup
@ -636,10 +666,12 @@ bool Workspace::allowFullClientRaising(const KWin::AbstractClient *c, xcb_timest
return true;
}
AbstractClient *ac = mostRecentlyActivatedClient();
if (level == 0) // none
if (level == 0) { // none
return true;
if (level == 4) // extreme
}
if (level == 4) { // extreme
return false;
}
if (ac == nullptr || ac->isDesktop()) {
qCDebug(KWIN_CORE) << "Raising: No client active, allowing";
return true; // no active client -> always allow
@ -649,8 +681,9 @@ bool Workspace::allowFullClientRaising(const KWin::AbstractClient *c, xcb_timest
qCDebug(KWIN_CORE) << "Raising: Belongs to active application";
return true;
}
if (level == 3) // high
if (level == 3) { // high
return false;
}
xcb_timestamp_t user_time = ac->userTime();
qCDebug(KWIN_CORE) << "Raising, compared:" << time << ":" << user_time
<< ":" << (NET::timestampCompare(time, user_time) >= 0);
@ -670,10 +703,11 @@ bool Workspace::restoreFocus()
// that was used by whoever caused the focus change, and therefore
// the attempt to restore the focus would fail due to old timestamp
updateXTime();
if (should_get_focus.count() > 0)
if (should_get_focus.count() > 0) {
return requestFocus(should_get_focus.last());
else if (last_active_client)
} else if (last_active_client) {
return requestFocus(last_active_client);
}
return true;
}
@ -682,8 +716,9 @@ void Workspace::clientAttentionChanged(AbstractClient *c, bool set)
if (set) {
attention_chain.removeAll(c);
attention_chain.prepend(c);
} else
} else {
attention_chain.removeAll(c);
}
Q_EMIT clientDemandsAttentionChanged(c, set);
}
@ -763,16 +798,18 @@ xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id
}
return ret;
};
if (act->hasTransient(this, true))
if (act->hasTransient(this, true)) {
; // is transient for currently active window, even though it's not
// the same app (e.g. kcookiejar dialog) -> allow activation
else if (groupTransient() && findInList<X11Client, X11Client>(clientMainClients(), sameApplicationActiveHackPredicate) == nullptr)
} else if (groupTransient() && findInList<X11Client, X11Client>(clientMainClients(), sameApplicationActiveHackPredicate) == nullptr) {
; // standalone transient
else
} else {
first_window = false;
}
} else {
if (workspace()->findClient(sameApplicationActiveHackPredicate))
if (workspace()->findClient(sameApplicationActiveHackPredicate)) {
first_window = false;
}
}
// don't refuse if focus stealing prevention is turned off
if (!first_window && rules()->checkFSP(options->focusStealingPreventionLevel()) > 0) {
@ -789,8 +826,9 @@ xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id
// Unless it was the active window at the time
// of session saving and there was no user interaction yet,
// this check will be done in manage().
if (session)
if (session) {
return -1U;
}
time = readUserCreationTime();
}
qCDebug(KWIN_CORE) << "User timestamp, final:" << this << ":" << time;
@ -800,13 +838,15 @@ xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id
xcb_timestamp_t X11Client::userTime() const
{
xcb_timestamp_t time = m_userTime;
if (time == 0) // doesn't want focus after showing
if (time == 0) { // doesn't want focus after showing
return 0;
}
Q_ASSERT(group() != nullptr);
if (time == -1U
|| (group()->userTime() != -1U
&& NET::timestampCompare(group()->userTime(), time) > 0))
&& NET::timestampCompare(group()->userTime(), time) > 0)) {
time = group()->userTime();
}
return time;
}
@ -821,16 +861,19 @@ void X11Client::startupIdChanged()
KStartupInfoId asn_id;
KStartupInfoData asn_data;
bool asn_valid = workspace()->checkStartupNotification(window(), asn_id, asn_data);
if (!asn_valid)
if (!asn_valid) {
return;
}
// If the ASN contains desktop, move it to the desktop, otherwise move it to the current
// desktop (since the new ASN should make the window act like if it's a new application
// launched). However don't affect the window's desktop if it's set to be on all desktops.
int desktop = VirtualDesktopManager::self()->current();
if (asn_data.desktop() != 0)
if (asn_data.desktop() != 0) {
desktop = asn_data.desktop();
if (!isOnAllDesktops())
}
if (!isOnAllDesktops()) {
workspace()->sendClientToDesktop(this, desktop, true);
}
if (asn_data.xinerama() != -1) {
AbstractOutput *output = kwinApp()->platform()->findOutput(asn_data.xinerama());
if (output) {
@ -840,19 +883,22 @@ void X11Client::startupIdChanged()
const xcb_timestamp_t timestamp = asn_id.timestamp();
if (timestamp != 0) {
bool activate = workspace()->allowClientActivation(this, timestamp);
if (asn_data.desktop() != 0 && !isOnCurrentDesktop())
if (asn_data.desktop() != 0 && !isOnCurrentDesktop()) {
activate = false; // it was started on different desktop than current one
if (activate)
}
if (activate) {
workspace()->activateClient(this);
else
} else {
demandAttention();
}
}
}
void X11Client::updateUrgency()
{
if (info->urgency())
if (info->urgency()) {
demandAttention();
}
}
//****************************************
@ -864,8 +910,9 @@ void Group::startupIdChanged()
KStartupInfoId asn_id;
KStartupInfoData asn_data;
bool asn_valid = workspace()->checkStartupNotification(leader_wid, asn_id, asn_data);
if (!asn_valid)
if (!asn_valid) {
return;
}
if (asn_id.timestamp() != 0 && user_time != -1U
&& NET::timestampCompare(asn_id.timestamp(), user_time) > 0) {
user_time = asn_id.timestamp();
@ -881,8 +928,9 @@ void Group::updateUserTime(xcb_timestamp_t time)
}
if (time != -1U
&& (user_time == XCB_CURRENT_TIME
|| NET::timestampCompare(time, user_time) > 0)) // time > user_time
|| NET::timestampCompare(time, user_time) > 0)) { // time > user_time
user_time = time;
}
}
} // namespace

View File

@ -62,8 +62,9 @@ void Activities::slotRemoved(const QString &activity)
{
const auto clients = Workspace::self()->allClientList();
for (auto *const client : clients) {
if (client->isDesktop())
if (client->isDesktop()) {
continue;
}
client->setOnActivity(activity, false);
}
// toss out any session data for it
@ -79,19 +80,22 @@ void Activities::toggleClientOnActivity(AbstractClient *c, const QString &activi
// note: all activities === no activities
bool enable = was_on_all || !was_on_activity;
c->setOnActivity(activity, enable);
if (c->isOnActivity(activity) == was_on_activity && c->isOnAllActivities() == was_on_all) // No change
if (c->isOnActivity(activity) == was_on_activity && c->isOnAllActivities() == was_on_all) { // No change
return;
}
Workspace *ws = Workspace::self();
if (c->isOnCurrentActivity()) {
if (c->wantsTabFocus() && options->focusPolicyIsReasonable() && !was_on_activity && // for stickyness changes
// FIXME not sure if the line above refers to the correct activity
!dont_activate)
!dont_activate) {
ws->requestFocus(c);
else
} else {
ws->restackClientUnderActive(c);
} else
}
} else {
ws->raiseClient(c);
}
// notifyWindowDesktopChanged( c, old_desktop );
@ -144,8 +148,9 @@ bool Activities::stop(const QString &id)
void Activities::reallyStop(const QString &id)
{
Workspace *ws = Workspace::self();
if (ws->sessionManager()->state() == SessionState::Saving)
if (ws->sessionManager()->state() == SessionState::Saving) {
return; // ksmserver doesn't queue requests (yet)
}
qCDebug(KWIN_CORE) << id;
@ -153,8 +158,9 @@ void Activities::reallyStop(const QString &id)
QSet<QByteArray> dontCloseSessionIds;
const auto clients = ws->allClientList();
for (auto *const c : clients) {
if (c->isDesktop())
if (c->isDesktop()) {
continue;
}
const QByteArray sessionId = c->sessionId();
if (sessionId.isEmpty()) {
continue; // TODO support old wm_command apps too?

View File

@ -64,8 +64,9 @@ bool EglGbmBackend::initializeEgl()
}
}
if (display == EGL_NO_DISPLAY)
if (display == EGL_NO_DISPLAY) {
return false;
}
setEglDisplay(display);
return initEglAPI();
}

View File

@ -174,8 +174,9 @@ bool EglWaylandBackend::initializeEgl()
m_havePlatformBase = hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_base"));
if (m_havePlatformBase) {
// Make sure that the wayland platform is supported
if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_wayland")))
if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_wayland"))) {
return false;
}
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_WAYLAND_EXT, m_backend->display(), nullptr);
} else {
@ -183,8 +184,9 @@ bool EglWaylandBackend::initializeEgl()
}
}
if (display == EGL_NO_DISPLAY)
if (display == EGL_NO_DISPLAY) {
return false;
}
setEglDisplay(display);
return initEglAPI();
}

View File

@ -45,8 +45,9 @@ EffectsHandlerImplX11::~EffectsHandlerImplX11()
bool EffectsHandlerImplX11::doGrabKeyboard()
{
bool ret = grabXKeyboard();
if (!ret)
if (!ret) {
return false;
}
// Workaround for Qt 5.9 regression introduced with 2b34aefcf02f09253473b096eb4faffd3e62b5f4
// we no longer get any events for the root window, one needs to call winId() on the desktop window
// TODO: change effects event handling to create the appropriate QKeyEvent without relying on Qt

View File

@ -139,14 +139,17 @@ GlxBackend::~GlxBackend()
cleanupGL();
doneCurrent();
if (ctx)
if (ctx) {
glXDestroyContext(display(), ctx);
}
if (glxWindow)
if (glxWindow) {
glXDestroyWindow(display(), glxWindow);
}
if (window)
if (window) {
XDestroyWindow(display(), window);
}
qDeleteAll(m_fbconfigHash);
m_fbconfigHash.clear();
@ -164,8 +167,9 @@ static glXFuncPtr getProcAddress(const char *name)
ret = glXGetProcAddress((const GLubyte *)name);
#endif
#if HAVE_DL_LIBRARY
if (ret == nullptr)
if (ret == nullptr) {
ret = (glXFuncPtr)dlsym(RTLD_DEFAULT, name);
}
#endif
return ret;
}
@ -204,8 +208,9 @@ void GlxBackend::init()
GLPlatform *glPlatform = GLPlatform::instance();
glPlatform->detect(GlxPlatformInterface);
options->setGlPreferBufferSwap(options->glPreferBufferSwap()); // resolve autosetting
if (options->glPreferBufferSwap() == Options::AutoSwapStrategy)
if (options->glPreferBufferSwap() == Options::AutoSwapStrategy) {
options->setGlPreferBufferSwap('e'); // for unknown drivers - should not happen
}
glPlatform->printResults();
initGL(&getProcAddress);
@ -238,8 +243,9 @@ void GlxBackend::init()
if (hasExtension(QByteArrayLiteral("GLX_EXT_buffer_age"))) {
const QByteArray useBufferAge = qgetenv("KWIN_USE_BUFFER_AGE");
if (useBufferAge != "0")
if (useBufferAge != "0") {
setSupportsBufferAge(true);
}
}
// If the buffer age extension is unsupported, glXSwapBuffers() is not guaranteed to
@ -397,8 +403,9 @@ bool GlxBackend::initRenderingContext()
}
}
if (!ctx)
if (!ctx) {
ctx = glXCreateNewContext(display(), fbconfig, GLX_RGBA_TYPE, globalShareContext, direct);
}
if (!ctx) {
qCDebug(KWIN_X11STANDALONE) << "Failed to create an OpenGL context.";
@ -417,8 +424,9 @@ bool GlxBackend::initRenderingContext()
bool GlxBackend::initBuffer()
{
if (!initFbConfig())
if (!initFbConfig()) {
return false;
}
if (overlayWindow()->create()) {
xcb_connection_t *const c = connection();
@ -520,8 +528,9 @@ void GlxBackend::initVisualDepthHashTable()
const int len = xcb_depth_visuals_length(depth.data);
const xcb_visualtype_t *visuals = xcb_depth_visuals(depth.data);
for (int i = 0; i < len; i++)
for (int i = 0; i < len; i++) {
m_visualDepthHash.insert(visuals[i].visual_id, depth.data->depth);
}
}
}
}
@ -619,44 +628,51 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual)
glXGetFBConfigAttrib(display(), configs[i], GLX_GREEN_SIZE, &green);
glXGetFBConfigAttrib(display(), configs[i], GLX_BLUE_SIZE, &blue);
if (std::tie(red, green, blue) != rgb_sizes)
if (std::tie(red, green, blue) != rgb_sizes) {
continue;
}
xcb_visualid_t visual;
glXGetFBConfigAttrib(display(), configs[i], GLX_VISUAL_ID, (int *)&visual);
if (visualDepth(visual) != depth)
if (visualDepth(visual) != depth) {
continue;
}
int bind_rgb, bind_rgba;
glXGetFBConfigAttrib(display(), configs[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, &bind_rgba);
glXGetFBConfigAttrib(display(), configs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &bind_rgb);
if (!bind_rgb && !bind_rgba)
if (!bind_rgb && !bind_rgba) {
continue;
}
int depth, stencil;
glXGetFBConfigAttrib(display(), configs[i], GLX_DEPTH_SIZE, &depth);
glXGetFBConfigAttrib(display(), configs[i], GLX_STENCIL_SIZE, &stencil);
int texture_format;
if (alpha_bits)
if (alpha_bits) {
texture_format = bind_rgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT;
else
} else {
texture_format = bind_rgb ? GLX_TEXTURE_FORMAT_RGB_EXT : GLX_TEXTURE_FORMAT_RGBA_EXT;
}
candidates.emplace_back(FBConfig{configs[i], depth, stencil, texture_format});
}
if (count > 0)
if (count > 0) {
XFree(configs);
}
std::stable_sort(candidates.begin(), candidates.end(), [](const FBConfig &left, const FBConfig &right) {
if (left.depth < right.depth)
if (left.depth < right.depth) {
return true;
}
if (left.stencil < right.stencil)
if (left.stencil < right.stencil) {
return true;
}
return false;
});
@ -690,12 +706,13 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual)
void GlxBackend::setSwapInterval(int interval)
{
if (m_haveEXTSwapControl)
if (m_haveEXTSwapControl) {
glXSwapIntervalEXT(display(), glxWindow, interval);
else if (m_haveMESASwapControl)
} else if (m_haveMESASwapControl) {
glXSwapIntervalMESA(interval);
else if (m_haveSGISwapControl)
} else if (m_haveSGISwapControl) {
glXSwapIntervalSGI(interval);
}
}
void GlxBackend::present(const QRegion &damage)
@ -787,8 +804,9 @@ void GlxBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegion,
present(effectiveRenderedRegion);
if (overlayWindow()->window()) // show the window only after the first pass,
if (overlayWindow()->window()) { // show the window only after the first pass,
overlayWindow()->show(); // since that pass may take long
}
// Save the damaged region to history
if (supportsBufferAge()) {
@ -883,12 +901,14 @@ void GlxPixmapTexturePrivate::onDamage()
bool GlxPixmapTexturePrivate::create(SurfacePixmapX11 *texture)
{
if (texture->pixmap() == XCB_NONE || texture->size().isEmpty() || texture->visual() == XCB_NONE)
if (texture->pixmap() == XCB_NONE || texture->size().isEmpty() || texture->visual() == XCB_NONE) {
return false;
}
const FBConfigInfo *info = m_backend->infoForVisual(texture->visual());
if (!info || info->fbconfig == nullptr)
if (!info || info->fbconfig == nullptr) {
return false;
}
if (info->texture_targets & GLX_TEXTURE_2D_BIT_EXT) {
m_target = GL_TEXTURE_2D;

View File

@ -42,18 +42,21 @@ OverlayWindowX11::~OverlayWindowX11()
bool OverlayWindowX11::create()
{
Q_ASSERT(m_window == XCB_WINDOW_NONE);
if (!Xcb::Extensions::self()->isCompositeOverlayAvailable())
if (!Xcb::Extensions::self()->isCompositeOverlayAvailable()) {
return false;
if (!Xcb::Extensions::self()->isShapeInputAvailable()) // needed in setupOverlay()
}
if (!Xcb::Extensions::self()->isShapeInputAvailable()) { // needed in setupOverlay()
return false;
}
#ifdef KWIN_HAVE_XCOMPOSITE_OVERLAY
Xcb::OverlayWindow overlay(rootWindow());
if (overlay.isNull()) {
return false;
}
m_window = overlay->overlay_win;
if (m_window == XCB_WINDOW_NONE)
if (m_window == XCB_WINDOW_NONE) {
return false;
}
resize(screens()->size());
return true;
#else
@ -91,8 +94,9 @@ void OverlayWindowX11::setNoneBackgroundPixmap(xcb_window_t window)
void OverlayWindowX11::show()
{
Q_ASSERT(m_window != XCB_WINDOW_NONE);
if (m_shown)
if (m_shown) {
return;
}
xcb_map_subwindows(connection(), m_window);
xcb_map_window(connection(), m_window);
m_shown = true;
@ -111,8 +115,9 @@ void OverlayWindowX11::setShape(const QRegion &reg)
{
// Avoid setting the same shape again, it causes flicker (apparently it is not a no-op
// and triggers something).
if (reg == m_shape)
if (reg == m_shape) {
return;
}
const QVector<xcb_rectangle_t> xrects = Xcb::regionToRects(reg);
xcb_shape_rectangles(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
m_window, 0, 0, xrects.count(), xrects.data());
@ -142,8 +147,9 @@ void OverlayWindowX11::setVisibility(bool visible)
void OverlayWindowX11::destroy()
{
if (m_window == XCB_WINDOW_NONE)
if (m_window == XCB_WINDOW_NONE) {
return;
}
// reset the overlay shape
const QSize &s = screens()->size();
xcb_rectangle_t rec = {0, 0, static_cast<uint16_t>(s.width()), static_cast<uint16_t>(s.height())};

View File

@ -215,11 +215,12 @@ QString X11StandalonePlatform::compositingNotPossibleReason() const
// first off, check whether we figured that we'll crash on detection because of a buggy driver
KConfigGroup gl_workaround_group(kwinApp()->config(), "Compositing");
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (kwinApp()->isX11MultiHead() ? QString::number(kwinApp()->x11ScreenNumber()) : QString()));
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") && gl_workaround_group.readEntry(unsafeKey, false))
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") && gl_workaround_group.readEntry(unsafeKey, false)) {
return i18n("<b>OpenGL compositing (the default) has crashed KWin in the past.</b><br>"
"This was most likely due to a driver bug."
"<p>If you think that you have meanwhile upgraded to a stable driver,<br>"
"you can reset this protection but <b>be aware that this might result in an immediate crash!</b></p>");
}
if (!Xcb::Extensions::self()->isCompositeAvailable() || !Xcb::Extensions::self()->isDamageAvailable()) {
return i18n("Required X extensions (XComposite and XDamage) are not available.");
@ -249,8 +250,9 @@ bool X11StandalonePlatform::compositingPossible() const
qCWarning(KWIN_X11STANDALONE) << "Compositing disabled: no damage extension available";
return false;
}
if (hasGlx())
if (hasGlx()) {
return true;
}
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
return true;
} else if (qstrcmp(qgetenv("KWIN_COMPOSE"), "O2ES") == 0) {
@ -506,10 +508,12 @@ void X11StandalonePlatform::doUpdateOutputs()
// refresh rate calculation - WTF was wikipedia 1998 when I needed it?
int dotclock = modes[j].dot_clock,
vtotal = modes[j].vtotal;
if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_INTERLACE)
if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_INTERLACE) {
dotclock *= 2;
if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_DOUBLE_SCAN)
}
if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_DOUBLE_SCAN) {
vtotal *= 2;
}
refreshRate = dotclock / float(modes[j].htotal * vtotal);
}
break; // found mode

View File

@ -983,12 +983,13 @@ void X11Compositor::updateClientCompositeBlocking(X11Client *c)
if (c) {
if (c->isBlockingCompositing()) {
// Do NOT attempt to call suspend(true) from within the eventchain!
if (!(m_suspended & BlockRuleSuspend))
if (!(m_suspended & BlockRuleSuspend)) {
QMetaObject::invokeMethod(
this, [this]() {
suspend(BlockRuleSuspend);
},
Qt::QueuedConnection);
}
}
} else if (m_suspended & BlockRuleSuspend) {
// If !c we just check if we can resume in case a blocking client was lost.

View File

@ -34,8 +34,9 @@ namespace KWin
Cursors *Cursors::s_self = nullptr;
Cursors *Cursors::self()
{
if (!s_self)
if (!s_self) {
s_self = new Cursors;
}
return s_self;
}
@ -54,10 +55,11 @@ void Cursors::removeCursor(Cursor *cursor)
{
m_cursors.removeOne(cursor);
if (m_currentCursor == cursor) {
if (m_cursors.isEmpty())
if (m_cursors.isEmpty()) {
m_currentCursor = nullptr;
else
} else {
setCurrentCursor(m_cursors.constFirst());
}
}
if (m_mouse == cursor) {
m_mouse = nullptr;
@ -87,8 +89,9 @@ bool Cursors::isCursorHidden() const
void Cursors::setCurrentCursor(Cursor *cursor)
{
if (m_currentCursor == cursor)
if (m_currentCursor == cursor) {
return;
}
Q_ASSERT(m_cursors.contains(cursor) || !cursor);
@ -686,8 +689,9 @@ QByteArray CursorShape::name() const
InputConfig *InputConfig::s_self = nullptr;
InputConfig *InputConfig::self()
{
if (!s_self)
if (!s_self) {
s_self = new InputConfig;
}
return s_self;
}

View File

@ -41,8 +41,9 @@ Deleted::Deleted()
Deleted::~Deleted()
{
if (delete_refcount != 0)
if (delete_refcount != 0) {
qCCritical(KWIN_CORE) << "Deleted client has non-zero reference count (" << delete_refcount << ")";
}
Q_ASSERT(delete_refcount == 0);
if (workspace()) {
workspace()->removeDeleted(this);
@ -80,8 +81,9 @@ void Deleted::copyToDeleted(Toplevel *c)
m_type = c->windowType();
m_windowRole = c->windowRole();
m_shade = c->isShade();
if (WinInfo *cinfo = dynamic_cast<WinInfo *>(info))
if (WinInfo *cinfo = dynamic_cast<WinInfo *>(info)) {
cinfo->disable();
}
if (AbstractClient *client = dynamic_cast<AbstractClient *>(c)) {
if (client->isDecorated()) {
client->layoutDecorationRects(decoration_left,
@ -115,8 +117,9 @@ void Deleted::copyToDeleted(Toplevel *c)
void Deleted::unrefWindow()
{
if (--delete_refcount > 0)
if (--delete_refcount > 0) {
return;
}
// needs to be delayed
// a) when calling from effects, otherwise it'd be rather complicated to handle the case of the
// window going away during a painting pass
@ -171,8 +174,9 @@ NET::WindowType Deleted::windowType(bool direct, int supportedTypes) const
void Deleted::mainClientClosed(Toplevel *client)
{
if (AbstractClient *c = dynamic_cast<AbstractClient *>(client))
if (AbstractClient *c = dynamic_cast<AbstractClient *>(client)) {
m_mainClients.removeAll(c);
}
}
xcb_window_t Deleted::frameId() const

View File

@ -156,10 +156,11 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
Q_EMIT desktopPresenceChanged(c->effectWindow(), old, c->desktop());
});
connect(ws, &Workspace::clientAdded, this, [this](AbstractClient *c) {
if (c->readyForPainting())
if (c->readyForPainting()) {
slotClientShown(c);
else
} else {
connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
}
});
connect(ws, &Workspace::unmanagedAdded, this, [this](Unmanaged *u) {
// it's never initially ready but has synthetic 50ms delay
@ -361,8 +362,9 @@ void EffectsHandlerImpl::paintScreen(int mask, const QRegion &region, ScreenPain
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
(*m_currentPaintScreenIterator++)->paintScreen(mask, region, data);
--m_currentPaintScreenIterator;
} else
} else {
m_scene->finalPaintScreen(mask, region, data);
}
}
void EffectsHandlerImpl::paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData &data)
@ -404,8 +406,9 @@ void EffectsHandlerImpl::paintWindow(EffectWindow *w, int mask, const QRegion &r
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
(*m_currentPaintWindowIterator++)->paintWindow(w, mask, region, data);
--m_currentPaintWindowIterator;
} else
} else {
m_scene->finalPaintWindow(static_cast<EffectWindowImpl *>(w), mask, region, data);
}
}
void EffectsHandlerImpl::paintEffectFrame(EffectFrame *frame, const QRegion &region, double opacity, double frameOpacity)
@ -430,9 +433,11 @@ void EffectsHandlerImpl::postPaintWindow(EffectWindow *w)
Effect *EffectsHandlerImpl::provides(Effect::Feature ef)
{
for (int i = 0; i < loaded_effects.size(); ++i)
if (loaded_effects.at(i).second->provides(ef))
for (int i = 0; i < loaded_effects.size(); ++i) {
if (loaded_effects.at(i).second->provides(ef)) {
return loaded_effects.at(i).second;
}
}
return nullptr;
}
@ -441,8 +446,9 @@ void EffectsHandlerImpl::drawWindow(EffectWindow *w, int mask, const QRegion &re
if (m_currentDrawWindowIterator != m_activeEffects.constEnd()) {
(*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data);
--m_currentDrawWindowIterator;
} else
} else {
m_scene->finalDrawWindow(static_cast<EffectWindowImpl *>(w), mask, region, data);
}
}
bool EffectsHandlerImpl::hasDecorationShadows() const
@ -562,8 +568,9 @@ void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel *t, const QRect &old)
{
// during late cleanup effectWindow() may be already NULL
// in some functions that may still call this
if (t == nullptr || t->effectWindow() == nullptr)
if (t == nullptr || t->effectWindow() == nullptr) {
return;
}
Q_EMIT windowGeometryShapeChanged(t->effectWindow(), old);
}
@ -600,8 +607,9 @@ bool EffectsHandlerImpl::hasActiveFullScreenEffect() const
bool EffectsHandlerImpl::grabKeyboard(Effect *effect)
{
if (keyboard_grab_effect != nullptr)
if (keyboard_grab_effect != nullptr) {
return false;
}
if (!doGrabKeyboard()) {
return false;
}
@ -627,8 +635,9 @@ void EffectsHandlerImpl::doUngrabKeyboard()
void EffectsHandlerImpl::grabbedKeyboardEvent(QKeyEvent *e)
{
if (keyboard_grab_effect != nullptr)
if (keyboard_grab_effect != nullptr) {
keyboard_grab_effect->grabbedKeyboardEvent(e);
}
}
void EffectsHandlerImpl::startMouseInterception(Effect *effect, Qt::CursorShape shape)
@ -799,23 +808,27 @@ void EffectsHandlerImpl::registerTouchscreenSwipeShortcut(SwipeDirection directi
void *EffectsHandlerImpl::getProxy(QString name)
{
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
if ((*it).first == name)
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
if ((*it).first == name) {
return (*it).second->proxy();
}
}
return nullptr;
}
void EffectsHandlerImpl::startMousePolling()
{
if (Cursors::self()->mouse())
if (Cursors::self()->mouse()) {
Cursors::self()->mouse()->startMousePolling();
}
}
void EffectsHandlerImpl::stopMousePolling()
{
if (Cursors::self()->mouse())
if (Cursors::self()->mouse()) {
Cursors::self()->mouse()->stopMousePolling();
}
}
bool EffectsHandlerImpl::hasKeyboardGrab() const
@ -825,11 +838,12 @@ bool EffectsHandlerImpl::hasKeyboardGrab() const
void EffectsHandlerImpl::registerPropertyType(long atom, bool reg)
{
if (reg)
if (reg) {
++registered_atoms[atom]; // initialized to 0 if not present yet
else {
if (--registered_atoms[atom] == 0)
} else {
if (--registered_atoms[atom] == 0) {
registered_atoms.remove(atom);
}
}
}
@ -900,13 +914,15 @@ EffectWindow *EffectsHandlerImpl::activeWindow() const
void EffectsHandlerImpl::moveWindow(EffectWindow *w, const QPoint &pos, bool snap, double snapAdjust)
{
auto cl = qobject_cast<AbstractClient *>(static_cast<EffectWindowImpl *>(w)->window());
if (!cl || !cl->isMovable())
if (!cl || !cl->isMovable()) {
return;
}
if (snap)
if (snap) {
cl->move(Workspace::self()->adjustClientPosition(cl, pos, true, snapAdjust));
else
} else {
cl->move(pos);
}
}
void EffectsHandlerImpl::windowToDesktop(EffectWindow *w, int desktop)
@ -1026,8 +1042,9 @@ QPoint EffectsHandlerImpl::desktopGridCoords(int id) const
QPoint EffectsHandlerImpl::desktopCoords(int id) const
{
QPoint coords = VirtualDesktopManager::self()->grid().gridCoords(id);
if (coords.x() == -1)
if (coords.x() == -1) {
return QPoint(-1, -1);
}
const QSize displaySize = Screens::self()->size();
return QPoint(coords.x() * displaySize.width(), coords.y() * displaySize.height());
}
@ -1070,10 +1087,12 @@ double EffectsHandlerImpl::animationTimeFactor() const
EffectWindow *EffectsHandlerImpl::findWindow(WId id) const
{
if (X11Client *w = Workspace::self()->findClient(Predicate::WindowMatch, id))
if (X11Client *w = Workspace::self()->findClient(Predicate::WindowMatch, id)) {
return w->effectWindow();
if (Unmanaged *w = Workspace::self()->findUnmanaged(id))
}
if (Unmanaged *w = Workspace::self()->findUnmanaged(id)) {
return w->effectWindow();
}
return nullptr;
}
@ -1115,8 +1134,9 @@ EffectWindowList EffectsHandlerImpl::stackingOrder() const
QList<Toplevel *> list = Workspace::self()->xStackingOrder();
EffectWindowList ret;
for (Toplevel *t : list) {
if (EffectWindow *w = effectWindow(t))
if (EffectWindow *w = effectWindow(t)) {
ret.append(w);
}
}
return ret;
}
@ -1124,8 +1144,9 @@ EffectWindowList EffectsHandlerImpl::stackingOrder() const
void EffectsHandlerImpl::setElevatedWindow(KWin::EffectWindow *w, bool set)
{
elevated_windows.removeAll(w);
if (set)
if (set) {
elevated_windows.append(w);
}
}
void EffectsHandlerImpl::setTabBoxWindow(EffectWindow *w)
@ -1207,8 +1228,9 @@ int EffectsHandlerImpl::currentTabBoxDesktop() const
EffectWindow *EffectsHandlerImpl::currentTabBoxWindow() const
{
#if KWIN_BUILD_TABBOX
if (auto c = TabBox::TabBox::self()->currentClient())
if (auto c = TabBox::TabBox::self()->currentClient()) {
return c->effectWindow();
}
#endif
return nullptr;
}
@ -1374,10 +1396,11 @@ QPainter *EffectsHandlerImpl::scenePainter()
void EffectsHandlerImpl::toggleEffect(const QString &name)
{
if (isEffectLoaded(name))
if (isEffectLoaded(name)) {
unloadEffect(name);
else
} else {
loadEffect(name);
}
}
QStringList EffectsHandlerImpl::loadedEffects() const
@ -1448,13 +1471,14 @@ void EffectsHandlerImpl::destroyEffect(Effect *effect)
void EffectsHandlerImpl::reconfigureEffect(const QString &name)
{
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
if ((*it).first == name) {
kwinApp()->config()->reparseConfiguration();
makeOpenGLContextCurrent();
(*it).second->reconfigure(Effect::ReconfigureAll);
return;
}
}
}
bool EffectsHandlerImpl::isEffectLoaded(const QString &name) const
@ -2202,10 +2226,11 @@ EffectWindowList EffectWindowImpl::mainWindows() const
void EffectWindowImpl::setData(int role, const QVariant &data)
{
if (!data.isNull())
if (!data.isNull()) {
dataMap[role] = data;
else
} else {
dataMap.remove(role);
}
Q_EMIT effects->windowDataChanged(this, role);
}
@ -2445,18 +2470,20 @@ Qt::Alignment EffectFrameImpl::alignment() const
void EffectFrameImpl::align(QRect &geometry)
{
if (m_alignment & Qt::AlignLeft)
if (m_alignment & Qt::AlignLeft) {
geometry.moveLeft(m_point.x());
else if (m_alignment & Qt::AlignRight)
} else if (m_alignment & Qt::AlignRight) {
geometry.moveLeft(m_point.x() - geometry.width());
else
} else {
geometry.moveLeft(m_point.x() - geometry.width() / 2);
if (m_alignment & Qt::AlignTop)
}
if (m_alignment & Qt::AlignTop) {
geometry.moveTop(m_point.y());
else if (m_alignment & Qt::AlignBottom)
} else if (m_alignment & Qt::AlignBottom) {
geometry.moveTop(m_point.y() - geometry.height());
else
} else {
geometry.moveTop(m_point.y() - geometry.height() / 2);
}
}
void EffectFrameImpl::setAlignment(Qt::Alignment alignment)
@ -2511,8 +2538,9 @@ void EffectFrameImpl::setSelection(const QRect &selection)
void EffectFrameImpl::autoResize()
{
if (m_static)
if (m_static) {
return; // Not automatically resizing
}
QRect geometry;
// Set size
@ -2522,8 +2550,9 @@ void EffectFrameImpl::autoResize()
}
if (!m_icon.isNull() && !m_iconSize.isEmpty()) {
geometry.setLeft(-m_iconSize.width());
if (m_iconSize.height() > geometry.height())
if (m_iconSize.height() > geometry.height()) {
geometry.setHeight(m_iconSize.height());
}
}
align(geometry);

View File

@ -644,8 +644,9 @@ private:
inline QList<EffectWindow *> EffectsHandlerImpl::elevatedWindows() const
{
if (isScreenLocked())
if (isScreenLocked()) {
return QList<EffectWindow *>();
}
return elevated_windows;
}

View File

@ -258,10 +258,12 @@ bool ContrastEffect::enabledByDefault()
{
GLPlatform *gl = GLPlatform::instance();
if (gl->isIntel() && gl->chipClass() < SandyBridge)
if (gl->isIntel() && gl->chipClass() < SandyBridge) {
return false;
if (gl->isPanfrost() && gl->chipClass() <= MaliT8XX)
}
if (gl->isPanfrost() && gl->chipClass() <= MaliT8XX) {
return false;
}
if (gl->isSoftwareEmulation()) {
return false;
}
@ -278,8 +280,9 @@ bool ContrastEffect::supported()
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
const QSize screenSize = effects->virtualScreenSize();
if (screenSize.width() > maxTexSize || screenSize.height() > maxTexSize)
if (screenSize.width() > maxTexSize || screenSize.height() > maxTexSize) {
supported = false;
}
}
return supported;
}
@ -326,8 +329,9 @@ void ContrastEffect::uploadRegion(QVector2D *&map, const QRegion &region)
void ContrastEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &region)
{
const int vertexCount = region.rectCount() * 6;
if (!vertexCount)
if (!vertexCount) {
return;
}
QVector2D *map = (QVector2D *)vbo->map(vertexCount * sizeof(QVector2D));
uploadRegion(map, region);
@ -342,23 +346,28 @@ void ContrastEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &region)
bool ContrastEffect::shouldContrast(const EffectWindow *w, int mask, const WindowPaintData &data) const
{
if (!shader || !shader->isValid())
if (!shader || !shader->isValid()) {
return false;
}
if (effects->activeFullScreenEffect() && !w->data(WindowForceBackgroundContrastRole).toBool())
if (effects->activeFullScreenEffect() && !w->data(WindowForceBackgroundContrastRole).toBool()) {
return false;
}
if (w->isDesktop())
if (w->isDesktop()) {
return false;
}
bool scaled = !qFuzzyCompare(data.xScale(), 1.0) && !qFuzzyCompare(data.yScale(), 1.0);
bool translated = data.xTranslation() || data.yTranslation();
if ((scaled || (translated || (mask & PAINT_WINDOW_TRANSFORMED))) && !w->data(WindowForceBackgroundContrastRole).toBool())
if ((scaled || (translated || (mask & PAINT_WINDOW_TRANSFORMED))) && !w->data(WindowForceBackgroundContrastRole).toBool()) {
return false;
}
if (!w->hasAlpha())
if (!w->hasAlpha()) {
return false;
}
return true;
}

View File

@ -61,8 +61,9 @@ float ContrastShader::opacity() const
void ContrastShader::setColorMatrix(const QMatrix4x4 &matrix)
{
if (!isValid())
if (!isValid()) {
return;
}
ShaderManager::instance()->pushShader(shader);
shader->setUniform(colorMatrixLocation, matrix);
@ -71,24 +72,27 @@ void ContrastShader::setColorMatrix(const QMatrix4x4 &matrix)
void ContrastShader::setTextureMatrix(const QMatrix4x4 &matrix)
{
if (!isValid())
if (!isValid()) {
return;
}
shader->setUniform(textureMatrixLocation, matrix);
}
void ContrastShader::setModelViewProjectionMatrix(const QMatrix4x4 &matrix)
{
if (!isValid())
if (!isValid()) {
return;
}
shader->setUniform(mvpMatrixLocation, matrix);
}
void ContrastShader::bind()
{
if (!isValid())
if (!isValid()) {
return;
}
ShaderManager::instance()->pushShader(shader);
}
@ -158,8 +162,9 @@ void ContrastShader::init()
stream2 << "uniform float opacity;\n";
stream2 << varying_in << " vec4 varyingTexCoords;\n";
if (core)
if (core) {
stream2 << "out vec4 fragColor;\n\n";
}
stream2 << "void main(void)\n";
stream2 << "{\n";

View File

@ -387,8 +387,9 @@ bool BlurEffect::enabledByDefault()
{
GLPlatform *gl = GLPlatform::instance();
if (gl->isIntel() && gl->chipClass() < SandyBridge)
if (gl->isIntel() && gl->chipClass() < SandyBridge) {
return false;
}
if (gl->isPanfrost() && gl->chipClass() <= MaliT8XX) {
return false;
}
@ -408,8 +409,9 @@ bool BlurEffect::supported()
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
const QSize screenSize = effects->virtualScreenSize();
if (screenSize.width() > maxTexSize || screenSize.height() > maxTexSize)
if (screenSize.width() > maxTexSize || screenSize.height() > maxTexSize) {
supported = false;
}
}
return supported;
}
@ -500,8 +502,9 @@ void BlurEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &blurRegion,
{
const int vertexCount = ((blurRegion.rectCount() * (m_downSampleIterations + 1)) + windowRegion.rectCount()) * 6;
if (!vertexCount)
if (!vertexCount) {
return;
}
QVector2D *map = (QVector2D *)vbo->map(vertexCount * sizeof(QVector2D));
@ -581,25 +584,30 @@ void BlurEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::
bool BlurEffect::shouldBlur(const EffectWindow *w, int mask, const WindowPaintData &data) const
{
if (!m_renderTargetsValid || !m_shader || !m_shader->isValid())
if (!m_renderTargetsValid || !m_shader || !m_shader->isValid()) {
return false;
}
if (effects->activeFullScreenEffect() && !w->data(WindowForceBlurRole).toBool())
if (effects->activeFullScreenEffect() && !w->data(WindowForceBlurRole).toBool()) {
return false;
}
if (w->isDesktop())
if (w->isDesktop()) {
return false;
}
bool scaled = !qFuzzyCompare(data.xScale(), 1.0) && !qFuzzyCompare(data.yScale(), 1.0);
bool translated = data.xTranslation() || data.yTranslation();
if ((scaled || (translated || (mask & PAINT_WINDOW_TRANSFORMED))) && !w->data(WindowForceBlurRole).toBool())
if ((scaled || (translated || (mask & PAINT_WINDOW_TRANSFORMED))) && !w->data(WindowForceBlurRole).toBool()) {
return false;
}
bool blurBehindDecos = effects->decorationsHaveAlpha() && decorationSupportsBlurBehind(w);
if (!w->hasAlpha() && w->opacity() >= 1.0 && !(blurBehindDecos && w->hasDecoration()))
if (!w->hasAlpha() && w->opacity() >= 1.0 && !(blurBehindDecos && w->hasDecoration())) {
return false;
}
return true;
}

View File

@ -194,8 +194,9 @@ void DesktopGridEffect::reconfigure(ReconfigureFlags)
}
effects->registerRealtimeTouchBorder(ElectricBorder(i), m_gestureAction, [this](ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) {
if (activated)
if (activated) {
return;
}
if (timeline.currentValue() == 0) {
activated = true;
@ -260,8 +261,9 @@ void DesktopGridEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mi
}
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once,
// so with normal screen painting second screen paint would erase parts of the first paint
if (timeline.currentValue() != 0 || (isUsingPresentWindows() && isMotionManagerMovingWindows()))
if (timeline.currentValue() != 0 || (isUsingPresentWindows() && isMotionManagerMovingWindows())) {
data.mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST;
}
}
const EffectWindowList windows = effects->stackingOrder();
@ -312,18 +314,20 @@ void DesktopGridEffect::paintScreen(int mask, const QRegion &region, ScreenPaint
textArea.adjust(textArea.width() / 10, textArea.height() / 10,
-textArea.width() / 10, -textArea.height() / 10);
int x, y;
if (desktopNameAlignment & Qt::AlignLeft)
if (desktopNameAlignment & Qt::AlignLeft) {
x = textArea.x();
else if (desktopNameAlignment & Qt::AlignRight)
} else if (desktopNameAlignment & Qt::AlignRight) {
x = textArea.right();
else
} else {
x = textArea.center().x();
if (desktopNameAlignment & Qt::AlignTop)
}
if (desktopNameAlignment & Qt::AlignTop) {
y = textArea.y();
else if (desktopNameAlignment & Qt::AlignBottom)
} else if (desktopNameAlignment & Qt::AlignBottom) {
y = textArea.bottom();
else
} else {
y = textArea.center().y();
}
frame->setPosition(QPoint(x, y));
frame->render(region, timeline.currentValue(), 0.7);
++desktop;
@ -408,8 +412,9 @@ void DesktopGridEffect::paintWindow(EffectWindow *w, int mask, QRegion region, W
WindowMotionManager &manager = m_managers[screen][paintingDesktop - 1];
if (manager.isManaging(w)) {
transformedGeo = manager.transformedGeometry(w);
if (!manager.areWindowsMoving() && timeline.currentValue() == 1.0)
if (!manager.areWindowsMoving() && timeline.currentValue() == 1.0) {
mask |= PAINT_WINDOW_LANCZOS;
}
} else if (w->screen() != screen) {
continue; // we don't want parts of overlapping windows on the other screen
}
@ -442,8 +447,9 @@ void DesktopGridEffect::paintWindow(EffectWindow *w, int mask, QRegion region, W
}
effects->paintWindow(w, mask, effects->clientArea(ScreenArea, screen, 0), d);
}
} else
} else {
effects->paintWindow(w, mask, region, data);
}
}
//-----------------------------------------------------------------------------
@ -451,8 +457,9 @@ void DesktopGridEffect::paintWindow(EffectWindow *w, int mask, QRegion region, W
void DesktopGridEffect::slotWindowAdded(EffectWindow *w)
{
if (!activated)
if (!activated) {
return;
}
if (isUsingPresentWindows()) {
if (!isRelevantWithPresentWindows(w)) {
return; // don't add
@ -469,8 +476,9 @@ void DesktopGridEffect::slotWindowAdded(EffectWindow *w)
void DesktopGridEffect::slotWindowClosed(EffectWindow *w)
{
if (!activated && timeline.currentValue() == 0)
if (!activated && timeline.currentValue() == 0) {
return;
}
if (w == windowMove) {
effects->setElevatedWindow(windowMove, false);
windowMove = nullptr;
@ -488,8 +496,9 @@ void DesktopGridEffect::slotWindowClosed(EffectWindow *w)
void DesktopGridEffect::slotWindowDeleted(EffectWindow *w)
{
if (w == windowMove)
if (w == windowMove) {
windowMove = nullptr;
}
if (isUsingPresentWindows()) {
for (auto it = m_managers.begin(); it != m_managers.end(); ++it) {
for (WindowMotionManager &manager : *it) {
@ -502,10 +511,12 @@ void DesktopGridEffect::slotWindowDeleted(EffectWindow *w)
void DesktopGridEffect::slotWindowFrameGeometryChanged(EffectWindow *w, const QRect &old)
{
Q_UNUSED(old)
if (!activated)
if (!activated) {
return;
if (w == windowMove && wasWindowMove)
}
if (w == windowMove && wasWindowMove) {
return;
}
if (isUsingPresentWindows()) {
const auto desktops = desktopList(w);
for (const int i : desktops) {
@ -520,8 +531,9 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
if ((e->type() != QEvent::MouseMove
&& e->type() != QEvent::MouseButtonPress
&& e->type() != QEvent::MouseButtonRelease)
|| timeline.currentValue() != 1) // Block user input during animations
|| timeline.currentValue() != 1) { // Block user input during animations
return;
}
QMouseEvent *me = static_cast<QMouseEvent *>(e);
if (!(wasWindowMove || wasDesktopMove)) {
for (OffscreenQuickScene *view : qAsConst(m_desktopButtons)) {
@ -555,8 +567,9 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
}
manager.unmanage(windowMove);
if (EffectWindow *modal = windowMove->findModal()) {
if (manager.isManaging(modal))
if (manager.isManaging(modal)) {
manager.unmanage(modal);
}
}
m_proxy->calculateWindowTransformations(manager.managedWindows(), windowMove->screen(), manager);
}
@ -586,8 +599,9 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
}
effects->windowToDesktops(windowMove, desktops);
EffectScreen *screen = effects->screenAt(me->pos());
if (screen != windowMove->screen())
if (screen != windowMove->screen()) {
effects->windowToScreen(windowMove, screen);
}
}
effects->addRepaintFull();
}
@ -603,19 +617,24 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
end = windows.constEnd();
it != end; ++it) {
EffectWindow *w = const_cast<EffectWindow *>(*it); // we're not really touching it here but below
if (w->isOnAllDesktops())
if (w->isOnAllDesktops()) {
continue;
if (w->isOnDesktop(highlightedDesktop))
}
if (w->isOnDesktop(highlightedDesktop)) {
stack[0] << w;
if (w->isOnDesktop(d))
}
if (w->isOnDesktop(d)) {
stack[1] << w;
if (w->isOnDesktop(m_originalMovingDesktop))
}
if (w->isOnDesktop(m_originalMovingDesktop)) {
stack[2] << w;
}
}
const int desks[4] = {highlightedDesktop, d, m_originalMovingDesktop, highlightedDesktop};
for (int i = 0; i < 3; ++i) {
if (desks[i] == desks[i + 1])
if (desks[i] == desks[i + 1]) {
continue;
}
for (EffectWindow *w : qAsConst(stack[i])) {
auto desktops = w->desktops();
desktops.removeOne(desks[i]);
@ -649,12 +668,14 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
sourceDesktop = posToDesktop(me->pos());
bool isDesktop = (me->modifiers() & Qt::ShiftModifier);
EffectWindow *w = isDesktop ? nullptr : windowAt(me->pos());
if (w != nullptr)
if (w != nullptr) {
isDesktop = w->isDesktop();
if (isDesktop)
}
if (isDesktop) {
m_originalMovingDesktop = posToDesktop(me->pos());
else
} else {
m_originalMovingDesktop = 0;
}
if (w != nullptr && !w->isDesktop() && (w->isMovable() || w->isMovableAcrossScreens() || isUsingPresentWindows())) {
// Prepare it for moving
windowMoveDiff = w->pos() - unscalePos(me->pos(), nullptr);
@ -678,10 +699,11 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
for (int i = 0; i < effects->numberOfDesktops(); i++) {
if (i != desktop - 1) {
WindowMotionManager &manager = m_managers[w->screen()][i];
if (isOnAllDesktops)
if (isOnAllDesktops) {
manager.manage(w);
else
} else {
manager.unmanage(w);
}
m_proxy->calculateWindowTransformations(manager.managedWindows(), w->screen(), manager);
}
}
@ -706,8 +728,9 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
effects->defineCursor(Qt::ArrowCursor);
} else { // click -> exit
const int desk = posToDesktop(me->pos());
if (desk > effects->numberOfDesktops())
if (desk > effects->numberOfDesktops()) {
return; // don't quit when missing desktop
}
setCurrentDesktop(desk);
deactivate();
}
@ -718,8 +741,9 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent *e)
for (const int i : desktops) {
WindowMotionManager &manager = m_managers[windowMove->screen()][i];
manager.manage(windowMove);
if (EffectWindow *modal = windowMove->findModal())
if (EffectWindow *modal = windowMove->findModal()) {
manager.manage(modal);
}
if (i + 1 == targetDesktop) {
// for the desktop the window is dropped on, we use the current geometry
manager.setTransformedGeometry(windowMove, moveGeometryToDesktop(targetDesktop));
@ -758,18 +782,21 @@ void DesktopGridEffect::deactivate()
void DesktopGridEffect::toggle()
{
if (activated)
if (activated) {
deactivate();
else
} else {
activate();
}
}
void DesktopGridEffect::grabbedKeyboardEvent(QKeyEvent *e)
{
if (timeline.currentValue() != 1) // Block user input during animations
if (timeline.currentValue() != 1) { // Block user input during animations
return;
if (windowMove != nullptr)
}
if (windowMove != nullptr) {
return;
}
if (e->type() == QEvent::KeyPress) {
// check for global shortcuts
// HACK: keyboard grab disables the global shortcuts so we have to check for global shortcut (bug 156155)
@ -780,10 +807,11 @@ void DesktopGridEffect::grabbedKeyboardEvent(QKeyEvent *e)
int desktop = -1;
// switch by F<number> or just <number>
if (e->key() >= Qt::Key_F1 && e->key() <= Qt::Key_F35)
if (e->key() >= Qt::Key_F1 && e->key() <= Qt::Key_F35) {
desktop = e->key() - Qt::Key_F1 + 1;
else if (e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9)
} else if (e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) {
desktop = e->key() == Qt::Key_0 ? 10 : e->key() - Qt::Key_0;
}
if (desktop != -1) {
if (desktop <= effects->numberOfDesktops()) {
setHighlightedDesktop(desktop);
@ -829,10 +857,12 @@ void DesktopGridEffect::grabbedKeyboardEvent(QKeyEvent *e)
bool DesktopGridEffect::borderActivated(ElectricBorder border)
{
if (!borderActivate.contains(border))
if (!borderActivate.contains(border)) {
return false;
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
}
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) {
return true;
}
toggle();
return true;
}
@ -902,10 +932,11 @@ QPoint DesktopGridEffect::unscalePos(const QPoint &pos, int *desktop) const
scaledX -= gx;
scaledY -= gy;
if (desktop != nullptr) {
if (orientation == Qt::Horizontal)
if (orientation == Qt::Horizontal) {
*desktop = gy * gridSize.width() + gx + 1;
else
} else {
*desktop = gx * gridSize.height() + gy + 1;
}
}
return QPoint(
@ -934,8 +965,9 @@ int DesktopGridEffect::posToDesktop(const QPoint &pos) const
double scaledY = (pos.y() - scaledOffset[screen].y() + double(border) / 2.0) / (scaledSize[screen].height() + border);
int gx = qBound(0, int(scaledX), gridSize.width() - 1); // Zero-based
int gy = qBound(0, int(scaledY), gridSize.height() - 1);
if (orientation == Qt::Horizontal)
if (orientation == Qt::Horizontal) {
return gy * gridSize.width() + gx + 1;
}
return gx * gridSize.height() + gy + 1;
}
@ -946,18 +978,21 @@ EffectWindow *DesktopGridEffect::windowAt(QPoint pos) const
EffectWindowList::Iterator begin = windows.begin();
EffectWindowList::Iterator end = windows.end();
--end;
while (begin < end)
while (begin < end) {
qSwap(*begin++, *end--);
}
int desktop;
pos = unscalePos(pos, &desktop);
if (desktop > effects->numberOfDesktops())
if (desktop > effects->numberOfDesktops()) {
return nullptr;
}
if (isUsingPresentWindows()) {
EffectScreen *screen = effects->screenAt(pos);
EffectWindow *w = m_managers[screen][desktop - 1].windowAtPoint(pos, false);
if (w)
if (w) {
return w;
}
for (EffectWindow *w : qAsConst(windows)) {
if (w->isOnDesktop(desktop) && w->isDesktop() && w->frameGeometry().contains(pos)) {
return w;
@ -982,20 +1017,24 @@ void DesktopGridEffect::setCurrentDesktop(int desktop)
activeCell.setX((desktop - 1) / gridSize.height() + 1);
activeCell.setY((desktop - 1) % gridSize.height() + 1);
}
if (effects->currentDesktop() != desktop)
if (effects->currentDesktop() != desktop) {
effects->setCurrentDesktop(desktop);
}
}
void DesktopGridEffect::setHighlightedDesktop(int d)
{
if (d == highlightedDesktop || d <= 0 || d > effects->numberOfDesktops())
if (d == highlightedDesktop || d <= 0 || d > effects->numberOfDesktops()) {
return;
if (highlightedDesktop > 0 && highlightedDesktop <= hoverTimeline.count())
}
if (highlightedDesktop > 0 && highlightedDesktop <= hoverTimeline.count()) {
hoverTimeline[highlightedDesktop - 1]->setCurrentTime(qMin(hoverTimeline[highlightedDesktop - 1]->currentTime(),
hoverTimeline[highlightedDesktop - 1]->duration()));
}
highlightedDesktop = d;
if (highlightedDesktop <= hoverTimeline.count())
if (highlightedDesktop <= hoverTimeline.count()) {
hoverTimeline[highlightedDesktop - 1]->setCurrentTime(qMax(hoverTimeline[highlightedDesktop - 1]->currentTime(), 0));
}
effects->addRepaintFull();
}
@ -1006,18 +1045,20 @@ int DesktopGridEffect::desktopToRight(int desktop, bool wrap) const
if (orientation == Qt::Vertical) {
dt += gridSize.height();
if (dt >= effects->numberOfDesktops()) {
if (wrap)
if (wrap) {
dt -= effects->numberOfDesktops();
else
} else {
return desktop;
}
}
} else {
int d = (dt % gridSize.width()) + 1;
if (d >= gridSize.width()) {
if (wrap)
if (wrap) {
d -= gridSize.width();
else
} else {
return desktop;
}
}
dt = dt - (dt % gridSize.width()) + d;
}
@ -1031,18 +1072,20 @@ int DesktopGridEffect::desktopToLeft(int desktop, bool wrap) const
if (orientation == Qt::Vertical) {
dt -= gridSize.height();
if (dt < 0) {
if (wrap)
if (wrap) {
dt += effects->numberOfDesktops();
else
} else {
return desktop;
}
}
} else {
int d = (dt % gridSize.width()) - 1;
if (d < 0) {
if (wrap)
if (wrap) {
d += gridSize.width();
else
} else {
return desktop;
}
}
dt = dt - (dt % gridSize.width()) + d;
}
@ -1056,18 +1099,20 @@ int DesktopGridEffect::desktopUp(int desktop, bool wrap) const
if (orientation == Qt::Horizontal) {
dt -= gridSize.width();
if (dt < 0) {
if (wrap)
if (wrap) {
dt += effects->numberOfDesktops();
else
} else {
return desktop;
}
}
} else {
int d = (dt % gridSize.height()) - 1;
if (d < 0) {
if (wrap)
if (wrap) {
d += gridSize.height();
else
} else {
return desktop;
}
}
dt = dt - (dt % gridSize.height()) + d;
}
@ -1081,18 +1126,20 @@ int DesktopGridEffect::desktopDown(int desktop, bool wrap) const
if (orientation == Qt::Horizontal) {
dt += gridSize.width();
if (dt >= effects->numberOfDesktops()) {
if (wrap)
if (wrap) {
dt -= effects->numberOfDesktops();
else
} else {
return desktop;
}
}
} else {
int d = (dt % gridSize.height()) + 1;
if (d >= gridSize.height()) {
if (wrap)
if (wrap) {
d -= gridSize.height();
else
} else {
return desktop;
}
}
dt = dt - (dt % gridSize.height()) + d;
}
@ -1104,8 +1151,9 @@ int DesktopGridEffect::desktopDown(int desktop, bool wrap) const
void DesktopGridEffect::setup()
{
if (!isActive())
if (!isActive()) {
return;
}
if (!keyboardGrab) {
keyboardGrab = effects->grabKeyboard(this);
effects->startMouseInterception(this, Qt::ArrowCursor);
@ -1140,8 +1188,9 @@ void DesktopGridEffect::setup()
setCurrentDesktop(effects->currentDesktop());
// setup the motion managers
if (clickBehavior == SwitchDesktopAndActivateWindow)
if (clickBehavior == SwitchDesktopAndActivateWindow) {
m_proxy = static_cast<PresentWindowsEffectProxy *>(effects->getProxy(QStringLiteral("presentwindows")));
}
if (isUsingPresentWindows()) {
m_proxy->reCreateGrids(); // revalidation on multiscreen, bug #351724
const QList<EffectScreen *> screens = effects->screens();
@ -1222,8 +1271,9 @@ void DesktopGridEffect::setupGrid()
case LayoutAutomatic:
y = sqrt(float(numDesktops)) + 0.5;
x = float(numDesktops) / float(y) + 0.5;
if (x * y < numDesktops)
if (x * y < numDesktops) {
x++;
}
orientation = Qt::Horizontal;
gridSize.setWidth(x);
gridSize.setHeight(y);
@ -1243,10 +1293,11 @@ void DesktopGridEffect::setupGrid()
for (EffectScreen *screen : screens) {
QRect geom = effects->clientArea(ScreenArea, screen, effects->currentDesktop());
double sScale;
if (gridSize.width() > gridSize.height())
if (gridSize.width() > gridSize.height()) {
sScale = (geom.width() - border * (gridSize.width() + 1)) / double(geom.width() * gridSize.width());
else
} else {
sScale = (geom.height() - border * (gridSize.height() + 1)) / double(geom.height() * gridSize.height());
}
double sBorder = border / sScale;
QSizeF size(
double(geom.width()) * sScale,
@ -1280,8 +1331,9 @@ void DesktopGridEffect::finish()
}
QTimer::singleShot(zoomDuration + 1, this,
[this] {
if (activated)
if (activated) {
return;
}
for (OffscreenQuickScene *view : qAsConst(m_desktopButtons)) {
view->hide();
}
@ -1290,8 +1342,9 @@ void DesktopGridEffect::finish()
windowMoveElevateTimer->stop();
if (keyboardGrab)
if (keyboardGrab) {
effects->ungrabKeyboard();
}
keyboardGrab = false;
lastPresentTime = std::chrono::milliseconds::zero();
effects->stopMouseInterception(this);
@ -1323,8 +1376,9 @@ bool DesktopGridEffect::isMotionManagerMovingWindows() const
if (isUsingPresentWindows()) {
for (auto it = m_managers.constBegin(); it != m_managers.constEnd(); ++it) {
for (const WindowMotionManager &manager : *it) {
if (manager.areWindowsMoving())
if (manager.areWindowsMoving()) {
return true;
}
}
}
}
@ -1368,13 +1422,15 @@ void DesktopGridEffect::slotRemoveDesktop()
void DesktopGridEffect::slotNumberDesktopsChanged(uint old)
{
if (!activated)
if (!activated) {
return;
}
const uint desktop = effects->numberOfDesktops();
if (old < desktop)
if (old < desktop) {
desktopsAdded(old);
else
} else {
desktopsRemoved(old);
}
}
void DesktopGridEffect::desktopsAdded(int old)
@ -1449,8 +1505,9 @@ void DesktopGridEffect::desktopsRemoved(int old)
WindowMotionManager &manager = m_managers[screen][desktop - 1];
const auto stackingOrder = effects->stackingOrder();
for (EffectWindow *w : stackingOrder) {
if (manager.isManaging(w))
if (manager.isManaging(w)) {
continue;
}
if (w->isOnDesktop(desktop) && w->screen() == screen && isRelevantWithPresentWindows(w)) {
manager.manage(w);
}
@ -1471,8 +1528,9 @@ QVector<int> DesktopGridEffect::desktopList(const EffectWindow *w) const
static QVector<int> allDesktops;
if (allDesktops.count() != effects->numberOfDesktops()) {
allDesktops.resize(effects->numberOfDesktops());
for (int i = 0; i < effects->numberOfDesktops(); ++i)
for (int i = 0; i < effects->numberOfDesktops(); ++i) {
allDesktops[i] = i;
}
}
return allDesktops;
}

View File

@ -40,8 +40,9 @@ void FallApartEffect::reconfigure(ReconfigureFlags)
void FallApartEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
{
if (!windows.isEmpty())
if (!windows.isEmpty()) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
}
effects->prePaintScreen(data, presentTime);
}
@ -83,15 +84,19 @@ void FallApartEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
// they are (left pieces generally move to the left, etc.)
QPointF p1(quad[0].x(), quad[0].y());
double xdiff = 0;
if (p1.x() < w->width() / 2)
if (p1.x() < w->width() / 2) {
xdiff = -(w->width() / 2 - p1.x()) / w->width() * 100;
if (p1.x() > w->width() / 2)
}
if (p1.x() > w->width() / 2) {
xdiff = (p1.x() - w->width() / 2) / w->width() * 100;
}
double ydiff = 0;
if (p1.y() < w->height() / 2)
if (p1.y() < w->height() / 2) {
ydiff = -(w->height() / 2 - p1.y()) / w->height() * 100;
if (p1.y() > w->height() / 2)
}
if (p1.y() > w->height() / 2) {
ydiff = (p1.y() - w->height() / 2) / w->height() * 100;
}
double modif = t * t * 64;
srandom(cnt); // change direction randomly but consistently
xdiff += (rand() % 21 - 10);
@ -125,8 +130,9 @@ void FallApartEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
void FallApartEffect::postPaintScreen()
{
if (!windows.isEmpty())
if (!windows.isEmpty()) {
effects->addRepaintFull();
}
effects->postPaintScreen();
}
@ -150,22 +156,27 @@ bool FallApartEffect::isRealWindow(EffectWindow *w)
if (w->isX11Client() && !w->isManaged()) {
return false;
}
if (!w->isNormalWindow())
if (!w->isNormalWindow()) {
return false;
}
return true;
}
void FallApartEffect::slotWindowClosed(EffectWindow *c)
{
if (effects->activeFullScreenEffect())
if (effects->activeFullScreenEffect()) {
return;
if (!isRealWindow(c))
}
if (!isRealWindow(c)) {
return;
if (!c->isVisible())
}
if (!c->isVisible()) {
return;
}
const void *e = c->data(WindowClosedGrabRole).value<void *>();
if (e && e != this)
if (e && e != this) {
return;
}
c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void *>(this)));
windows[c].progress = 0;
c->refWindow();

View File

@ -97,8 +97,9 @@ void HighlightWindowEffect::slotWindowAdded(EffectWindow *w)
void HighlightWindowEffect::slotWindowClosed(EffectWindow *w)
{
if (m_monitorWindow == w) // The monitoring window was destroyed
if (m_monitorWindow == w) { // The monitoring window was destroyed
finishHighlighting();
}
}
void HighlightWindowEffect::slotWindowDeleted(EffectWindow *w)
@ -108,15 +109,17 @@ void HighlightWindowEffect::slotWindowDeleted(EffectWindow *w)
void HighlightWindowEffect::slotPropertyNotify(EffectWindow *w, long a, EffectWindow *addedWindow)
{
if (a != m_atom || m_atom == XCB_ATOM_NONE)
if (a != m_atom || m_atom == XCB_ATOM_NONE) {
return; // Not our atom
}
// if the window is null, the property was set on the root window - see events.cpp
QByteArray byteData = w ? w->readProperty(m_atom, m_atom, 32) : effects->readRootProperty(m_atom, m_atom, 32);
if (byteData.length() < 1) {
// Property was removed, clearing highlight
if (!addedWindow || w != addedWindow)
if (!addedWindow || w != addedWindow) {
finishHighlighting();
}
return;
}
auto *data = reinterpret_cast<uint32_t *>(byteData.data());

View File

@ -83,8 +83,9 @@ bool InvertEffect::loadData()
void InvertEffect::drawWindow(EffectWindow *w, int mask, const QRegion &region, WindowPaintData &data)
{
// Load if we haven't already
if (m_valid && !m_inited)
if (m_valid && !m_inited) {
m_valid = loadData();
}
bool useShader = m_valid && (m_allWindows != m_windows.contains(w));
if (useShader) {
@ -128,10 +129,11 @@ void InvertEffect::toggleWindow()
if (!effects->activeWindow()) {
return;
}
if (!m_windows.contains(effects->activeWindow()))
if (!m_windows.contains(effects->activeWindow())) {
m_windows.append(effects->activeWindow());
else
} else {
m_windows.removeOne(effects->activeWindow());
}
effects->activeWindow()->addRepaintFull();
}

View File

@ -201,10 +201,11 @@ void LookingGlassEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::m
const int time = m_lastPresentTime.count() ? (presentTime - m_lastPresentTime).count() : 0;
if (zoom != target_zoom) {
double diff = time / animationTime(500.0);
if (target_zoom > zoom)
if (target_zoom > zoom) {
zoom = qMin(zoom * qMax(1.0 + diff, 1.2), target_zoom);
else
} else {
zoom = qMax(zoom * qMin(1.0 - diff, 0.8), target_zoom);
}
qCDebug(KWIN_LOOKINGGLASS) << "zoom is now " << zoom;
radius = qBound((double)initialradius, initialradius * zoom, 3.5 * initialradius);

View File

@ -106,8 +106,9 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
di = d[1][1];
position = Bottom;
}
if (d[0][1] < di)
if (d[0][1] < di) {
position = Right;
}
switch (position) {
case Top:
pt.setY(extG.y());
@ -123,14 +124,15 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
break;
}
} else {
if (pt.y() < geo.y())
if (pt.y() < geo.y()) {
position = Top;
else if (pt.x() < geo.x())
} else if (pt.x() < geo.x()) {
position = Left;
else if (pt.y() > geo.bottom())
} else if (pt.y() > geo.bottom()) {
position = Bottom;
else if (pt.x() > geo.right())
} else if (pt.x() > geo.right()) {
position = Right;
}
}
icon = QRect(pt, QSize(0, 0));
} else {
@ -138,8 +140,9 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
EffectWindow *panel = nullptr;
const auto stackingOrder = effects->stackingOrder();
for (EffectWindow *window : stackingOrder) {
if (!window->isDock())
if (!window->isDock()) {
continue;
}
// we have to use intersects as there seems to be a Plasma bug
// the published icon geometry might be bigger than the panel
if (window->frameGeometry().intersects(icon)) {
@ -153,16 +156,18 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
QRect panelScreen = effects->clientArea(ScreenArea, panel);
if (panel->width() >= panel->height()) {
// horizontal panel
if (panel->y() <= panelScreen.height() / 2)
if (panel->y() <= panelScreen.height() / 2) {
position = Top;
else
} else {
position = Bottom;
}
} else {
// vertical panel
if (panel->x() <= panelScreen.width() / 2)
if (panel->x() <= panelScreen.width() / 2) {
position = Left;
else
} else {
position = Right;
}
}
} else {
// we did not find a panel, so it might be autohidden
@ -228,8 +233,9 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
offset[1] = (icon.y() + quad[2].y() - geo.y()) * progress * ((quadFactor * quadFactor * quadFactor) / height_cube);
p_progress[1] = qMin(offset[1] / (icon.y() + icon.height() - geo.y() - float(quad[2].y())), 1.0f);
p_progress[0] = qMin(offset[0] / (icon.y() + icon.height() - geo.y() - float(quad[0].y())), 1.0f);
} else
} else {
lastQuad = quad;
}
SANITIZE_PROGRESS;
// x values are moved towards the center of the icon
@ -246,8 +252,9 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
offset[1] = (geo.y() - icon.height() + geo.height() + quad[2].y() - icon.y()) * progress * ((quadFactor * quadFactor * quadFactor) / height_cube);
p_progress[0] = qMin(offset[0] / (geo.y() - icon.height() + geo.height() - icon.y() - float(geo.height() - quad[0].y())), 1.0f);
p_progress[1] = qMin(offset[1] / (geo.y() - icon.height() + geo.height() - icon.y() - float(geo.height() - quad[2].y())), 1.0f);
} else
} else {
lastQuad = quad;
}
offset[0] = -offset[0];
offset[1] = -offset[1];
@ -267,8 +274,9 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
offset[1] = (geo.x() - icon.width() + geo.width() + quad[1].x() - icon.x()) * progress * ((quadFactor * quadFactor * quadFactor) / width_cube);
p_progress[0] = qMin(offset[0] / (geo.x() - icon.width() + geo.width() - icon.x() - float(geo.width() - quad[0].x())), 1.0f);
p_progress[1] = qMin(offset[1] / (geo.x() - icon.width() + geo.width() - icon.x() - float(geo.width() - quad[1].x())), 1.0f);
} else
} else {
lastQuad = quad;
}
offset[0] = -offset[0];
offset[1] = -offset[1];
@ -288,8 +296,9 @@ void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W
offset[1] = (icon.x() + quad[1].x() - geo.x()) * progress * ((quadFactor * quadFactor * quadFactor) / width_cube);
p_progress[0] = qMin(offset[0] / (icon.x() + icon.width() - geo.x() - float(quad[0].x())), 1.0f);
p_progress[1] = qMin(offset[1] / (icon.x() + icon.width() - geo.x() - float(quad[1].x())), 1.0f);
} else
} else {
lastQuad = quad;
}
SANITIZE_PROGRESS;
// y values are moved towards the center of the icon
@ -324,8 +333,9 @@ void MagicLampEffect::slotWindowDeleted(EffectWindow *w)
void MagicLampEffect::slotWindowMinimized(EffectWindow *w)
{
if (effects->activeFullScreenEffect())
if (effects->activeFullScreenEffect()) {
return;
}
MagicLampAnimation &animation = m_animations[w];
@ -343,8 +353,9 @@ void MagicLampEffect::slotWindowMinimized(EffectWindow *w)
void MagicLampEffect::slotWindowUnminimized(EffectWindow *w)
{
if (effects->activeFullScreenEffect())
if (effects->activeFullScreenEffect()) {
return;
}
MagicLampAnimation &animation = m_animations[w];

View File

@ -79,8 +79,9 @@ void MagnifierEffect::reconfigure(ReconfigureFlags)
magnifier_size = QSize(width, height);
// Load the saved zoom value.
target_zoom = MagnifierConfig::initialZoom();
if (target_zoom != zoom)
if (target_zoom != zoom) {
toggle();
}
}
void MagnifierEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
@ -89,9 +90,9 @@ void MagnifierEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mill
if (zoom != target_zoom) {
double diff = time / animationTime(500.0);
if (target_zoom > zoom)
if (target_zoom > zoom) {
zoom = qMin(zoom * qMax(1 + diff, 1.2), target_zoom);
else {
} else {
zoom = qMax(zoom * qMin(1 - diff, 0.8), target_zoom);
if (zoom == 1.0) {
// zoom ended - delete FBO and texture
@ -110,8 +111,9 @@ void MagnifierEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mill
}
effects->prePaintScreen(data, presentTime);
if (zoom != 1.0)
if (zoom != 1.0) {
data.paint |= magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH);
}
}
void MagnifierEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &data)
@ -260,10 +262,11 @@ void MagnifierEffect::toggle()
void MagnifierEffect::slotMouseChanged(const QPoint &pos, const QPoint &old,
Qt::MouseButtons, Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers)
{
if (pos != old && zoom != 1)
if (pos != old && zoom != 1) {
// need full repaint as we might lose some change events on fast mouse movements
// see Bug 187658
effects->addRepaintFull();
}
}
void MagnifierEffect::slotWindowDamaged()

View File

@ -46,8 +46,9 @@ MouseClickEffect::MouseClickEffect()
MouseClickEffect::~MouseClickEffect()
{
if (m_enabled)
if (m_enabled) {
effects->stopMousePolling();
}
qDeleteAll(m_clicks);
m_clicks.clear();
@ -158,8 +159,9 @@ void MouseClickEffect::slotMouseChanged(const QPoint &pos, const QPoint &,
Qt::MouseButtons buttons, Qt::MouseButtons oldButtons,
Qt::KeyboardModifiers, Qt::KeyboardModifiers)
{
if (buttons == oldButtons)
if (buttons == oldButtons) {
return;
}
MouseEvent *m = nullptr;
int i = BUTTON_COUNT;
@ -257,22 +259,25 @@ bool MouseClickEffect::isActive() const
void MouseClickEffect::drawCircle(const QColor &color, float cx, float cy, float r)
{
if (effects->isOpenGLCompositing())
if (effects->isOpenGLCompositing()) {
drawCircleGl(color, cx, cy, r);
else if (effects->compositingType() == QPainterCompositing)
} else if (effects->compositingType() == QPainterCompositing) {
drawCircleQPainter(color, cx, cy, r);
}
}
void MouseClickEffect::paintScreenSetup(int mask, QRegion region, ScreenPaintData &data)
{
if (effects->isOpenGLCompositing())
if (effects->isOpenGLCompositing()) {
paintScreenSetupGl(mask, region, data);
}
}
void MouseClickEffect::paintScreenFinish(int mask, QRegion region, ScreenPaintData &data)
{
if (effects->isOpenGLCompositing())
if (effects->isOpenGLCompositing()) {
paintScreenFinishGl(mask, region, data);
}
}
void MouseClickEffect::drawCircleGl(const QColor &color, float cx, float cy, float r)

View File

@ -78,8 +78,9 @@ public:
{
if (m_isPressed != pressed) {
m_isPressed = pressed;
if (pressed)
if (pressed) {
m_time = 0;
}
}
}
};

View File

@ -71,8 +71,9 @@ void MouseMarkEffect::reconfigure(ReconfigureFlags)
void MouseMarkEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &data)
{
effects->paintScreen(mask, region, data); // paint normal screen
if (marks.isEmpty() && drawing.isEmpty())
if (marks.isEmpty() && drawing.isEmpty()) {
return;
}
if (effects->isOpenGLCompositing()) {
if (!GLPlatform::instance()->isGLES()) {
glEnable(GL_BLEND);
@ -146,17 +147,21 @@ void MouseMarkEffect::slotMouseChanged(const QPoint &pos, const QPoint &,
arrow_start = NULL_POINT;
effects->addRepaintFull();
return;
} else
} else {
arrow_start = pos;
}
}
if (arrow_start != NULL_POINT)
if (arrow_start != NULL_POINT) {
return;
}
// TODO the shortcuts now trigger this right before they're activated
if (modifiers == (Qt::META | Qt::SHIFT)) { // activated
if (drawing.isEmpty())
if (drawing.isEmpty()) {
drawing.append(pos);
if (drawing.last() == pos)
}
if (drawing.last() == pos) {
return;
}
QPoint pos2 = drawing.last();
drawing.append(pos);
QRect repaint = QRect(qMin(pos.x(), pos2.x()), qMin(pos.y(), pos2.y()),

View File

@ -354,11 +354,12 @@ void ExpoLayout::calculateWindowTransformationsClosest()
// precalculate all slot centers
QVector<QPoint> slotCenters;
slotCenters.resize(rows * columns);
for (int x = 0; x < columns; ++x)
for (int x = 0; x < columns; ++x) {
for (int y = 0; y < rows; ++y) {
slotCenters[x + y * columns] = QPoint(area.x() + slotWidth * x + slotWidth / 2,
area.y() + slotHeight * y + slotHeight / 2);
}
}
// Assign each window to the closest available slot
QList<ExpoCell *> tmpList = m_cells; // use a QLinkedList copy instead?
@ -618,9 +619,9 @@ void ExpoLayout::calculateWindowTransformationsNatural()
target->y() - yDiff - heightDiff,
target->width() + widthDiff,
target->height() + heightDiff);
if (isOverlappingAny(cell, targets, borderRegion, m_spacing))
if (isOverlappingAny(cell, targets, borderRegion, m_spacing)) {
*target = oldRect;
else {
} else {
moved = true;
heightDiff = heightForWidth(cell, target->width() + widthDiff) - target->height();
yDiff = heightDiff / 2;
@ -632,9 +633,9 @@ void ExpoLayout::calculateWindowTransformationsNatural()
target->y() + yDiff,
target->width() + widthDiff,
target->height() + heightDiff);
if (isOverlappingAny(cell, targets, borderRegion, m_spacing))
if (isOverlappingAny(cell, targets, borderRegion, m_spacing)) {
*target = oldRect;
else {
} else {
moved = true;
heightDiff = heightForWidth(cell, target->width() + widthDiff) - target->height();
yDiff = heightDiff / 2;
@ -646,9 +647,9 @@ void ExpoLayout::calculateWindowTransformationsNatural()
target->y() + yDiff,
target->width() + widthDiff,
target->height() + heightDiff);
if (isOverlappingAny(cell, targets, borderRegion, m_spacing))
if (isOverlappingAny(cell, targets, borderRegion, m_spacing)) {
*target = oldRect;
else {
} else {
moved = true;
heightDiff = heightForWidth(cell, target->width() + widthDiff) - target->height();
yDiff = heightDiff / 2;

File diff suppressed because it is too large Load Diff

View File

@ -44,8 +44,9 @@ ShowFpsEffect::ShowFpsEffect()
}
for (int i = 0;
i < MAX_FPS;
++i)
++i) {
frames[i] = 0;
}
m_noBenchmark->setAlignment(Qt::AlignTop | Qt::AlignRight);
m_noBenchmark->setText(i18n("This effect is not a benchmark"));
reconfigure(ReconfigureAll);
@ -62,14 +63,16 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags)
x = ShowFpsConfig::x();
y = ShowFpsConfig::y();
const QSize screenSize = effects->virtualScreenSize();
if (x == -10000) // there's no -0 :(
if (x == -10000) { // there's no -0 :(
x = screenSize.width() - 2 * NUM_PAINTS - FPS_WIDTH;
else if (x < 0)
} else if (x < 0) {
x = screenSize.width() - 2 * NUM_PAINTS - FPS_WIDTH - x;
if (y == -10000)
}
if (y == -10000) {
y = screenSize.height() - MAX_TIME;
else if (y < 0)
} else if (y < 0) {
y = screenSize.height() - MAX_TIME - y;
}
fps_rect = QRect(x, y, FPS_WIDTH + 2 * NUM_PAINTS, MAX_TIME);
m_noBenchmark->setPosition(fps_rect.bottomRight() + QPoint(-6, 6));
@ -78,8 +81,9 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags)
textColor = ShowFpsConfig::textColor();
double textAlpha = ShowFpsConfig::textAlpha();
if (!textColor.isValid())
if (!textColor.isValid()) {
textColor = QPalette().color(QPalette::Active, QPalette::WindowText);
}
textColor.setAlphaF(textAlpha);
switch (textPosition) {
@ -113,8 +117,9 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags)
void ShowFpsEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
{
frames[frames_pos] = QDateTime::currentMSecsSinceEpoch();
if (++frames_pos == MAX_FPS)
if (++frames_pos == MAX_FPS) {
frames_pos = 0;
}
effects->prePaintScreen(data, presentTime);
data.paint += fps_rect;
@ -141,17 +146,21 @@ void ShowFpsEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData
{
effects->paintScreen(mask, region, data);
int lastFrame = frames_pos - 1;
if (lastFrame < 0)
if (lastFrame < 0) {
lastFrame = MAX_FPS - 1;
}
const qint64 lastTimestamp = frames[lastFrame];
int fps = 0;
for (int i = 0;
i < MAX_FPS;
++i)
if (abs(lastTimestamp - frames[i]) < 1000)
++i) {
if (abs(lastTimestamp - frames[i]) < 1000) {
++fps; // count all frames in the last second
if (fps > MAX_TIME)
}
}
if (fps > MAX_TIME) {
fps = MAX_TIME; // keep it the same height
}
if (effects->isOpenGLCompositing()) {
paintGL(fps, data.projectionMatrix());
glFinish(); // make sure all rendering is done
@ -287,8 +296,9 @@ void ShowFpsEffect::paintFPSGraph(int x, int y)
void ShowFpsEffect::paintDrawSizeGraph(int x, int y)
{
int max_drawsize = 0;
for (int i = 0; i < NUM_PAINTS; i++)
for (int i = 0; i < NUM_PAINTS; i++) {
max_drawsize = qMax(max_drawsize, paint_size[i]);
}
// Log of min/max values shown on graph
const float max_pixels_log = 7.2f;
@ -298,8 +308,9 @@ void ShowFpsEffect::paintDrawSizeGraph(int x, int y)
float drawscale = (MAX_TIME - minh) / (max_pixels_log - min_pixels_log);
QList<int> drawlines;
for (int logh = (int)min_pixels_log; logh <= max_pixels_log; logh++)
for (int logh = (int)min_pixels_log; logh <= max_pixels_log; logh++) {
drawlines.append((int)((logh - min_pixels_log) * drawscale) + minh);
}
QList<int> drawvalues;
for (int i = 0;
@ -394,8 +405,9 @@ void ShowFpsEffect::postPaintScreen()
{
effects->postPaintScreen();
paints[paints_pos] = t.elapsed();
if (++paints_pos == NUM_PAINTS)
if (++paints_pos == NUM_PAINTS) {
paints_pos = 0;
}
effects->addRepaint(fps_rect);
}

View File

@ -42,10 +42,11 @@ void SlideBackEffect::slotStackingOrderChanged()
m_upmostWindow = usableNewStackingOrder.last();
if (m_upmostWindow == m_justMapped) // a window was added, got on top, stacking changed. Nothing impressive
if (m_upmostWindow == m_justMapped) { // a window was added, got on top, stacking changed. Nothing impressive
m_justMapped = nullptr;
else if (!usableOldStackingOrder.isEmpty() && m_upmostWindow != usableOldStackingOrder.last())
} else if (!usableOldStackingOrder.isEmpty() && m_upmostWindow != usableOldStackingOrder.last()) {
windowRaised(m_upmostWindow);
}
oldStackingOrder = newStackingOrder;
usableOldStackingOrder = usableNewStackingOrder;
@ -253,10 +254,12 @@ void SlideBackEffect::postPaintWindow(EffectWindow *w)
void SlideBackEffect::slotWindowDeleted(EffectWindow *w)
{
if (w == m_upmostWindow)
if (w == m_upmostWindow) {
m_upmostWindow = nullptr;
if (w == m_justMapped)
}
if (w == m_justMapped) {
m_justMapped = nullptr;
}
usableOldStackingOrder.removeAll(w);
oldStackingOrder.removeAll(w);
coveringWindows.removeAll(w);

View File

@ -141,11 +141,11 @@ void StartupFeedbackEffect::reconfigure(Effect::ReconfigureFlags flags)
m_startupInfo->setTimeout(m_timeout.count());
const bool busyBlinking = c.readEntry("Blinking", false);
const bool busyBouncing = c.readEntry("Bouncing", true);
if (!busyCursor)
if (!busyCursor) {
m_type = NoFeedback;
else if (busyBouncing)
} else if (busyBouncing) {
m_type = BouncingFeedback;
else if (busyBlinking) {
} else if (busyBlinking) {
m_type = BlinkingFeedback;
if (effects->compositingType() == OpenGLCompositing) {
ensureResources();
@ -156,8 +156,9 @@ void StartupFeedbackEffect::reconfigure(Effect::ReconfigureFlags flags)
qCDebug(KWIN_STARTUPFEEDBACK) << "Blinking Shader is not valid";
}
}
} else
} else {
m_type = PassiveFeedback;
}
if (m_active) {
stop();
start(m_startups[m_currentStartup]);
@ -235,8 +236,9 @@ void StartupFeedbackEffect::postPaintScreen()
{
if (m_active) {
m_dirtyRect = m_currentGeometry; // ensure the now dirty region is cleaned on the next pass
if (m_type == BlinkingFeedback || m_type == BouncingFeedback)
if (m_type == BlinkingFeedback || m_type == BouncingFeedback) {
effects->addRepaint(m_dirtyRect); // we also have to trigger a repaint
}
}
effects->postPaintScreen();
}
@ -300,10 +302,12 @@ void StartupFeedbackEffect::gotStartupChange(const QString &id, const QIcon &ico
void StartupFeedbackEffect::start(const Startup &startup)
{
if (m_type == NoFeedback || m_splashVisible || effects->isCursorHidden())
if (m_type == NoFeedback || m_splashVisible || effects->isCursorHidden()) {
return;
if (!m_active)
}
if (!m_active) {
effects->startMousePolling();
}
m_active = true;
// read details about the mouse-cursor theme define per default
@ -315,8 +319,9 @@ void StartupFeedbackEffect::start(const Startup &startup)
iconSize = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
}
// get ratio for bouncing cursor so we don't need to manually calculate the sizes for each icon size
if (m_type == BouncingFeedback)
if (m_type == BouncingFeedback) {
m_bounceSizesRatio = iconSize / 16.0;
}
const QPixmap iconPixmap = startup.icon.pixmap(iconSize);
prepareTextures(iconPixmap);
m_dirtyRect = m_currentGeometry = feedbackRect();
@ -325,8 +330,9 @@ void StartupFeedbackEffect::start(const Startup &startup)
void StartupFeedbackEffect::stop()
{
if (m_active)
if (m_active) {
effects->stopMousePolling();
}
m_active = false;
m_lastPresentTime = std::chrono::milliseconds::zero();
effects->makeOpenGLContextCurrent();
@ -377,8 +383,9 @@ QImage StartupFeedbackEffect::scalePixmap(const QPixmap &pm, const QSize &size)
{
const QSize &adjustedSize = size * m_bounceSizesRatio;
QImage scaled = pm.toImage().scaled(adjustedSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
if (scaled.format() != QImage::Format_ARGB32_Premultiplied && scaled.format() != QImage::Format_ARGB32)
if (scaled.format() != QImage::Format_ARGB32_Premultiplied && scaled.format() != QImage::Format_ARGB32) {
scaled = scaled.convertToFormat(QImage::Format_ARGB32);
}
QImage result(20 * m_bounceSizesRatio, 20 * m_bounceSizesRatio, QImage::Format_ARGB32);
QPainter p(&result);
@ -391,14 +398,15 @@ QImage StartupFeedbackEffect::scalePixmap(const QPixmap &pm, const QSize &size)
QRect StartupFeedbackEffect::feedbackRect() const
{
int xDiff;
if (m_cursorSize <= 16)
if (m_cursorSize <= 16) {
xDiff = 8 + 7;
else if (m_cursorSize <= 32)
} else if (m_cursorSize <= 32) {
xDiff = 16 + 7;
else if (m_cursorSize <= 48)
} else if (m_cursorSize <= 48) {
xDiff = 24 + 7;
else
} else {
xDiff = 32 + 7;
}
int yDiff = xDiff;
GLTexture *texture = nullptr;
int yOffset = 0;
@ -417,8 +425,9 @@ QRect StartupFeedbackEffect::feedbackRect() const
}
const QPoint cursorPos = effects->cursorPos() + QPoint(xDiff, yDiff + yOffset);
QRect rect;
if (texture)
if (texture) {
rect = QRect(cursorPos, texture->size());
}
return rect;
}

View File

@ -76,8 +76,9 @@ void ThumbnailAsideEffect::paintWindow(EffectWindow *w, int mask, QRegion region
void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow *w, const QRegion &)
{
for (const Data &d : qAsConst(windows)) {
if (d.window == w)
if (d.window == w) {
effects->addRepaint(d.rect);
}
}
}
@ -85,10 +86,11 @@ void ThumbnailAsideEffect::slotWindowFrameGeometryChanged(EffectWindow *w, const
{
for (const Data &d : qAsConst(windows)) {
if (d.window == w) {
if (w->size() == old.size())
if (w->size() == old.size()) {
effects->addRepaint(d.rect);
else
} else {
arrange();
}
return;
}
}
@ -102,12 +104,14 @@ void ThumbnailAsideEffect::slotWindowClosed(EffectWindow *w)
void ThumbnailAsideEffect::toggleCurrentThumbnail()
{
EffectWindow *active = effects->activeWindow();
if (active == nullptr)
if (active == nullptr) {
return;
if (windows.contains(active))
}
if (windows.contains(active)) {
removeThumbnail(active);
else
} else {
addThumbnail(active);
}
}
void ThumbnailAsideEffect::addThumbnail(EffectWindow *w)
@ -122,8 +126,9 @@ void ThumbnailAsideEffect::addThumbnail(EffectWindow *w)
void ThumbnailAsideEffect::removeThumbnail(EffectWindow *w)
{
if (!windows.contains(w))
if (!windows.contains(w)) {
return;
}
repaintAll(); // repaint old areas
int index = windows[w].index;
windows.remove(w);
@ -131,16 +136,18 @@ void ThumbnailAsideEffect::removeThumbnail(EffectWindow *w)
it != windows.end();
++it) {
Data &d = *it;
if (d.index > index)
if (d.index > index) {
--d.index;
}
}
arrange();
}
void ThumbnailAsideEffect::arrange()
{
if (windows.size() == 0)
if (windows.size() == 0) {
return;
}
int height = 0;
QVector<int> pos(windows.size());
int mwidth = 0;

View File

@ -179,22 +179,25 @@ bool TouchPointsEffect::isActive() const
void TouchPointsEffect::drawCircle(const QColor &color, float cx, float cy, float r)
{
if (effects->isOpenGLCompositing())
if (effects->isOpenGLCompositing()) {
drawCircleGl(color, cx, cy, r);
else if (effects->compositingType() == QPainterCompositing)
} else if (effects->compositingType() == QPainterCompositing) {
drawCircleQPainter(color, cx, cy, r);
}
}
void TouchPointsEffect::paintScreenSetup(int mask, QRegion region, ScreenPaintData &data)
{
if (effects->isOpenGLCompositing())
if (effects->isOpenGLCompositing()) {
paintScreenSetupGl(mask, region, data);
}
}
void TouchPointsEffect::paintScreenFinish(int mask, QRegion region, ScreenPaintData &data)
{
if (effects->isOpenGLCompositing())
if (effects->isOpenGLCompositing()) {
paintScreenFinishGl(mask, region, data);
}
}
void TouchPointsEffect::drawCircleGl(const QColor &color, float cx, float cy, float r)

View File

@ -35,8 +35,9 @@ TrackMouseEffect::TrackMouseEffect()
{
initConfig<TrackMouseConfig>();
m_texture[0] = m_texture[1] = nullptr;
if (effects->isOpenGLCompositing() || effects->compositingType() == QPainterCompositing)
if (effects->isOpenGLCompositing() || effects->compositingType() == QPainterCompositing) {
m_angleBase = 90.0;
}
m_mousePolling = false;
m_action = new QAction(this);
@ -54,8 +55,9 @@ TrackMouseEffect::TrackMouseEffect()
TrackMouseEffect::~TrackMouseEffect()
{
if (m_mousePolling)
if (m_mousePolling) {
effects->stopMousePolling();
}
for (int i = 0; i < 2; ++i) {
delete m_texture[i];
m_texture[i] = nullptr;
@ -66,18 +68,23 @@ void TrackMouseEffect::reconfigure(ReconfigureFlags)
{
m_modifiers = Qt::KeyboardModifiers();
TrackMouseConfig::self()->read();
if (TrackMouseConfig::shift())
if (TrackMouseConfig::shift()) {
m_modifiers |= Qt::ShiftModifier;
if (TrackMouseConfig::alt())
}
if (TrackMouseConfig::alt()) {
m_modifiers |= Qt::AltModifier;
if (TrackMouseConfig::control())
}
if (TrackMouseConfig::control()) {
m_modifiers |= Qt::ControlModifier;
if (TrackMouseConfig::meta())
}
if (TrackMouseConfig::meta()) {
m_modifiers |= Qt::MetaModifier;
}
if (m_modifiers) {
if (!m_mousePolling)
if (!m_mousePolling) {
effects->startMousePolling();
}
m_mousePolling = true;
} else if (m_mousePolling) {
effects->stopMousePolling();
@ -149,8 +156,9 @@ bool TrackMouseEffect::init()
effects->makeOpenGLContextCurrent();
if (!m_texture[0] && m_image[0].isNull()) {
loadTexture();
if (!m_texture[0] && m_image[0].isNull())
if (!m_texture[0] && m_image[0].isNull()) {
return false;
}
}
m_lastRect[0].moveCenter(cursorPos());
m_lastRect[1].moveCenter(cursorPos());
@ -225,8 +233,9 @@ void TrackMouseEffect::loadTexture()
{
QString f[2] = {QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("tm_outer.png")),
QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("tm_inner.png"))};
if (f[0].isEmpty() || f[1].isEmpty())
if (f[0].isEmpty() || f[1].isEmpty()) {
return;
}
for (int i = 0; i < 2; ++i) {
if (effects->isOpenGLCompositing()) {

View File

@ -331,14 +331,18 @@ void WobblyWindowsEffect::slotWindowStepUserMovedResized(EffectWindow *w, const
if (windows.contains(w)) {
WindowWobblyInfos &wwi = windows[w];
const QRect rect = w->frameGeometry();
if (rect.y() != wwi.resize_original_rect.y())
if (rect.y() != wwi.resize_original_rect.y()) {
wwi.can_wobble_top = true;
if (rect.x() != wwi.resize_original_rect.x())
}
if (rect.x() != wwi.resize_original_rect.x()) {
wwi.can_wobble_left = true;
if (rect.right() != wwi.resize_original_rect.right())
}
if (rect.right() != wwi.resize_original_rect.right()) {
wwi.can_wobble_right = true;
if (rect.bottom() != wwi.resize_original_rect.bottom())
}
if (rect.bottom() != wwi.resize_original_rect.bottom()) {
wwi.can_wobble_bottom = true;
}
}
}
@ -348,14 +352,18 @@ void WobblyWindowsEffect::slotWindowFinishUserMovedResized(EffectWindow *w)
WindowWobblyInfos &wwi = windows[w];
wwi.status = Free;
const QRect rect = w->frameGeometry();
if (rect.y() != wwi.resize_original_rect.y())
if (rect.y() != wwi.resize_original_rect.y()) {
wwi.can_wobble_top = true;
if (rect.x() != wwi.resize_original_rect.x())
}
if (rect.x() != wwi.resize_original_rect.x()) {
wwi.can_wobble_left = true;
if (rect.right() != wwi.resize_original_rect.right())
}
if (rect.right() != wwi.resize_original_rect.right()) {
wwi.can_wobble_right = true;
if (rect.bottom() != wwi.resize_original_rect.bottom())
}
if (rect.bottom() != wwi.resize_original_rect.bottom()) {
wwi.can_wobble_bottom = true;
}
}
}
@ -374,14 +382,18 @@ void WobblyWindowsEffect::slotWindowMaximizeStateChanged(EffectWindow *w, bool h
if (windows.contains(w)) {
WindowWobblyInfos &wwi = windows[w];
const QRect rect = w->frameGeometry();
if (rect.y() != wwi.resize_original_rect.y())
if (rect.y() != wwi.resize_original_rect.y()) {
wwi.can_wobble_top = true;
if (rect.x() != wwi.resize_original_rect.x())
}
if (rect.x() != wwi.resize_original_rect.x()) {
wwi.can_wobble_left = true;
if (rect.right() != wwi.resize_original_rect.right())
}
if (rect.right() != wwi.resize_original_rect.right()) {
wwi.can_wobble_right = true;
if (rect.bottom() != wwi.resize_original_rect.bottom())
}
if (rect.bottom() != wwi.resize_original_rect.bottom()) {
wwi.can_wobble_bottom = true;
}
}
}
@ -907,24 +919,32 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow *w, qreal time)
}
if (!wwi.can_wobble_top) {
for (unsigned int i = 0; i < wwi.width; ++i)
for (unsigned j = 0; j < wwi.width - 1; ++j)
for (unsigned int i = 0; i < wwi.width; ++i) {
for (unsigned j = 0; j < wwi.width - 1; ++j) {
wwi.position[i + wwi.width * j].y = wwi.origin[i + wwi.width * j].y;
}
}
}
if (!wwi.can_wobble_bottom) {
for (unsigned int i = wwi.width * (wwi.height - 1); i < wwi.count; ++i)
for (unsigned j = 0; j < wwi.width - 1; ++j)
for (unsigned int i = wwi.width * (wwi.height - 1); i < wwi.count; ++i) {
for (unsigned j = 0; j < wwi.width - 1; ++j) {
wwi.position[i - wwi.width * j].y = wwi.origin[i - wwi.width * j].y;
}
}
}
if (!wwi.can_wobble_left) {
for (unsigned int i = 0; i < wwi.count; i += wwi.width)
for (unsigned j = 0; j < wwi.width - 1; ++j)
for (unsigned int i = 0; i < wwi.count; i += wwi.width) {
for (unsigned j = 0; j < wwi.width - 1; ++j) {
wwi.position[i + j].x = wwi.origin[i + j].x;
}
}
}
if (!wwi.can_wobble_right) {
for (unsigned int i = wwi.width - 1; i < wwi.count; i += wwi.width)
for (unsigned j = 0; j < wwi.width - 1; ++j)
for (unsigned int i = wwi.width - 1; i < wwi.count; i += wwi.width) {
for (unsigned j = 0; j < wwi.width - 1; ++j) {
wwi.position[i - j].x = wwi.origin[i - j].x;
}
}
}
#if defined VERBOSE_MODE
@ -939,8 +959,9 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow *w, qreal time)
freeWobblyInfo(wwi);
windows.remove(w);
unredirect(w);
if (windows.isEmpty())
if (windows.isEmpty()) {
effects->addRepaintFull();
}
return false;
}

View File

@ -186,8 +186,9 @@ void ZoomEffect::showCursor()
void ZoomEffect::hideCursor()
{
if (mouseTracking == MouseTrackingProportional && mousePointer == MousePointerKeep)
if (mouseTracking == MouseTrackingProportional && mousePointer == MousePointerKeep) {
return; // don't replace the actual cursor by a static image for no reason.
}
if (!isMouseHidden) {
// try to load the cursor-theme into a OpenGL texture and if successful then hide the mouse-pointer
GLTexture *texture = nullptr;
@ -225,8 +226,9 @@ void ZoomEffect::reconfigure(ReconfigureFlags)
// Load the saved zoom value.
source_zoom = 1.0;
target_zoom = ZoomConfig::initialZoom();
if (target_zoom > 1.0)
if (target_zoom > 1.0) {
zoomIn(target_zoom);
}
} else {
source_zoom = 1.0;
}
@ -236,15 +238,17 @@ void ZoomEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseco
{
if (zoom != target_zoom) {
int time = 0;
if (lastPresentTime.count())
if (lastPresentTime.count()) {
time = (presentTime - lastPresentTime).count();
}
lastPresentTime = presentTime;
const float zoomDist = qAbs(target_zoom - source_zoom);
if (target_zoom > zoom)
if (target_zoom > zoom) {
zoom = qMin(zoom + ((zoomDist * time) / animationTime(150 * zoomFactor)), target_zoom);
else
} else {
zoom = qMax(zoom - ((zoomDist * time) / animationTime(150 * zoomFactor)), target_zoom);
}
}
if (zoom == 1.0) {
@ -283,18 +287,22 @@ void ZoomEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &d
int y = cursorPoint.y() * zoom - prevPoint.y() * (zoom - 1.0);
int threshold = 4;
xMove = yMove = 0;
if (x < threshold)
if (x < threshold) {
xMove = (x - threshold) / zoom;
else if (x + threshold > screenSize.width())
} else if (x + threshold > screenSize.width()) {
xMove = (x + threshold - screenSize.width()) / zoom;
if (y < threshold)
}
if (y < threshold) {
yMove = (y - threshold) / zoom;
else if (y + threshold > screenSize.height())
} else if (y + threshold > screenSize.height()) {
yMove = (y + threshold - screenSize.height()) / zoom;
if (xMove)
}
if (xMove) {
prevPoint.setX(qMax(0, qMin(screenSize.width(), prevPoint.x() + xMove)));
if (yMove)
}
if (yMove) {
prevPoint.setY(qMax(0, qMin(screenSize.height(), prevPoint.y() + yMove)));
}
data.setXTranslation(-int(prevPoint.x() * (zoom - 1.0)));
data.setYTranslation(-int(prevPoint.y() * (zoom - 1.0)));
break;
@ -353,27 +361,30 @@ void ZoomEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &d
void ZoomEffect::postPaintScreen()
{
if (zoom != target_zoom)
if (zoom != target_zoom) {
effects->addRepaintFull();
else
} else {
lastPresentTime = std::chrono::milliseconds::zero();
}
effects->postPaintScreen();
}
void ZoomEffect::zoomIn(double to)
{
source_zoom = zoom;
if (to < 0.0)
if (to < 0.0) {
target_zoom *= zoomFactor;
else
} else {
target_zoom = to;
}
if (!polling) {
polling = true;
effects->startMousePolling();
}
cursorPoint = effects->cursorPos();
if (mouseTracking == MouseTrackingDisabled)
if (mouseTracking == MouseTrackingDisabled) {
prevPoint = cursorPoint;
}
effects->addRepaintFull();
}
@ -388,8 +399,9 @@ void ZoomEffect::zoomOut()
effects->stopMousePolling();
}
}
if (mouseTracking == MouseTrackingDisabled)
if (mouseTracking == MouseTrackingDisabled) {
prevPoint = effects->cursorPos();
}
effects->addRepaintFull();
}
@ -415,23 +427,26 @@ void ZoomEffect::timelineFrameChanged(int /* frame */)
void ZoomEffect::moveZoom(int x, int y)
{
if (timeline.state() == QTimeLine::Running)
if (timeline.state() == QTimeLine::Running) {
timeline.stop();
}
const QSize screenSize = effects->virtualScreenSize();
if (x < 0)
if (x < 0) {
xMove = -qMax(1.0, screenSize.width() / zoom / moveFactor);
else if (x > 0)
} else if (x > 0) {
xMove = qMax(1.0, screenSize.width() / zoom / moveFactor);
else
} else {
xMove = 0;
}
if (y < 0)
if (y < 0) {
yMove = -qMax(1.0, screenSize.height() / zoom / moveFactor);
else if (y > 0)
} else if (y > 0) {
yMove = qMax(1.0, screenSize.height() / zoom / moveFactor);
else
} else {
yMove = 0;
}
timeline.start();
}
@ -470,8 +485,9 @@ void ZoomEffect::moveMouseToCenter()
void ZoomEffect::slotMouseChanged(const QPoint &pos, const QPoint &old, Qt::MouseButtons,
Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers)
{
if (zoom == 1.0)
if (zoom == 1.0) {
return;
}
cursorPoint = pos;
if (pos != old) {
lastMouseEvent = QTime::currentTime();
@ -488,8 +504,9 @@ void ZoomEffect::slotWindowDamaged()
void ZoomEffect::moveFocus(const QPoint &point)
{
if (zoom == 1.0)
if (zoom == 1.0) {
return;
}
focusPoint = point;
lastFocusEvent = QTime::currentTime();
effects->addRepaintFull();

View File

@ -151,34 +151,41 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
{
const uint8_t eventType = e->response_type & ~0x80;
if (effects && static_cast<EffectsHandlerImpl *>(effects)->hasKeyboardGrab()
&& (eventType == XCB_KEY_PRESS || eventType == XCB_KEY_RELEASE))
&& (eventType == XCB_KEY_PRESS || eventType == XCB_KEY_RELEASE)) {
return false; // let Qt process it, it'll be intercepted again in eventFilter()
}
// events that should be handled before Clients can get them
switch (eventType) {
case XCB_CONFIGURE_NOTIFY:
if (reinterpret_cast<xcb_configure_notify_event_t *>(e)->event == kwinApp()->x11RootWindow())
if (reinterpret_cast<xcb_configure_notify_event_t *>(e)->event == kwinApp()->x11RootWindow()) {
markXStackingOrderAsDirty();
}
break;
};
const xcb_window_t eventWindow = findEventWindow(e);
if (eventWindow != XCB_WINDOW_NONE) {
if (X11Client *c = findClient(Predicate::WindowMatch, eventWindow)) {
if (c->windowEvent(e))
if (c->windowEvent(e)) {
return true;
}
} else if (X11Client *c = findClient(Predicate::WrapperIdMatch, eventWindow)) {
if (c->windowEvent(e))
if (c->windowEvent(e)) {
return true;
}
} else if (X11Client *c = findClient(Predicate::FrameIdMatch, eventWindow)) {
if (c->windowEvent(e))
if (c->windowEvent(e)) {
return true;
}
} else if (X11Client *c = findClient(Predicate::InputIdMatch, eventWindow)) {
if (c->windowEvent(e))
if (c->windowEvent(e)) {
return true;
}
} else if (Unmanaged *c = findUnmanaged(eventWindow)) {
if (c->windowEvent(e))
if (c->windowEvent(e)) {
return true;
}
}
}
@ -231,8 +238,9 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
const auto *event = reinterpret_cast<xcb_map_notify_event_t *>(e);
if (event->override_redirect) {
Unmanaged *c = findUnmanaged(event->window);
if (c == nullptr)
if (c == nullptr) {
c = createUnmanaged(event->window);
}
if (c) {
// if hasScheduledRelease is true, it means a unamp and map sequence has occurred.
// since release is scheduled after map notify, this old Unmanaged will get released
@ -241,8 +249,9 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
c->release();
c = createUnmanaged(event->window);
}
if (c)
if (c) {
return c->windowEvent(e);
}
}
}
return (event->event != event->window); // hide wm typical event from Qt
@ -287,12 +296,13 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
if (!currentInput.isNull() && (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT || lostFocusPointerToRoot)) {
// kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ;
AbstractClient *c = mostRecentlyActivatedClient();
if (c != nullptr)
if (c != nullptr) {
requestFocus(c, true);
else if (activateNextClient(nullptr))
} else if (activateNextClient(nullptr)) {
; // ok, activated
else
} else {
focusToNull();
}
}
}
}
@ -332,16 +342,19 @@ bool X11Client::windowEvent(xcb_generic_event_t *e)
NET::Properties2 dirtyProperties2;
info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff
if ((dirtyProperties & NET::WMName) != 0)
if ((dirtyProperties & NET::WMName) != 0) {
fetchName();
if ((dirtyProperties & NET::WMIconName) != 0)
}
if ((dirtyProperties & NET::WMIconName) != 0) {
fetchIconicName();
}
if ((dirtyProperties & NET::WMStrut) != 0
|| (dirtyProperties2 & NET::WM2ExtendedStrut) != 0) {
workspace()->updateClientArea();
}
if ((dirtyProperties & NET::WMIcon) != 0)
if ((dirtyProperties & NET::WMIcon) != 0) {
getIcons();
}
// Note there's a difference between userTime() and info->userTime()
// info->userTime() is the value of the property, userTime() also includes
// updates of the time done by KWin (ButtonPress on windowrapper etc.).
@ -349,8 +362,9 @@ bool X11Client::windowEvent(xcb_generic_event_t *e)
workspace()->setWasUserInteraction();
updateUserTime(info->userTime());
}
if ((dirtyProperties2 & NET::WM2StartupId) != 0)
if ((dirtyProperties2 & NET::WM2StartupId) != 0) {
startupIdChanged();
}
if (dirtyProperties2 & NET::WM2Opacity) {
if (Compositor::compositing()) {
setOpacity(info->opacityF());
@ -481,8 +495,9 @@ bool X11Client::windowEvent(xcb_generic_event_t *e)
detectShape(window()); // workaround for #19644
updateShape();
}
if (eventType == Xcb::Extensions::self()->damageNotifyEvent() && reinterpret_cast<xcb_damage_notify_event_t *>(e)->drawable == frameId())
if (eventType == Xcb::Extensions::self()->damageNotifyEvent() && reinterpret_cast<xcb_damage_notify_event_t *>(e)->drawable == frameId()) {
damageNotifyEvent();
}
break;
}
return true; // eat all events
@ -506,20 +521,24 @@ bool X11Client::mapRequestEvent(xcb_map_request_event_t *e)
// always maps. Returning true here means that Workspace::workspaceEvent()
// will handle this MapRequest and manage this window (i.e. act as if
// it was reparented to root window).
if (e->parent == wrapperId())
if (e->parent == wrapperId()) {
return false;
}
return true; // no messing with frame etc.
}
// also copied in clientMessage()
if (isMinimized())
if (isMinimized()) {
unminimize();
if (isShade())
}
if (isShade()) {
setShade(ShadeNone);
}
if (!isOnCurrentDesktop()) {
if (workspace()->allowClientActivation(this))
if (workspace()->allowClientActivation(this)) {
workspace()->activateClient(this);
else
} else {
demandAttention();
}
}
return true;
}
@ -529,15 +548,18 @@ bool X11Client::mapRequestEvent(xcb_map_request_event_t *e)
*/
void X11Client::unmapNotifyEvent(xcb_unmap_notify_event_t *e)
{
if (e->window != window())
if (e->window != window()) {
return;
}
if (e->event != wrapperId()) {
// most probably event from root window when initially reparenting
bool ignore = true;
if (e->event == kwinApp()->x11RootWindow() && (e->response_type & 0x80))
if (e->event == kwinApp()->x11RootWindow() && (e->response_type & 0x80)) {
ignore = false; // XWithdrawWindow()
if (ignore)
}
if (ignore) {
return;
}
}
// check whether this is result of an XReparentWindow - client then won't be parented by wrapper
@ -554,8 +576,9 @@ void X11Client::unmapNotifyEvent(xcb_unmap_notify_event_t *e)
void X11Client::destroyNotifyEvent(xcb_destroy_notify_event_t *e)
{
if (e->window != window())
if (e->window != window()) {
return;
}
destroyClient();
}
@ -565,12 +588,14 @@ void X11Client::destroyNotifyEvent(xcb_destroy_notify_event_t *e)
void X11Client::clientMessageEvent(xcb_client_message_event_t *e)
{
Toplevel::clientMessageEvent(e);
if (e->window != window())
if (e->window != window()) {
return; // ignore frame/wrapper
}
// WM_STATE
if (e->type == atoms->wm_change_state) {
if (e->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC)
if (e->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) {
minimize();
}
return;
}
}
@ -580,10 +605,12 @@ void X11Client::clientMessageEvent(xcb_client_message_event_t *e)
*/
void X11Client::configureRequestEvent(xcb_configure_request_event_t *e)
{
if (e->window != window())
if (e->window != window()) {
return; // ignore frame/wrapper
if (isInteractiveResize() || isInteractiveMove())
}
if (isInteractiveResize() || isInteractiveMove()) {
return; // we have better things to do right now
}
if (m_fullscreenMode == FullScreenNormal) { // refuse resizing of fullscreen windows
// but allow resizing fullscreen hacks in order to let them cancel fullscreen mode
@ -600,11 +627,13 @@ void X11Client::configureRequestEvent(xcb_configure_request_event_t *e)
m_client.setBorderWidth(0);
}
if (e->value_mask & (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_WIDTH))
if (e->value_mask & (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_WIDTH)) {
configureRequest(e->value_mask, e->x, e->y, e->width, e->height, 0, false);
}
if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE)
if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
restackWindow(e->sibling, e->stack_mode, NET::FromApplication, userTime(), false);
}
// Sending a synthetic configure notify always is fine, even in cases where
// the ICCCM doesn't require this - it can be though of as 'the WM decided to move
@ -623,8 +652,9 @@ void X11Client::configureRequestEvent(xcb_configure_request_event_t *e)
void X11Client::propertyNotifyEvent(xcb_property_notify_event_t *e)
{
Toplevel::propertyNotifyEvent(e);
if (e->window != window())
if (e->window != window()) {
return; // ignore frame/wrapper
}
switch (e->atom) {
case XCB_ATOM_WM_NORMAL_HINTS:
getWmNormalHints();
@ -644,20 +674,21 @@ void X11Client::propertyNotifyEvent(xcb_property_notify_event_t *e)
default:
if (e->atom == atoms->motif_wm_hints) {
getMotifHints();
} else if (e->atom == atoms->net_wm_sync_request_counter)
} else if (e->atom == atoms->net_wm_sync_request_counter) {
getSyncCounter();
else if (e->atom == atoms->activities)
} else if (e->atom == atoms->activities) {
checkActivities();
else if (e->atom == atoms->kde_first_in_window_list)
} else if (e->atom == atoms->kde_first_in_window_list) {
updateFirstInTabBox();
else if (e->atom == atoms->kde_color_sheme)
} else if (e->atom == atoms->kde_color_sheme) {
updateColorScheme();
else if (e->atom == atoms->kde_screen_edge_show)
} else if (e->atom == atoms->kde_screen_edge_show) {
updateShowOnScreenEdge();
else if (e->atom == atoms->kde_net_wm_appmenu_service_name)
} else if (e->atom == atoms->kde_net_wm_appmenu_service_name) {
checkApplicationMenuServiceName();
else if (e->atom == atoms->kde_net_wm_appmenu_object_path)
} else if (e->atom == atoms->kde_net_wm_appmenu_object_path) {
checkApplicationMenuObjectPath();
}
break;
}
}
@ -667,8 +698,9 @@ void X11Client::enterNotifyEvent(xcb_enter_notify_event_t *e)
if (waylandServer()) {
return;
}
if (e->event != frameId())
if (e->event != frameId()) {
return; // care only about entering the whole frame
}
#define MOUSE_DRIVEN_FOCUS (!options->focusPolicyIsReasonable() || (options->focusPolicy() == Options::FocusFollowsMouse && options->isNextFocusPrefersMouse()))
if (e->mode == XCB_NOTIFY_MODE_NORMAL || (e->mode == XCB_NOTIFY_MODE_UNGRAB && MOUSE_DRIVEN_FOCUS)) {
@ -684,8 +716,9 @@ void X11Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
if (waylandServer()) {
return;
}
if (e->event != frameId())
if (e->event != frameId()) {
return; // care only about leaving the whole frame
}
if (e->mode == XCB_NOTIFY_MODE_NORMAL) {
if (!isInteractiveMoveResizePointerButtonDown()) {
setInteractiveMoveResizeGravity(Gravity::None);
@ -750,8 +783,9 @@ void X11Client::establishCommandWindowGrab(uint8_t button)
0, XCapL, XNumL, XNumL | XCapL,
XScrL, XScrL | XCapL,
XScrL | XNumL, XScrL | XNumL | XCapL};
for (int i = 0; i < 8; ++i)
for (int i = 0; i < 8; ++i) {
m_wrapper.ungrabButton(x11Modifier | mods[i], button);
}
}
void X11Client::establishCommandAllGrab(uint8_t button)
@ -762,8 +796,9 @@ void X11Client::establishCommandAllGrab(uint8_t button)
0, XCapL, XNumL, XNumL | XCapL,
XScrL, XScrL | XCapL,
XScrL | XNumL, XScrL | XNumL | XCapL};
for (int i = 0; i < 8; ++i)
for (int i = 0; i < 8; ++i) {
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, x11Modifier | mods[i], button);
}
}
#undef XCapL
#undef XNumL
@ -841,8 +876,9 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i
return true;
}
if (isInteractiveMoveResizePointerButtonDown()) {
if (w == wrapperId())
if (w == wrapperId()) {
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
}
return true;
}
@ -855,8 +891,9 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i
&& button == XCB_BUTTON_INDEX_1 && !bModKeyHeld) {
// hide splashwindow if the user clicks on it
hideClient();
if (w == wrapperId())
if (w == wrapperId()) {
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
}
return true;
}
@ -891,11 +928,13 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i
if (was_action) {
bool replay = performMouseCommand(com, QPoint(x_root, y_root));
if (isSpecialWindow())
if (isSpecialWindow()) {
replay = true;
}
if (w == wrapperId()) // these can come only from a grab
if (w == wrapperId()) { // these can come only from a grab
xcb_allow_events(kwinApp()->x11Connection(), replay ? XCB_ALLOW_REPLAY_POINTER : XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
}
return true;
}
}
@ -977,8 +1016,9 @@ bool X11Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x,
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
return true;
}
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow()) {
return true;
}
if (w == frameId() && workspace()->userActionsMenu() && workspace()->userActionsMenu()->isShown()) {
const_cast<UserActionsMenu *>(workspace()->userActionsMenu())->grabInput();
}
@ -987,12 +1027,13 @@ bool X11Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x,
// Check whether other buttons are still left pressed
int buttonMask = XCB_BUTTON_MASK_1 | XCB_BUTTON_MASK_2 | XCB_BUTTON_MASK_3;
if (button == XCB_BUTTON_INDEX_1)
if (button == XCB_BUTTON_INDEX_1) {
buttonMask &= ~XCB_BUTTON_MASK_1;
else if (button == XCB_BUTTON_INDEX_2)
} else if (button == XCB_BUTTON_INDEX_2) {
buttonMask &= ~XCB_BUTTON_MASK_2;
else if (button == XCB_BUTTON_INDEX_3)
} else if (button == XCB_BUTTON_INDEX_3) {
buttonMask &= ~XCB_BUTTON_MASK_3;
}
if ((state & buttonMask) == 0) {
endInteractiveMoveResize();
@ -1011,8 +1052,9 @@ bool X11Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x
QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y));
QCoreApplication::instance()->sendEvent(decoration(), &event);
}
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow()) {
return true; // care only about the whole frame
}
if (!isInteractiveMoveResizePointerButtonDown()) {
if (w == inputId()) {
int x = x_root - frameGeometry().x(); // + padding_left;
@ -1045,14 +1087,18 @@ bool X11Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x
void X11Client::focusInEvent(xcb_focus_in_event_t *e)
{
if (e->event != window())
if (e->event != window()) {
return; // only window gets focus
if (e->mode == XCB_NOTIFY_MODE_UNGRAB)
}
if (e->mode == XCB_NOTIFY_MODE_UNGRAB) {
return; // we don't care
if (e->detail == XCB_NOTIFY_DETAIL_POINTER)
}
if (e->detail == XCB_NOTIFY_DETAIL_POINTER) {
return; // we don't care
if (isShade() || !isShown() || !isOnCurrentDesktop()) // we unmapped it, but it got focus meanwhile ->
}
if (isShade() || !isShown() || !isOnCurrentDesktop()) { // we unmapped it, but it got focus meanwhile ->
return; // activateNextClient() already transferred focus elsewhere
}
workspace()->forEachClient([](X11Client *client) {
client->cancelFocusOutTimer();
});
@ -1073,18 +1119,23 @@ void X11Client::focusInEvent(xcb_focus_in_event_t *e)
void X11Client::focusOutEvent(xcb_focus_out_event_t *e)
{
if (e->event != window())
if (e->event != window()) {
return; // only window gets focus
if (e->mode == XCB_NOTIFY_MODE_GRAB)
}
if (e->mode == XCB_NOTIFY_MODE_GRAB) {
return; // we don't care
if (isShade())
}
if (isShade()) {
return; // here neither
}
if (e->detail != XCB_NOTIFY_DETAIL_NONLINEAR
&& e->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL)
&& e->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) {
// SELI check all this
return; // hack for motif apps like netscape
if (QApplication::activePopupWidget())
}
if (QApplication::activePopupWidget()) {
return;
}
// When a client loses focus, FocusOut events are usually immediatelly
// followed by FocusIn events for another client that gains the focus
@ -1135,17 +1186,20 @@ void X11Client::NETMoveResize(int x_root, int y_root, NET::Direction direction)
Gravity::Bottom,
Gravity::BottomLeft,
Gravity::Left};
if (!isResizable() || isShade())
if (!isResizable() || isShade()) {
return;
if (isInteractiveMoveResize())
}
if (isInteractiveMoveResize()) {
finishInteractiveMoveResize(false);
}
setInteractiveMoveResizePointerButtonDown(true);
setInteractiveMoveOffset(QPoint(x_root - x(), y_root - y())); // map from global
setInvertedInteractiveMoveOffset(rect().bottomRight() - interactiveMoveOffset());
setUnrestrictedInteractiveMoveResize(false);
setInteractiveMoveResizeGravity(convert[direction]);
if (!startInteractiveMoveResize())
if (!startInteractiveMoveResize()) {
setInteractiveMoveResizePointerButtonDown(false);
}
updateCursor();
} else if (direction == NET::KeyboardMove) {
// ignore mouse coordinates given in the message, mouse position is used by the moving algorithm
@ -1232,8 +1286,9 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e)
addWorkspaceRepaint(frameGeometry()); // in case shape change removes part of this window
Q_EMIT geometryShapeChanged(this, frameGeometry());
}
if (eventType == Xcb::Extensions::self()->damageNotifyEvent())
if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) {
damageNotifyEvent();
}
break;
}
}
@ -1242,8 +1297,9 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e)
void Unmanaged::configureNotifyEvent(xcb_configure_notify_event_t *e)
{
if (effects)
if (effects) {
static_cast<EffectsHandlerImpl *>(effects)->checkInputWindowStacking(); // keep them on top
}
QRect newgeom(e->x, e->y, e->width, e->height);
if (newgeom != m_frameGeometry) {
QRect old = m_frameGeometry;
@ -1263,16 +1319,18 @@ void Unmanaged::configureNotifyEvent(xcb_configure_notify_event_t *e)
void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e)
{
if (e->window != window())
if (e->window != window()) {
return; // ignore frame/wrapper
}
switch (e->atom) {
default:
if (e->atom == atoms->wm_client_leader)
if (e->atom == atoms->wm_client_leader) {
getWmClientLeader();
else if (e->atom == atoms->kde_net_wm_shadow)
} else if (e->atom == atoms->kde_net_wm_shadow) {
updateShadow();
else if (e->atom == atoms->kde_skip_close_animation)
} else if (e->atom == atoms->kde_skip_close_animation) {
getSkipCloseAnimation();
}
break;
}
}

View File

@ -49,9 +49,9 @@ Group::~Group()
QIcon Group::icon() const
{
if (leader_client != nullptr)
if (leader_client != nullptr) {
return leader_client->icon();
else if (leader_wid != XCB_WINDOW_NONE) {
} else if (leader_wid != XCB_WINDOW_NONE) {
QIcon ic;
NETWinInfo info(kwinApp()->x11Connection(), leader_wid, kwinApp()->x11RootWindow(), NET::WMIcon, NET::WM2IconPixmap);
auto readIcon = [&ic, &info, this](int size, bool scale = true) {

View File

@ -57,8 +57,9 @@ Monitor::Monitor(QWidget *parent)
setRatio((qreal)avail.width() / (qreal)avail.height());
for (int i = 0;
i < 8;
++i)
++i) {
popups[i] = new QMenu(this);
}
scene = new QGraphicsScene(this);
view = new QGraphicsView(scene, this);
view->setBackgroundBrush(Qt::black);
@ -137,10 +138,11 @@ void Monitor::setEdgeEnabled(int edge, bool enabled)
void Monitor::setEdgeHidden(int edge, bool set)
{
hidden[edge] = set;
if (set)
if (set) {
items[edge]->hide();
else
} else {
items[edge]->show();
}
}
bool Monitor::edgeHidden(int edge) const
@ -198,8 +200,9 @@ void Monitor::popup(Corner *c, QPoint pos)
i < 8;
++i) {
if (items[i] == c) {
if (popup_actions[i].count() == 0)
if (popup_actions[i].count() == 0) {
return;
}
if (QAction *a = popups[i]->exec(pos)) {
selectEdgeItem(i, popup_actions[i].indexOf(a));
Q_EMIT changed();
@ -218,10 +221,11 @@ void Monitor::flip(Corner *c, QPoint pos)
i < 8;
++i) {
if (items[i] == c) {
if (popup_actions[i].count() == 0)
if (popup_actions[i].count() == 0) {
setEdge(i, !edge(i));
else
} else {
popup(c, pos);
}
return;
}
}

View File

@ -136,14 +136,16 @@ void ScreenPreviewWidget::paintEvent(QPaintEvent *event)
void ScreenPreviewWidget::dropEvent(QDropEvent *e)
{
if (!e->mimeData()->hasUrls())
if (!e->mimeData()->hasUrls()) {
return;
}
QList<QUrl> uris(KUrlMimeData::urlsFromMimeData(e->mimeData()));
if (!uris.isEmpty()) {
// TODO: Download remote file
if (uris.first().isLocalFile())
if (uris.first().isLocalFile()) {
Q_EMIT imageDropped(uris.first().path());
}
}
}

View File

@ -63,20 +63,23 @@ const char *const *BrightnessSaturationShader::attributeNames() const
void BrightnessSaturationShader::updateState(const QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_ASSERT(program()->isLinked());
if (state.isMatrixDirty())
if (state.isMatrixDirty()) {
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
if (state.isOpacityDirty())
}
if (state.isOpacityDirty()) {
program()->setUniformValue(m_id_opacity, state.opacity());
}
auto *tx = static_cast<BrightnessSaturationMaterial *>(newMaterial);
auto *oldTx = static_cast<BrightnessSaturationMaterial *>(oldMaterial);
QSGTexture *t = tx->texture();
t->setFiltering(QSGTexture::Linear);
if (!oldTx || oldTx->texture()->textureId() != t->textureId())
if (!oldTx || oldTx->texture()->textureId() != t->textureId()) {
t->bind();
else
} else {
t->updateBindOptions();
}
program()->setUniformValue(m_id_saturation, static_cast<float>(tx->saturation));
program()->setUniformValue(m_id_brightness, static_cast<float>(tx->brightness));

View File

@ -97,8 +97,9 @@ namespace KWin
void Workspace::updateStackingOrder(bool propagate_new_clients)
{
if (block_stacking_updates > 0) {
if (propagate_new_clients)
if (propagate_new_clients) {
blocked_propagating_new_clients = true;
}
return;
}
QList<Toplevel *> new_stacking_order = constrainedStackingOrder();
@ -115,8 +116,9 @@ void Workspace::updateStackingOrder(bool propagate_new_clients)
Q_EMIT stackingOrderChanged();
if (active_client)
if (active_client) {
active_client->updateMouseGrab();
}
}
}
@ -167,9 +169,10 @@ void Workspace::propagateClients(bool propagate_new_clients)
continue;
}
if (client->inputId())
if (client->inputId()) {
// Stack the input window above the frame
newWindowStack << client->inputId();
}
newWindowStack << client->frameId();
}
@ -179,8 +182,9 @@ void Workspace::propagateClients(bool propagate_new_clients)
// these windows that should be unmapped to interfere with other windows
for (int i = stacking_order.size() - 1; i >= 0; --i) {
X11Client *client = qobject_cast<X11Client *>(stacking_order.at(i));
if (!client || !client->hiddenPreview())
if (!client || !client->hiddenPreview()) {
continue;
}
newWindowStack << client->frameId();
}
// TODO isn't it too inefficient to restack always all clients?
@ -195,8 +199,9 @@ void Workspace::propagateClients(bool propagate_new_clients)
for (const auto win : qAsConst(manual_overlays)) {
cl[pos++] = win;
}
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it)
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it) {
cl[pos++] = (*it)->window();
}
rootInfo()->setClientList(cl, pos);
delete[] cl;
}
@ -226,22 +231,26 @@ AbstractClient *Workspace::topClientOnDesktop(VirtualDesktop *desktop, AbstractO
{
// TODO Q_ASSERT( block_stacking_updates == 0 );
QList<Toplevel *> list;
if (!unconstrained)
if (!unconstrained) {
list = stacking_order;
else
} else {
list = unconstrained_stacking_order;
}
for (int i = list.size() - 1; i >= 0; --i) {
AbstractClient *c = qobject_cast<AbstractClient *>(list.at(i));
if (!c) {
continue;
}
if (c->isOnDesktop(desktop) && c->isShown() && c->isOnCurrentActivity() && !c->isShade()) {
if (output && c->output() != output)
if (output && c->output() != output) {
continue;
if (!only_normal)
}
if (!only_normal) {
return c;
if (c->wantsTabFocus() && !c->isSpecialWindow())
}
if (c->wantsTabFocus() && !c->isSpecialWindow()) {
return c;
}
}
}
return nullptr;
@ -278,16 +287,18 @@ void Workspace::raiseOrLowerClient(AbstractClient *c)
topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(),
options->isSeparateScreenFocus() ? c->output() : nullptr);
if (c == topmost)
if (c == topmost) {
lowerClient(c);
else
} else {
raiseClient(c);
}
}
void Workspace::lowerClient(AbstractClient *c, bool nogroup)
{
if (!c)
if (!c) {
return;
}
c->cancelAutoRaise();
@ -302,16 +313,18 @@ void Workspace::lowerClient(AbstractClient *c, bool nogroup)
wins = ensureStackingOrder(group->members());
}
for (int i = wins.size() - 1; i >= 0; --i) {
if (wins[i] != c)
if (wins[i] != c) {
lowerClient(wins[i], true);
}
}
}
}
void Workspace::lowerClientWithinApplication(AbstractClient *c)
{
if (!c)
if (!c) {
return;
}
c->cancelAutoRaise();
@ -331,15 +344,17 @@ void Workspace::lowerClientWithinApplication(AbstractClient *c)
break;
}
}
if (!lowered)
if (!lowered) {
unconstrained_stacking_order.prepend(c);
}
// ignore mainwindows
}
void Workspace::raiseClient(AbstractClient *c, bool nogroup)
{
if (!c)
if (!c) {
return;
}
c->cancelAutoRaise();
@ -348,8 +363,9 @@ void Workspace::raiseClient(AbstractClient *c, bool nogroup)
if (!nogroup && c->isTransient()) {
QList<AbstractClient *> transients;
AbstractClient *transient_parent = c;
while ((transient_parent = transient_parent->transientFor()))
while ((transient_parent = transient_parent->transientFor())) {
transients << transient_parent;
}
for (const auto &transient_parent : qAsConst(transients)) {
raiseClient(transient_parent, true);
}
@ -361,8 +377,9 @@ void Workspace::raiseClient(AbstractClient *c, bool nogroup)
void Workspace::raiseClientWithinApplication(AbstractClient *c)
{
if (!c)
if (!c) {
return;
}
c->cancelAutoRaise();
@ -375,8 +392,9 @@ void Workspace::raiseClientWithinApplication(AbstractClient *c)
if (!other) {
continue;
}
if (other == c) // don't lower it just because it asked to be raised
if (other == c) { // don't lower it just because it asked to be raised
return;
}
if (AbstractClient::belongToSameApplication(other, c)) {
unconstrained_stacking_order.removeAll(c);
unconstrained_stacking_order.insert(unconstrained_stacking_order.indexOf(other) + 1, c); // insert after the found one
@ -387,9 +405,9 @@ void Workspace::raiseClientWithinApplication(AbstractClient *c)
void Workspace::raiseClientRequest(KWin::AbstractClient *c, NET::RequestSource src, xcb_timestamp_t timestamp)
{
if (src == NET::FromTool || allowFullClientRaising(c, timestamp))
if (src == NET::FromTool || allowFullClientRaising(c, timestamp)) {
raiseClient(c);
else {
} else {
raiseClientWithinApplication(c);
c->demandAttention();
}
@ -401,10 +419,11 @@ void Workspace::lowerClientRequest(KWin::X11Client *c, NET::RequestSource src, x
// do only lowering within the application, as that's the more logical
// variant of lowering when application requests it.
// No demanding of attention here of course.
if (src == NET::FromTool || !c->hasUserTimeSupport())
if (src == NET::FromTool || !c->hasUserTimeSupport()) {
lowerClient(c);
else
} else {
lowerClientWithinApplication(c);
}
}
void Workspace::lowerClientRequest(KWin::AbstractClient *c)
@ -446,8 +465,9 @@ void Workspace::restackClientUnderActive(AbstractClient *c)
void Workspace::restoreSessionStackingOrder(X11Client *c)
{
if (c->sessionStackingOrder() < 0)
if (c->sessionStackingOrder() < 0) {
return;
}
StackingUpdatesBlocker blocker(this);
unconstrained_stacking_order.removeAll(c);
for (auto it = unconstrained_stacking_order.begin(); it != unconstrained_stacking_order.end(); ++it) {
@ -559,14 +579,16 @@ QList<Toplevel *> Workspace::constrainedStackingOrder()
void Workspace::blockStackingUpdates(bool block)
{
if (block) {
if (block_stacking_updates == 0)
if (block_stacking_updates == 0) {
blocked_propagating_new_clients = false;
}
++block_stacking_updates;
} else // !block
if (--block_stacking_updates == 0) {
updateStackingOrder(blocked_propagating_new_clients);
if (effects)
if (effects) {
static_cast<EffectsHandlerImpl *>(effects)->checkInputWindowStacking();
}
}
}
@ -578,8 +600,9 @@ QList<T *> ensureStackingOrderInList(const QList<Toplevel *> &stackingOrder, con
static_assert(std::is_base_of<Toplevel, T>::value,
"U must be derived from T");
// TODO Q_ASSERT( block_stacking_updates == 0 );
if (list.count() < 2)
if (list.count() < 2) {
return list;
}
// TODO is this worth optimizing?
QList<T *> result = list;
for (auto it = stackingOrder.begin(); it != stackingOrder.end(); ++it) {
@ -587,8 +610,9 @@ QList<T *> ensureStackingOrderInList(const QList<Toplevel *> &stackingOrder, con
if (!c) {
continue;
}
if (result.removeAll(c) != 0)
if (result.removeAll(c) != 0) {
result.append(c);
}
}
return result;
}
@ -669,18 +693,21 @@ void X11Client::restackWindow(xcb_window_t above, int detail, NET::RequestSource
}
} else if (detail == XCB_STACK_MODE_TOP_IF) {
other = workspace()->findClient(Predicate::WindowMatch, above);
if (other && other->frameGeometry().intersects(frameGeometry()))
if (other && other->frameGeometry().intersects(frameGeometry())) {
workspace()->raiseClientRequest(this, src, timestamp);
}
return;
} else if (detail == XCB_STACK_MODE_BOTTOM_IF) {
other = workspace()->findClient(Predicate::WindowMatch, above);
if (other && other->frameGeometry().intersects(frameGeometry()))
if (other && other->frameGeometry().intersects(frameGeometry())) {
workspace()->lowerClientRequest(this, src, timestamp);
}
return;
}
if (!other)
if (!other) {
other = workspace()->findClient(Predicate::WindowMatch, above);
}
if (other && detail == XCB_STACK_MODE_ABOVE) {
auto it = workspace()->stackingOrder().constEnd(),
@ -694,36 +721,42 @@ void X11Client::restackWindow(xcb_window_t above, int detail, NET::RequestSource
}
X11Client *c = qobject_cast<X11Client *>(*it);
if (!c || !((*it)->isNormalWindow() && c->isShown() && (*it)->isOnCurrentDesktop() && (*it)->isOnCurrentActivity() && (*it)->isOnOutput(output())))
if (!c || !((*it)->isNormalWindow() && c->isShown() && (*it)->isOnCurrentDesktop() && (*it)->isOnCurrentActivity() && (*it)->isOnOutput(output()))) {
continue; // irrelevant clients
}
if (*(it - 1) == other)
if (*(it - 1) == other) {
break; // "it" is the one above the target one, stack below "it"
}
}
if (it != begin && (*(it - 1) == other))
if (it != begin && (*(it - 1) == other)) {
other = qobject_cast<X11Client *>(*it);
else
} else {
other = nullptr;
}
}
if (other)
if (other) {
workspace()->restack(this, other);
else if (detail == XCB_STACK_MODE_BELOW)
} else if (detail == XCB_STACK_MODE_BELOW) {
workspace()->lowerClientRequest(this, src, timestamp);
else if (detail == XCB_STACK_MODE_ABOVE)
} else if (detail == XCB_STACK_MODE_ABOVE) {
workspace()->raiseClientRequest(this, src, timestamp);
}
if (send_event)
if (send_event) {
sendSyntheticConfigureNotify();
}
}
bool X11Client::belongsToDesktop() const
{
const auto members = group()->members();
for (const X11Client *c : members) {
if (c->isDesktop())
if (c->isDesktop()) {
return true;
}
}
return false;
}

View File

@ -48,8 +48,9 @@ AnimationEffect::AnimationEffect()
: d_ptr(new AnimationEffectPrivate())
{
Q_D(AnimationEffect);
if (!s_clock.isValid())
if (!s_clock.isValid()) {
s_clock.start();
}
/* this is the same as the QTimer::singleShot(0, SLOT(init())) kludge
* defering the init and esp. the connection to the windowClosed slot */
QMetaObject::invokeMethod(this, &AnimationEffect::init, Qt::QueuedConnection);
@ -63,8 +64,9 @@ AnimationEffect::~AnimationEffect()
void AnimationEffect::init()
{
Q_D(AnimationEffect);
if (d->m_isInitialized)
if (d->m_isInitialized) {
return; // not more than once, please
}
d->m_isInitialized = true;
/* by connecting the signal from a slot AFTER the inheriting class constructor had the chance to
* connect it we can provide auto-referencing of animated and closed windows, since at the time
@ -108,10 +110,12 @@ void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, co
to->set(0.0, 0.0);
}
}
if (from && !from->isValid())
if (from && !from->isValid()) {
from->set(1.0, 1.0);
if (to && !to->isValid())
}
if (to && !to->isValid()) {
to->set(1.0, 1.0);
}
} else if (a == Position) {
QRect area = effects->clientArea(ScreenArea, w);
@ -208,15 +212,17 @@ quint64 AnimationEffect::p_animate(EffectWindow *w, Attribute a, uint meta, int
validate(a, meta, &from, &to, w);
Q_D(AnimationEffect);
if (!d->m_isInitialized)
if (!d->m_isInitialized) {
init(); // needs to ensure the window gets removed if deleted in the same event cycle
}
if (d->m_animations.isEmpty()) {
connect(effects, &EffectsHandler::windowExpandedGeometryChanged,
this, &AnimationEffect::_windowExpandedGeometryChanged);
}
AniMap::iterator it = d->m_animations.find(w);
if (it == d->m_animations.end())
if (it == d->m_animations.end()) {
it = d->m_animations.insert(w, QPair<QList<AniData>, QRect>(QList<AniData>(), QRect()));
}
FullScreenEffectLockPtr fullscreen;
if (fullScreenEffect) {
@ -267,8 +273,9 @@ quint64 AnimationEffect::p_animate(EffectWindow *w, Attribute a, uint meta, int
if (delay > 0) {
QTimer::singleShot(delay, this, &AnimationEffect::triggerRepaint);
const QSize &s = effects->virtualScreenSize();
if (waitAtSource)
if (waitAtSource) {
w->addLayerRepaint(0, 0, s.width(), s.height());
}
} else {
triggerRepaint();
}
@ -278,8 +285,9 @@ quint64 AnimationEffect::p_animate(EffectWindow *w, Attribute a, uint meta, int
bool AnimationEffect::retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime)
{
Q_D(AnimationEffect);
if (animationId == d->m_justEndedAnimation)
if (animationId == d->m_justEndedAnimation) {
return false; // this is just ending, do not try to retarget it
}
for (AniMap::iterator entry = d->m_animations.begin(),
mapEnd = d->m_animations.end();
entry != mapEnd; ++entry) {
@ -365,8 +373,9 @@ bool AnimationEffect::complete(quint64 animationId)
bool AnimationEffect::cancel(quint64 animationId)
{
Q_D(AnimationEffect);
if (animationId == d->m_justEndedAnimation)
if (animationId == d->m_justEndedAnimation) {
return true; // this is just ending, do not try to cancel it but fake success
}
for (AniMap::iterator entry = d->m_animations.begin(), mapEnd = d->m_animations.end(); entry != mapEnd; ++entry) {
for (QList<AniData>::iterator anim = entry->first.begin(), animEnd = entry->first.end(); anim != animEnd; ++anim) {
if (anim->id == animationId) {
@ -374,8 +383,9 @@ bool AnimationEffect::cancel(quint64 animationId)
if (entry->first.isEmpty()) { // no other animations on the window, release it.
d->m_animations.erase(entry);
}
if (d->m_animations.isEmpty())
if (d->m_animations.isEmpty()) {
disconnectGeometryChanges();
}
d->m_animationsTouched = true; // could be called from animationEnded
return true;
}
@ -408,22 +418,24 @@ void AnimationEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mill
static int xCoord(const QRect &r, int flag)
{
if (flag & AnimationEffect::Left)
if (flag & AnimationEffect::Left) {
return r.x();
else if (flag & AnimationEffect::Right)
} else if (flag & AnimationEffect::Right) {
return r.right();
else
} else {
return r.x() + r.width() / 2;
}
}
static int yCoord(const QRect &r, int flag)
{
if (flag & AnimationEffect::Top)
if (flag & AnimationEffect::Top) {
return r.y();
else if (flag & AnimationEffect::Bottom)
} else if (flag & AnimationEffect::Bottom) {
return r.bottom();
else
} else {
return r.y() + r.height() / 2;
}
}
QRect AnimationEffect::clipRect(const QRect &geo, const AniData &anim) const
@ -461,25 +473,27 @@ void AnimationEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data,
bool isUsed = false;
bool paintDeleted = false;
for (QList<AniData>::const_iterator anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim) {
if (anim->startTime > clock() && !anim->waitAtSource)
if (anim->startTime > clock() && !anim->waitAtSource) {
continue;
}
isUsed = true;
if (anim->attribute == Opacity || anim->attribute == CrossFadePrevious)
if (anim->attribute == Opacity || anim->attribute == CrossFadePrevious) {
data.setTranslucent();
else if (!(anim->attribute == Brightness || anim->attribute == Saturation)) {
} else if (!(anim->attribute == Brightness || anim->attribute == Saturation)) {
data.setTransformed();
}
paintDeleted |= anim->keepAlive;
}
if (isUsed) {
if (w->isMinimized())
if (w->isMinimized()) {
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE);
else if (w->isDeleted() && paintDeleted)
} else if (w->isDeleted() && paintDeleted) {
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
else if (!w->isOnCurrentDesktop())
} else if (!w->isOnCurrentDesktop()) {
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
}
// if( !w->isPaintingEnabled() && !effects->activeFullScreenEffect() )
// effects->addLayerRepaint(w->expandedGeometry());
}
@ -489,10 +503,12 @@ void AnimationEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data,
static inline float geometryCompensation(int flags, float v)
{
if (flags & (AnimationEffect::Left | AnimationEffect::Top))
if (flags & (AnimationEffect::Left | AnimationEffect::Top)) {
return 0.0; // no compensation required
if (flags & (AnimationEffect::Right | AnimationEffect::Bottom))
}
if (flags & (AnimationEffect::Right | AnimationEffect::Bottom)) {
return 1.0 - v; // full compensation
}
return 0.5 * (1.0 - v); // half compensation
}
@ -503,8 +519,9 @@ void AnimationEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Win
if (entry != d->m_animations.constEnd()) {
for (QList<AniData>::const_iterator anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim) {
if (anim->startTime > clock() && !anim->waitAtSource)
if (anim->startTime > clock() && !anim->waitAtSource) {
continue;
}
switch (anim->attribute) {
case Opacity:
@ -529,8 +546,9 @@ void AnimationEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Win
if (!anim->isOneDimensional()) {
f1 = interpolated(*anim, 1);
f2 = geometryCompensation(anim->meta & AnimationEffect::Vertical, f1);
} else if (((anim->meta & AnimationEffect::Vertical) >> 1) != (anim->meta & AnimationEffect::Horizontal))
} else if (((anim->meta & AnimationEffect::Vertical) >> 1) != (anim->meta & AnimationEffect::Horizontal)) {
f2 = geometryCompensation(anim->meta & AnimationEffect::Vertical, f1);
}
data.translate(0.0, f2 * sz.height());
data.setYScale(data.yScale() * f1);
}
@ -663,8 +681,9 @@ void AnimationEffect::postPaintScreen()
} else {
for (auto entry = d->m_animations.constBegin(); entry != d->m_animations.constEnd(); ++entry) {
for (auto anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim) {
if (anim->startTime > clock())
if (anim->startTime > clock()) {
continue;
}
if (!anim->timeLine.done()) {
entry.key()->addLayerRepaint(entry->second);
break;
@ -736,10 +755,11 @@ void AnimationEffect::setMetaData(MetaType type, uint value, uint &meta)
case RelativeTargetX:
case RelativeTargetY: {
const int shift = 10 + type - RelativeSourceX;
if (value)
if (value) {
meta |= (1 << shift);
else
} else {
meta &= ~(1 << shift);
}
break;
}
case Axis:
@ -754,8 +774,9 @@ void AnimationEffect::setMetaData(MetaType type, uint value, uint &meta)
void AnimationEffect::triggerRepaint()
{
Q_D(AnimationEffect);
for (AniMap::const_iterator entry = d->m_animations.constBegin(), mapEnd = d->m_animations.constEnd(); entry != mapEnd; ++entry)
for (AniMap::const_iterator entry = d->m_animations.constBegin(), mapEnd = d->m_animations.constEnd(); entry != mapEnd; ++entry) {
*const_cast<QRect *>(&(entry->second)) = QRect();
}
updateLayerRepaints();
if (d->m_needSceneRepaint) {
effects->addRepaintFull();
@ -790,16 +811,18 @@ void AnimationEffect::updateLayerRepaints()
Q_D(AnimationEffect);
d->m_needSceneRepaint = false;
for (AniMap::const_iterator entry = d->m_animations.constBegin(), mapEnd = d->m_animations.constEnd(); entry != mapEnd; ++entry) {
if (!entry->second.isNull())
if (!entry->second.isNull()) {
continue;
}
float f[2] = {1.0, 1.0};
float t[2] = {0.0, 0.0};
bool createRegion = false;
QList<QRect> rects;
QRect *layerRect = const_cast<QRect *>(&(entry->second));
for (QList<AniData>::const_iterator anim = entry->first.constBegin(), animEnd = entry->first.constEnd(); anim != animEnd; ++anim) {
if (anim->startTime > clock())
if (anim->startTime > clock()) {
continue;
}
switch (anim->attribute) {
case Opacity:
case Brightness:
@ -849,16 +872,18 @@ void AnimationEffect::updateLayerRepaints()
float fx = qMax(fixOvershoot(anim->from[0], *anim, 1), fixOvershoot(anim->to[0], *anim, 2));
// float fx = qMax(interpolated(*anim,0), anim->to[0]);
if (fx >= 0.0) {
if (anim->attribute == Size)
if (anim->attribute == Size) {
fx /= sz.width();
}
f[0] *= fx;
t[0] += geometryCompensation(anim->meta & AnimationEffect::Horizontal, fx) * sz.width();
}
// float fy = qMax(interpolated(*anim,1), anim->to[1]);
float fy = qMax(fixOvershoot(anim->from[1], *anim, 1), fixOvershoot(anim->to[1], *anim, 2));
if (fy >= 0.0) {
if (anim->attribute == Size)
if (anim->attribute == Size) {
fy /= sz.height();
}
if (!anim->isOneDimensional()) {
f[1] *= fy;
t[1] += geometryCompensation(anim->meta & AnimationEffect::Vertical, fy) * sz.height();
@ -874,8 +899,9 @@ void AnimationEffect::updateLayerRepaints()
region_creation:
if (createRegion) {
const QRect geo = entry.key()->expandedGeometry();
if (rects.isEmpty())
if (rects.isEmpty()) {
rects << geo;
}
QList<QRect>::const_iterator r, rEnd = rects.constEnd();
for (r = rects.constBegin(); r != rEnd; ++r) { // transform
const_cast<QRect *>(&(*r))->setSize(QSize(qRound(r->width() * f[0]), qRound(r->height() * f[1])));
@ -883,8 +909,9 @@ void AnimationEffect::updateLayerRepaints()
}
QRect rect = rects.at(0);
if (rects.count() > 1) {
for (r = rects.constBegin() + 1; r != rEnd; ++r) // unite
for (r = rects.constBegin() + 1; r != rEnd; ++r) { // unite
rect |= *r;
}
const int dx = 110 * (rect.width() - geo.width()) / 100 + 1 - rect.width() + geo.width();
const int dy = 110 * (rect.height() - geo.height()) / 100 + 1 - rect.height() + geo.height();
rect.adjust(-dx, -dy, dx, dy); // fix pot. overshoot
@ -901,8 +928,9 @@ void AnimationEffect::_windowExpandedGeometryChanged(KWin::EffectWindow *w)
if (entry != d->m_animations.constEnd()) {
*const_cast<QRect *>(&(entry->second)) = QRect();
updateLayerRepaints();
if (!entry->second.isNull()) // actually got updated, ie. is in use - ensure it get's a repaint
if (!entry->second.isNull()) { // actually got updated, ie. is in use - ensure it get's a repaint
w->addLayerRepaint(entry->second);
}
}
}
@ -943,18 +971,20 @@ QString AnimationEffect::debug(const QString & /*parameter*/) const
{
Q_D(const AnimationEffect);
QString dbg;
if (d->m_animations.isEmpty())
if (d->m_animations.isEmpty()) {
dbg = QStringLiteral("No window is animated");
else {
} else {
AniMap::const_iterator entry = d->m_animations.constBegin(), mapEnd = d->m_animations.constEnd();
for (; entry != mapEnd; ++entry) {
QString caption = entry.key()->isDeleted() ? QStringLiteral("[Deleted]") : entry.key()->caption();
if (caption.isEmpty())
if (caption.isEmpty()) {
caption = QStringLiteral("[Untitled]");
}
dbg += QLatin1String("Animating window: ") + caption + QLatin1Char('\n');
QList<AniData>::const_iterator anim = entry->first.constBegin(), animEnd = entry->first.constEnd();
for (; anim != animEnd; ++anim)
for (; anim != animEnd; ++anim) {
dbg += anim->debugInfo();
}
}
}
return dbg;

View File

@ -84,10 +84,11 @@ public:
inline QString toString() const
{
QString ret;
if (valid)
if (valid) {
ret = QString::number(f[0]) + QLatin1Char(',') + QString::number(f[1]);
else
} else {
ret = QString();
}
return ret;
}

View File

@ -760,8 +760,9 @@ bool EffectPluginFactory::isSupported() const
EffectsHandler::EffectsHandler(CompositingType type)
: compositing_type(type)
{
if (compositing_type == NoCompositing)
if (compositing_type == NoCompositing) {
return;
}
KWin::effects = this;
connect(this, QOverload<int, int>::of(&EffectsHandler::desktopChanged), this, &EffectsHandler::desktopChangedLegacy);
}
@ -946,10 +947,12 @@ WindowQuadList WindowQuadList::splitAtX(double x) const
bool wholeleft = true;
bool wholeright = true;
for (int i = 0; i < 4; ++i) {
if (quad[i].x() < x)
if (quad[i].x() < x) {
wholeright = false;
if (quad[i].x() > x)
}
if (quad[i].x() > x) {
wholeleft = false;
}
}
if (wholeleft || wholeright) { // is whole in one split part
ret.append(quad);
@ -973,10 +976,12 @@ WindowQuadList WindowQuadList::splitAtY(double y) const
bool wholetop = true;
bool wholebottom = true;
for (int i = 0; i < 4; ++i) {
if (quad[i].y() < y)
if (quad[i].y() < y) {
wholebottom = false;
if (quad[i].y() > y)
}
if (quad[i].y() > y) {
wholetop = false;
}
}
if (wholetop || wholebottom) { // is whole in one split part
ret.append(quad);
@ -994,8 +999,9 @@ WindowQuadList WindowQuadList::splitAtY(double y) const
WindowQuadList WindowQuadList::makeGrid(int maxQuadSize) const
{
if (empty())
if (empty()) {
return *this;
}
// Find the bounding rectangle
double left = first().left();
@ -1047,8 +1053,9 @@ WindowQuadList WindowQuadList::makeGrid(int maxQuadSize) const
WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisions) const
{
if (empty())
if (empty()) {
return *this;
}
// Find the bounding rectangle
double left = first().left();
@ -1303,8 +1310,9 @@ WindowMotionManager::~WindowMotionManager()
void WindowMotionManager::manage(EffectWindow *w)
{
if (m_managedWindows.contains(w))
if (m_managedWindows.contains(w)) {
return;
}
double strength = 0.08;
double smoothness = 4.0;
@ -1358,9 +1366,9 @@ void WindowMotionManager::calculate(int time)
// TODO: Motion needs to be calculated from the window's center
Motion2D *trans = &motion->translation;
if (trans->distance().isNull())
if (trans->distance().isNull()) {
++stopped;
else {
} else {
// Still moving
trans->calculate(time);
const short fx = trans->target().x() <= trans->startValue().x() ? -1 : 1;
@ -1374,9 +1382,9 @@ void WindowMotionManager::calculate(int time)
}
Motion2D *scale = &motion->scale;
if (scale->distance().isNull())
if (scale->distance().isNull()) {
++stopped;
else {
} else {
// Still scaling
scale->calculate(time);
const short fx = scale->target().x() < 1.0 ? -1 : 1;
@ -1390,8 +1398,9 @@ void WindowMotionManager::calculate(int time)
}
// We just finished this window's motion
if (stopped == 2)
if (stopped == 2) {
m_movingWindowsSet.remove(it.key());
}
}
}
@ -1411,8 +1420,9 @@ void WindowMotionManager::reset()
void WindowMotionManager::reset(EffectWindow *w)
{
QHash<EffectWindow *, WindowMotion>::iterator it = m_managedWindows.find(w);
if (it == m_managedWindows.end())
if (it == m_managedWindows.end()) {
return;
}
WindowMotion *motion = &it.value();
motion->translation.setTarget(w->pos());
@ -1424,8 +1434,9 @@ void WindowMotionManager::reset(EffectWindow *w)
void WindowMotionManager::apply(EffectWindow *w, WindowPaintData &data)
{
QHash<EffectWindow *, WindowMotion>::iterator it = m_managedWindows.find(w);
if (it == m_managedWindows.end())
if (it == m_managedWindows.end()) {
return;
}
// TODO: Take into account existing scale so that we can work with multiple managers (E.g. Present windows + grid)
WindowMotion *motion = &it.value();
@ -1440,12 +1451,14 @@ void WindowMotionManager::moveWindow(EffectWindow *w, QPoint target, double scal
WindowMotion *motion = &it.value();
if (yScale == 0.0)
if (yScale == 0.0) {
yScale = scale;
}
QPointF scalePoint(scale, yScale);
if (motion->translation.value() == target && motion->scale.value() == scalePoint)
if (motion->translation.value() == target && motion->scale.value() == scalePoint) {
return; // Window already at that position
}
motion->translation.setTarget(target);
motion->scale.setTarget(scalePoint);
@ -1456,8 +1469,9 @@ void WindowMotionManager::moveWindow(EffectWindow *w, QPoint target, double scal
QRectF WindowMotionManager::transformedGeometry(EffectWindow *w) const
{
QHash<EffectWindow *, WindowMotion>::const_iterator it = m_managedWindows.constFind(w);
if (it == m_managedWindows.end())
if (it == m_managedWindows.end()) {
return w->frameGeometry();
}
const WindowMotion *motion = &it.value();
QRectF geometry(w->frameGeometry());
@ -1473,8 +1487,9 @@ QRectF WindowMotionManager::transformedGeometry(EffectWindow *w) const
void WindowMotionManager::setTransformedGeometry(EffectWindow *w, const QRectF &geometry)
{
QHash<EffectWindow *, WindowMotion>::iterator it = m_managedWindows.find(w);
if (it == m_managedWindows.end())
if (it == m_managedWindows.end()) {
return;
}
WindowMotion *motion = &it.value();
motion->translation.setValue(geometry.topLeft());
motion->scale.setValue(QPointF(geometry.width() / qreal(w->width()), geometry.height() / qreal(w->height())));
@ -1483,8 +1498,9 @@ void WindowMotionManager::setTransformedGeometry(EffectWindow *w, const QRectF &
QRectF WindowMotionManager::targetGeometry(EffectWindow *w) const
{
QHash<EffectWindow *, WindowMotion>::const_iterator it = m_managedWindows.constFind(w);
if (it == m_managedWindows.end())
if (it == m_managedWindows.end()) {
return w->frameGeometry();
}
const WindowMotion *motion = &it.value();
QRectF geometry(w->frameGeometry());
@ -1503,8 +1519,9 @@ EffectWindow *WindowMotionManager::windowAtPoint(QPoint point, bool useStackingO
// TODO: Stacking order uses EffectsHandler::stackingOrder() then filters by m_managedWindows
QHash<EffectWindow *, WindowMotion>::ConstIterator it = m_managedWindows.constBegin();
while (it != m_managedWindows.constEnd()) {
if (transformedGeometry(it.key()).contains(point))
if (transformedGeometry(it.key()).contains(point)) {
return it.key();
}
++it;
}

View File

@ -3402,8 +3402,9 @@ public:
*/
inline void manage(const EffectWindowList &list)
{
for (int i = 0; i < list.size(); i++)
for (int i = 0; i < list.size(); i++) {
manage(list.at(i));
}
}
/**
* Deregister a window. All transformations applied to the
@ -4045,8 +4046,9 @@ Motion<T>::~Motion()
template<typename T>
void Motion<T>::calculate(const int msec)
{
if (m_value == m_target && m_velocity == T()) // At target and not moving
if (m_value == m_target && m_velocity == T()) { // At target and not moving
return;
}
// Poor man's time independent calculation
int steps = qMax(1, msec / 5);

View File

@ -33,13 +33,15 @@ static qint64 parseVersionString(const QByteArray &version)
{
// Skip any leading non digit
int start = 0;
while (start < version.length() && !QChar::fromLatin1(version[start]).isDigit())
while (start < version.length() && !QChar::fromLatin1(version[start]).isDigit()) {
start++;
}
// Strip any non digit, non '.' characters from the end
int end = start;
while (end < version.length() && (version[end] == '.' || QChar::fromLatin1(version[end]).isDigit()))
while (end < version.length() && (version[end] == '.' || QChar::fromLatin1(version[end]).isDigit())) {
end++;
}
const QByteArray result = version.mid(start, end - start);
const QList<QByteArray> tokens = result.split('.');
@ -76,8 +78,9 @@ static qint64 getKernelVersion()
struct utsname name;
uname(&name);
if (qstrcmp(name.sysname, "Linux") == 0)
if (qstrcmp(name.sysname, "Linux") == 0) {
return parseVersionString(name.release);
}
return 0;
}
@ -87,36 +90,41 @@ static QString extract(const QString &text, const QString &pattern)
{
const QRegularExpression regexp(pattern);
const QRegularExpressionMatch match = regexp.match(text);
if (!match.hasMatch())
if (!match.hasMatch()) {
return QString();
}
return match.captured();
}
static ChipClass detectRadeonClass(const QByteArray &chipset)
{
if (chipset.isEmpty())
if (chipset.isEmpty()) {
return UnknownRadeon;
}
if (chipset.contains("R100")
|| chipset.contains("RV100")
|| chipset.contains("RS100"))
|| chipset.contains("RS100")) {
return R100;
}
if (chipset.contains("RV200")
|| chipset.contains("RS200")
|| chipset.contains("R200")
|| chipset.contains("RV250")
|| chipset.contains("RS300")
|| chipset.contains("RV280"))
|| chipset.contains("RV280")) {
return R200;
}
if (chipset.contains("R300")
|| chipset.contains("R350")
|| chipset.contains("R360")
|| chipset.contains("RV350")
|| chipset.contains("RV370")
|| chipset.contains("RV380"))
|| chipset.contains("RV380")) {
return R300;
}
if (chipset.contains("R420")
|| chipset.contains("R423")
@ -130,16 +138,18 @@ static ChipClass detectRadeonClass(const QByteArray &chipset)
|| chipset.contains("RS482")
|| chipset.contains("RS600")
|| chipset.contains("RS690")
|| chipset.contains("RS740"))
|| chipset.contains("RS740")) {
return R400;
}
if (chipset.contains("RV515")
|| chipset.contains("R520")
|| chipset.contains("RV530")
|| chipset.contains("R580")
|| chipset.contains("RV560")
|| chipset.contains("RV570"))
|| chipset.contains("RV570")) {
return R500;
}
if (chipset.contains("R600")
|| chipset.contains("RV610")
@ -148,15 +158,17 @@ static ChipClass detectRadeonClass(const QByteArray &chipset)
|| chipset.contains("RV620")
|| chipset.contains("RV635")
|| chipset.contains("RS780")
|| chipset.contains("RS880"))
|| chipset.contains("RS880")) {
return R600;
}
if (chipset.contains("R700")
|| chipset.contains("RV770")
|| chipset.contains("RV730")
|| chipset.contains("RV710")
|| chipset.contains("RV740"))
|| chipset.contains("RV740")) {
return R700;
}
if (chipset.contains("EVERGREEN") // Not an actual chipset, but returned by R600G in 7.9
|| chipset.contains("CEDAR")
@ -164,16 +176,18 @@ static ChipClass detectRadeonClass(const QByteArray &chipset)
|| chipset.contains("JUNIPER")
|| chipset.contains("CYPRESS")
|| chipset.contains("HEMLOCK")
|| chipset.contains("PALM"))
|| chipset.contains("PALM")) {
return Evergreen;
}
if (chipset.contains("SUMO")
|| chipset.contains("SUMO2")
|| chipset.contains("BARTS")
|| chipset.contains("TURKS")
|| chipset.contains("CAICOS")
|| chipset.contains("CAYMAN"))
|| chipset.contains("CAYMAN")) {
return NorthernIslands;
}
if (chipset.contains("TAHITI")
|| chipset.contains("PITCAIRN")
@ -226,20 +240,25 @@ static ChipClass detectRadeonClass(const QByteArray &chipset)
QString name = extract(chipset16, QStringLiteral("HD [0-9]{4}")); // HD followed by a space and 4 digits
if (!name.isEmpty()) {
const int id = QStringView(name).right(4).toInt();
if (id == 6250 || id == 6310) // Palm
if (id == 6250 || id == 6310) { // Palm
return Evergreen;
}
if (id >= 6000 && id < 7000)
if (id >= 6000 && id < 7000) {
return NorthernIslands; // HD 6xxx
}
if (id >= 5000 && id < 6000)
if (id >= 5000 && id < 6000) {
return Evergreen; // HD 5xxx
}
if (id >= 4000 && id < 5000)
if (id >= 4000 && id < 5000) {
return R700; // HD 4xxx
}
if (id >= 2000 && id < 4000) // HD 2xxx/3xxx
if (id >= 2000 && id < 4000) { // HD 2xxx/3xxx
return R600;
}
return UnknownRadeon;
}
@ -249,16 +268,19 @@ static ChipClass detectRadeonClass(const QByteArray &chipset)
const int id = QStringView(name).mid(1, -1).toInt();
// X1xxx
if (id >= 1300)
if (id >= 1300) {
return R500;
}
// X7xx, X8xx, X12xx, 2100
if ((id >= 700 && id < 1000) || id >= 1200)
if ((id >= 700 && id < 1000) || id >= 1200) {
return R400;
}
// X200, X3xx, X5xx, X6xx, X10xx, X11xx
if ((id >= 300 && id < 700) || (id >= 1000 && id < 1200))
if ((id >= 300 && id < 700) || (id >= 1000 && id < 1200)) {
return R300;
}
return UnknownRadeon;
}
@ -268,19 +290,23 @@ static ChipClass detectRadeonClass(const QByteArray &chipset)
const int id = name.toInt();
// 7xxx
if (id >= 7000 && id < 8000)
if (id >= 7000 && id < 8000) {
return R100;
}
// 8xxx, 9xxx
if (id >= 8000 && id < 9500)
if (id >= 8000 && id < 9500) {
return R200;
}
// 9xxx
if (id >= 9500)
if (id >= 9500) {
return R300;
}
if (id == 2100)
if (id == 2100) {
return R400;
}
}
return UnknownRadeon;
@ -318,19 +344,22 @@ static ChipClass detectNVidiaClass(const QString &chipset)
}
}
if (chipset.contains(QLatin1String("GeForce2")) || chipset.contains(QLatin1String("GeForce 256")))
if (chipset.contains(QLatin1String("GeForce2")) || chipset.contains(QLatin1String("GeForce 256"))) {
return NV10;
}
if (chipset.contains(QLatin1String("GeForce3")))
if (chipset.contains(QLatin1String("GeForce3"))) {
return NV20;
}
if (chipset.contains(QLatin1String("GeForce4"))) {
if (chipset.contains(QLatin1String("MX 420"))
|| chipset.contains(QLatin1String("MX 440")) // including MX 440SE
|| chipset.contains(QLatin1String("MX 460"))
|| chipset.contains(QLatin1String("MX 4000"))
|| chipset.contains(QLatin1String("PCX 4300")))
|| chipset.contains(QLatin1String("PCX 4300"))) {
return NV10;
}
return NV20;
}
@ -338,18 +367,22 @@ static ChipClass detectNVidiaClass(const QString &chipset)
// GeForce 5,6,7,8,9
name = extract(chipset, QStringLiteral("GeForce (FX |PCX |Go )?\\d{4}(M|\\b)")).trimmed();
if (!name.isEmpty()) {
if (!name[name.length() - 1].isDigit())
if (!name[name.length() - 1].isDigit()) {
name.chop(1);
}
const int id = QStringView(name).right(4).toInt();
if (id < 6000)
if (id < 6000) {
return NV30;
}
if (id >= 6000 && id < 8000)
if (id >= 6000 && id < 8000) {
return NV40;
}
if (id >= 8000)
if (id >= 8000) {
return G80;
}
return UnknownNVidia;
}
@ -357,13 +390,15 @@ static ChipClass detectNVidiaClass(const QString &chipset)
// GeForce 100/200/300/400/500
name = extract(chipset, QStringLiteral("GeForce (G |GT |GTX |GTS )?\\d{3}(M|\\b)")).trimmed();
if (!name.isEmpty()) {
if (!name[name.length() - 1].isDigit())
if (!name[name.length() - 1].isDigit()) {
name.chop(1);
}
const int id = QStringView(name).right(3).toInt();
if (id >= 100 && id < 600) {
if (id >= 400)
if (id >= 400) {
return GF100;
}
return G80;
}
@ -384,8 +419,9 @@ static ChipClass detectIntelClass(const QByteArray &chipset)
if (chipset.contains("845G")
|| chipset.contains("830M")
|| chipset.contains("852GM/855GM")
|| chipset.contains("865G"))
|| chipset.contains("865G")) {
return I8XX;
}
// GL 1.4, DX 9.0, SM 2.0
if (chipset.contains("915G")
@ -399,8 +435,9 @@ static ChipClass detectIntelClass(const QByteArray &chipset)
|| chipset.contains("G33")
|| chipset.contains("965Q") // GMA 3000, but apparently considered gen 4 by the driver
|| chipset.contains("946GZ") // GMA 3000, but apparently considered gen 4 by the driver
|| chipset.contains("IGD"))
|| chipset.contains("IGD")) {
return I915;
}
// GL 2.0, DX 9.0c, SM 3.0
if (chipset.contains("965G")
@ -411,8 +448,9 @@ static ChipClass detectIntelClass(const QByteArray &chipset)
|| chipset.contains("Q45/Q43")
|| chipset.contains("G41")
|| chipset.contains("B43")
|| chipset.contains("Ironlake"))
|| chipset.contains("Ironlake")) {
return I965;
}
// GL 3.1, CL 1.1, DX 10.1
if (chipset.contains("Sandybridge") || chipset.contains("SNB GT")) {
@ -502,14 +540,17 @@ static ChipClass detectQualcommClass(const QByteArray &chipClass)
static ChipClass detectPanfrostClass(const QByteArray &chipClass)
{
if (chipClass.contains("T720") || chipClass.contains("T760"))
if (chipClass.contains("T720") || chipClass.contains("T760")) {
return MaliT7XX;
}
if (chipClass.contains("T820") || chipClass.contains("T860"))
if (chipClass.contains("T820") || chipClass.contains("T860")) {
return MaliT8XX;
}
if (chipClass.contains("G31") || chipClass.contains("G52") || chipClass.contains("G72"))
if (chipClass.contains("G31") || chipClass.contains("G52") || chipClass.contains("G72")) {
return MaliGXX;
}
return UnknownPanfrost;
}
@ -525,8 +566,9 @@ QByteArray GLPlatform::versionToString8(qint64 version)
int patch = version & 0xffff;
QByteArray string = QByteArray::number(major) + '.' + QByteArray::number(minor);
if (patch != 0)
if (patch != 0) {
string += '.' + QByteArray::number(patch);
}
return string;
}
@ -806,21 +848,22 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
const QByteArray &chipClass = tokens.at(2);
m_chipset = tokens.at(3).mid(1, -1); // Strip the leading '('
if (chipClass == "R100")
if (chipClass == "R100") {
// Vendor: Tungsten Graphics, Inc.
m_driver = Driver_R100;
else if (chipClass == "R200")
} else if (chipClass == "R200") {
// Vendor: Tungsten Graphics, Inc.
m_driver = Driver_R200;
else if (chipClass == "R300")
} else if (chipClass == "R300") {
// Vendor: DRI R300 Project
m_driver = Driver_R300C;
else if (chipClass == "R600")
} else if (chipClass == "R600") {
// Vendor: Advanced Micro Devices, Inc.
m_driver = Driver_R600C;
}
m_chipClass = detectRadeonClass(m_chipset);
}
@ -831,10 +874,11 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
// Sample renderer string: Mesa DRI Mobile Intel® GM45 Express Chipset GEM 20100328 2010Q1
QByteArray chipset;
if (m_renderer.startsWith("Intel(R) Integrated Graphics Device"))
if (m_renderer.startsWith("Intel(R) Integrated Graphics Device")) {
chipset = "IGD";
else
} else {
chipset = m_renderer;
}
m_driver = Driver_Intel;
m_chipClass = detectIntelClass(chipset);
@ -846,12 +890,13 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
m_chipClass = detectRadeonClass(m_renderer);
m_driver = Driver_Catalyst;
if (versionTokens.count() > 1 && versionTokens.at(2)[0] == '(')
if (versionTokens.count() > 1 && versionTokens.at(2)[0] == '(') {
m_driverVersion = parseVersionString(versionTokens.at(1));
else if (versionTokens.count() > 0)
} else if (versionTokens.count() > 0) {
m_driverVersion = parseVersionString(versionTokens.at(0));
else
} else {
m_driverVersion = 0;
}
}
else if (m_vendor == "NVIDIA Corporation") {
@ -859,10 +904,11 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
m_driver = Driver_NVidia;
int index = versionTokens.indexOf("NVIDIA");
if (versionTokens.count() > index)
if (versionTokens.count() > index) {
m_driverVersion = parseVersionString(versionTokens.at(index + 1));
else
} else {
m_driverVersion = 0;
}
}
else if (m_vendor == "Qualcomm") {
@ -886,10 +932,11 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
m_driver = Driver_VirtualBox;
const int index = versionTokens.indexOf("Chromium");
if (versionTokens.count() > index)
if (versionTokens.count() > index) {
m_driverVersion = parseVersionString(versionTokens.at(index + 1));
else
} else {
m_driverVersion = 0;
}
}
// Gallium drivers
@ -957,17 +1004,19 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
if (isRadeon()) {
// R200 technically has a programmable pipeline, but since it's SM 1.4,
// it's too limited to to be of any practical value to us.
if (m_chipClass < R300)
if (m_chipClass < R300) {
m_supportsGLSL = false;
}
m_limitedGLSL = false;
m_limitedNPOT = false;
if (m_chipClass < R600) {
if (driver() == Driver_Catalyst)
if (driver() == Driver_Catalyst) {
m_textureNPOT = m_limitedNPOT = false; // Software fallback
else if (driver() == Driver_R300G)
} else if (driver() == Driver_R300G) {
m_limitedNPOT = m_textureNPOT;
}
m_limitedGLSL = m_supportsGLSL;
}
@ -988,8 +1037,9 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
}
if (isNvidia()) {
if (m_driver == Driver_NVidia && m_chipClass < NV40)
if (m_driver == Driver_NVidia && m_chipClass < NV40) {
m_supportsGLSL = false; // High likelihood of software emulation
}
if (m_driver == Driver_NVidia) {
m_looseBinding = true;
@ -1007,8 +1057,9 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
}
if (isIntel()) {
if (m_chipClass < I915)
if (m_chipClass < I915) {
m_supportsGLSL = false;
}
m_limitedGLSL = m_supportsGLSL && m_chipClass < I965;
// see https://bugs.freedesktop.org/show_bug.cgi?id=80349#c1
@ -1095,28 +1146,34 @@ void GLPlatform::printResults() const
print(QByteArrayLiteral("OpenGL renderer string:"), m_renderer);
print(QByteArrayLiteral("OpenGL version string:"), m_version);
if (m_supportsGLSL)
if (m_supportsGLSL) {
print(QByteArrayLiteral("OpenGL shading language version string:"), m_glsl_version);
}
print(QByteArrayLiteral("Driver:"), driverToString8(m_driver));
if (!isMesaDriver())
if (!isMesaDriver()) {
print(QByteArrayLiteral("Driver version:"), versionToString8(m_driverVersion));
}
print(QByteArrayLiteral("GPU class:"), chipClassToString8(m_chipClass));
print(QByteArrayLiteral("OpenGL version:"), versionToString8(m_glVersion));
if (m_supportsGLSL)
if (m_supportsGLSL) {
print(QByteArrayLiteral("GLSL version:"), versionToString8(m_glslVersion));
}
if (isMesaDriver())
if (isMesaDriver()) {
print(QByteArrayLiteral("Mesa version:"), versionToString8(mesaVersion()));
}
// if (galliumVersion() > 0)
// print("Gallium version:", versionToString(m_galliumVersion));
if (serverVersion() > 0)
if (serverVersion() > 0) {
print(QByteArrayLiteral("X server version:"), versionToString8(m_serverVersion));
if (kernelVersion() > 0)
}
if (kernelVersion() > 0) {
print(QByteArrayLiteral("Linux kernel version:"), versionToString8(m_kernelVersion));
}
print(QByteArrayLiteral("Requires strict binding:"), !m_looseBinding ? QByteArrayLiteral("yes") : QByteArrayLiteral("no"));
print(QByteArrayLiteral("GLSL shaders:"), m_supportsGLSL ? (m_limitedGLSL ? QByteArrayLiteral("limited") : QByteArrayLiteral("yes")) : QByteArrayLiteral("no"));
@ -1182,8 +1239,9 @@ qint64 GLPlatform::kernelVersion() const
qint64 GLPlatform::driverVersion() const
{
if (isMesaDriver())
if (isMesaDriver()) {
return mesaVersion();
}
return m_driverVersion;
}

View File

@ -458,8 +458,9 @@ private:
inline GLPlatform *GLPlatform::instance()
{
if (!s_platform)
if (!s_platform) {
s_platform = new GLPlatform;
}
return s_platform;
}

View File

@ -104,8 +104,9 @@ GLTexture::GLTexture(const QImage &image, GLenum target)
{
Q_D(GLTexture);
if (image.isNull())
if (image.isNull()) {
return;
}
d->m_target = target;
@ -365,8 +366,9 @@ void GLTexture::setSize(const QSize &size)
void GLTexture::update(const QImage &image, const QPoint &offset, const QRect &src)
{
if (image.isNull() || isNull())
if (image.isNull() || isNull()) {
return;
}
Q_D(GLTexture);
Q_ASSERT(!d->m_foreign);
@ -495,8 +497,9 @@ void GLTexture::generateMipmaps()
{
Q_D(GLTexture);
if (d->m_canUseMipmaps && d->s_supportsFramebufferObjects)
if (d->m_canUseMipmaps && d->s_supportsFramebufferObjects) {
glGenerateMipmap(d->m_target);
}
}
void GLTexture::unbind()
@ -513,8 +516,9 @@ void GLTexture::render(const QRect &rect)
void GLTexture::render(const QRegion &region, const QRect &rect, bool hardwareClipping)
{
Q_D(GLTexture);
if (rect.isEmpty())
if (rect.isEmpty()) {
return; // nothing to paint and m_vbo is likely nullptr and d->m_cachedSize empty as well, #337090
}
if (rect.size() != d->m_cachedSize) {
d->m_cachedSize = rect.size();
QRect r(rect);
@ -572,20 +576,23 @@ void GLTexture::clear()
{
Q_D(GLTexture);
Q_ASSERT(!d->m_foreign);
if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && GLPlatform::instance()->driver() != Driver_Catalyst) // fail. -> bug #323065
if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && GLPlatform::instance()->driver() != Driver_Catalyst) { // fail. -> bug #323065
glGenFramebuffers(1, &GLTexturePrivate::s_fbo);
}
if (GLTexturePrivate::s_fbo) {
// Clear the texture
GLuint previousFramebuffer = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, reinterpret_cast<GLint *>(&previousFramebuffer));
if (GLTexturePrivate::s_fbo != previousFramebuffer)
if (GLTexturePrivate::s_fbo != previousFramebuffer) {
glBindFramebuffer(GL_FRAMEBUFFER, GLTexturePrivate::s_fbo);
}
glClearColor(0, 0, 0, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, d->m_texture, 0);
glClear(GL_COLOR_BUFFER_BIT);
if (GLTexturePrivate::s_fbo != previousFramebuffer)
if (GLTexturePrivate::s_fbo != previousFramebuffer) {
glBindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer);
}
} else {
if (const int size = width() * height()) {
uint32_t *buffer = new uint32_t[size];
@ -645,10 +652,11 @@ void GLTexturePrivate::updateMatrix()
m_matrix[NormalizedCoordinates].setToIdentity();
m_matrix[UnnormalizedCoordinates].setToIdentity();
if (m_target == GL_TEXTURE_RECTANGLE_ARB)
if (m_target == GL_TEXTURE_RECTANGLE_ARB) {
m_matrix[NormalizedCoordinates].scale(m_size.width(), m_size.height());
else
} else {
m_matrix[UnnormalizedCoordinates].scale(1.0 / m_size.width(), 1.0 / m_size.height());
}
if (!m_yInverted) {
m_matrix[NormalizedCoordinates].translate(0.0, 1.0);
@ -668,8 +676,9 @@ bool GLTexture::isYInverted() const
void GLTexture::setYInverted(bool inverted)
{
Q_D(GLTexture);
if (d->m_yInverted == inverted)
if (d->m_yInverted == inverted) {
return;
}
d->m_yInverted = inverted;
d->updateMatrix();

View File

@ -58,8 +58,9 @@ static void initDebugOutput()
const bool have_KHR_debug = hasGLExtension(QByteArrayLiteral("GL_KHR_debug"));
const bool have_ARB_debug = hasGLExtension(QByteArrayLiteral("GL_ARB_debug_output"));
if (!have_KHR_debug && !have_ARB_debug)
if (!have_KHR_debug && !have_ARB_debug) {
return;
}
if (!have_ARB_debug) {
// if we don't have ARB debug, but only KHR debug we need to verify whether the context is a debug context
@ -111,8 +112,9 @@ static void initDebugOutput()
glDebugMessageCallback(callback, nullptr);
// This state exists only in GL_KHR_debug
if (have_KHR_debug)
if (have_KHR_debug) {
glEnable(GL_DEBUG_OUTPUT);
}
#if !defined(QT_NO_DEBUG)
// Enable all debug messages
@ -140,8 +142,9 @@ void initGL(const std::function<resolveFuncPtr(const char *)> &resolveFunction)
const QByteArray name = (const char *)glGetStringi(GL_EXTENSIONS, i);
glExtensions << name;
}
} else
} else {
glExtensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' ');
}
// handle OpenGL extensions functions
glResolveFunctions(resolveFunction);
@ -341,11 +344,13 @@ bool GLShader::compile(GLuint program, GLenum shaderType, const QByteArray &sour
qCCritical(LIBKWINGLUTILS) << "Failed to compile" << typeName << "shader:"
<< "\n"
<< log;
} else if (length > 0)
} else if (length > 0) {
qCDebug(LIBKWINGLUTILS) << "Shader compile log:" << log;
}
if (status != 0)
if (status != 0) {
glAttachShader(program, shader);
}
glDeleteShader(shader);
return status != 0;
@ -367,20 +372,23 @@ bool GLShader::load(const QByteArray &vertexSource, const QByteArray &fragmentSo
if (!vertexSource.isEmpty()) {
bool success = compile(mProgram, GL_VERTEX_SHADER, vertexSource);
if (!success)
if (!success) {
return false;
}
}
// Compile the fragment shader
if (!fragmentSource.isEmpty()) {
bool success = compile(mProgram, GL_FRAGMENT_SHADER, fragmentSource);
if (!success)
if (!success) {
return false;
}
}
if (mExplicitLinking)
if (mExplicitLinking) {
return true;
}
// link() sets mValid
return link();
@ -393,8 +401,9 @@ void GLShader::bindAttributeLocation(const char *name, int index)
void GLShader::bindFragDataLocation(const char *name, int index)
{
if (!GLPlatform::instance()->isGLES() && (hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_gpu_shader4"))))
if (!GLPlatform::instance()->isGLES() && (hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_gpu_shader4")))) {
glBindFragDataLocation(mProgram, index, name);
}
}
void GLShader::bind()
@ -409,8 +418,9 @@ void GLShader::unbind()
void GLShader::resolveLocations()
{
if (mLocationsResolved)
if (mLocationsResolved) {
return;
}
mMatrixLocation[TextureMatrix] = uniformLocation("textureMatrix");
mMatrixLocation[ProjectionMatrix] = uniformLocation("projection");
@ -655,30 +665,34 @@ QByteArray ShaderManager::generateVertexSource(ShaderTraits traits) const
attribute = glsl_140 ? QByteArrayLiteral("in") : QByteArrayLiteral("attribute");
varying = glsl_140 ? QByteArrayLiteral("out") : QByteArrayLiteral("varying");
if (glsl_140)
if (glsl_140) {
stream << "#version 140\n\n";
}
} else {
const bool glsl_es_300 = gl->glslVersion() >= kVersionNumber(3, 0);
attribute = glsl_es_300 ? QByteArrayLiteral("in") : QByteArrayLiteral("attribute");
varying = glsl_es_300 ? QByteArrayLiteral("out") : QByteArrayLiteral("varying");
if (glsl_es_300)
if (glsl_es_300) {
stream << "#version 300 es\n\n";
}
}
stream << attribute << " vec4 position;\n";
if (traits & ShaderTrait::MapTexture) {
stream << attribute << " vec4 texcoord;\n\n";
stream << varying << " vec2 texcoord0;\n\n";
} else
} else {
stream << "\n";
}
stream << "uniform mat4 modelViewProjectionMatrix;\n\n";
stream << "void main()\n{\n";
if (traits & ShaderTrait::MapTexture)
if (traits & ShaderTrait::MapTexture) {
stream << " texcoord0 = texcoord.st;\n";
}
stream << " gl_Position = modelViewProjectionMatrix * position;\n";
stream << "}\n";
@ -698,8 +712,9 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const
if (!gl->isGLES()) {
const bool glsl_140 = gl->glslVersion() >= kVersionNumber(1, 40);
if (glsl_140)
if (glsl_140) {
stream << "#version 140\n\n";
}
varying = glsl_140 ? QByteArrayLiteral("in") : QByteArrayLiteral("varying");
textureLookup = glsl_140 ? QByteArrayLiteral("texture") : QByteArrayLiteral("texture2D");
@ -707,8 +722,9 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const
} else {
const bool glsl_es_300 = GLPlatform::instance()->glslVersion() >= kVersionNumber(3, 0);
if (glsl_es_300)
if (glsl_es_300) {
stream << "#version 300 es\n\n";
}
// From the GLSL ES specification:
//
@ -723,19 +739,23 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const
if (traits & ShaderTrait::MapTexture) {
stream << "uniform sampler2D sampler;\n";
if (traits & ShaderTrait::Modulate)
if (traits & ShaderTrait::Modulate) {
stream << "uniform vec4 modulation;\n";
if (traits & ShaderTrait::AdjustSaturation)
}
if (traits & ShaderTrait::AdjustSaturation) {
stream << "uniform float saturation;\n";
}
stream << "\n"
<< varying << " vec2 texcoord0;\n";
} else if (traits & ShaderTrait::UniformColor)
} else if (traits & ShaderTrait::UniformColor) {
stream << "uniform vec4 geometryColor;\n";
}
if (output != QByteArrayLiteral("gl_FragColor"))
if (output != QByteArrayLiteral("gl_FragColor")) {
stream << "\nout vec4 " << output << ";\n";
}
stream << "\nvoid main(void)\n{\n";
if (traits & ShaderTrait::MapTexture) {
@ -743,17 +763,20 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const
if (traits & (ShaderTrait::Modulate | ShaderTrait::AdjustSaturation)) {
stream << " vec4 texel = " << textureLookup << "(sampler, texcoordC);\n";
if (traits & ShaderTrait::Modulate)
if (traits & ShaderTrait::Modulate) {
stream << " texel *= modulation;\n";
if (traits & ShaderTrait::AdjustSaturation)
}
if (traits & ShaderTrait::AdjustSaturation) {
stream << " texel.rgb = mix(vec3(dot(texel.rgb, vec3(0.2126, 0.7152, 0.0722))), texel.rgb, saturation);\n";
}
stream << " " << output << " = texel;\n";
} else {
stream << " " << output << " = " << textureLookup << "(sampler, texcoordC);\n";
}
} else if (traits & ShaderTrait::UniformColor)
} else if (traits & ShaderTrait::UniformColor) {
stream << " " << output << " = geometryColor;\n";
}
stream << "}";
stream.flush();
@ -1098,10 +1121,11 @@ void GLRenderTarget::initFBO(GLTexture *colorAttachment)
if (status != GL_FRAMEBUFFER_COMPLETE) {
// We have an incomplete framebuffer, consider it invalid
if (status == 0)
if (status == 0) {
qCCritical(LIBKWINGLUTILS) << "glCheckFramebufferStatus failed: " << formatGLError(glGetError());
else
} else {
qCCritical(LIBKWINGLUTILS) << "Invalid framebuffer status: " << formatFramebufferStatus(status);
}
glDeleteFramebuffers(1, &mFramebuffer);
return;
}
@ -1355,8 +1379,9 @@ IndexBuffer::~IndexBuffer()
void IndexBuffer::accommodate(int count)
{
// Check if we need to grow the buffer.
if (count <= m_count)
if (count <= m_count) {
return;
}
count = align(count, 128);
size_t size = 6 * sizeof(uint16_t) * count;
@ -1379,8 +1404,9 @@ void IndexBuffer::accommodate(int count)
const uint16_t index[] = {1, 0, 3, 3, 2, 1};
for (int i = m_count; i < count; i++) {
for (int j = 0; j < 6; j++)
for (int j = 0; j < 6; j++) {
*(map++) = i * 4 + index[j];
}
}
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
@ -1407,10 +1433,11 @@ public:
void operator=(bool val)
{
if (val)
if (val) {
m_bitfield |= m_mask;
else
} else {
m_bitfield &= ~m_mask;
}
}
operator bool() const
@ -1511,8 +1538,9 @@ struct BufferFence
static void deleteAll(std::deque<BufferFence> &fences)
{
for (const BufferFence &fence : fences)
for (const BufferFence &fence : fences) {
glDeleteSync(fence.sync);
}
fences.clear();
}
@ -1537,8 +1565,9 @@ public:
size_t average() const
{
size_t sum = 0;
for (size_t size : m_array)
for (size_t size : m_array) {
sum += size;
}
return sum / Count;
}
@ -1665,8 +1694,9 @@ void GLVertexBufferPrivate::interleaveArrays(float *dst, int dim,
default:
for (int i = 0; i < count; i++) {
for (int j = 0; j < dim; j++)
for (int j = 0; j < dim; j++) {
*(dst++) = *(vertices++);
}
*(dst++) = *(texcoords++);
*(dst++) = *(texcoords++);
@ -1695,8 +1725,9 @@ void GLVertexBufferPrivate::bindArrays()
void GLVertexBufferPrivate::unbindArrays()
{
BitfieldIterator it(enabledArrays);
while (it.hasNext())
while (it.hasNext()) {
glDisableVertexAttribArray(it.next());
}
}
void GLVertexBufferPrivate::reallocatePersistentBuffer(size_t size)
@ -1709,8 +1740,9 @@ void GLVertexBufferPrivate::reallocatePersistentBuffer(size_t size)
deleteAll(fences);
}
if (buffer == 0)
if (buffer == 0) {
glGenBuffers(1, &buffer);
}
// Round the size up to 64 kb
size_t minSize = qMax<size_t>(frameSizes.average() * 3, 128 * 1024);
@ -1762,16 +1794,18 @@ bool GLVertexBufferPrivate::awaitFence(intptr_t end)
GLvoid *GLVertexBufferPrivate::getIdleRange(size_t size)
{
if (unlikely(size > bufferSize))
if (unlikely(size > bufferSize)) {
reallocatePersistentBuffer(size * 2);
}
// Handle wrap-around
if (unlikely(nextOffset + size > bufferSize)) {
nextOffset = 0;
bufferEnd -= bufferSize;
for (BufferFence &fence : fences)
for (BufferFence &fence : fences) {
fence.nextEnd -= bufferSize;
}
// Emit a fence now
BufferFence fence;
@ -1782,8 +1816,9 @@ GLvoid *GLVertexBufferPrivate::getIdleRange(size_t size)
}
if (unlikely(nextOffset + intptr_t(size) > bufferEnd)) {
if (!awaitFence(nextOffset + size))
if (!awaitFence(nextOffset + size)) {
return nullptr;
}
}
return map + nextOffset;
@ -1862,21 +1897,24 @@ GLvoid *GLVertexBuffer::map(size_t size)
d->mappedSize = size;
d->frameSize += size;
if (d->persistent)
if (d->persistent) {
return d->getIdleRange(size);
}
glBindBuffer(GL_ARRAY_BUFFER, d->buffer);
bool preferBufferSubData = GLPlatform::instance()->preferBufferSubData();
if (GLVertexBufferPrivate::hasMapBufferRange && !preferBufferSubData)
if (GLVertexBufferPrivate::hasMapBufferRange && !preferBufferSubData) {
return (GLvoid *)d->mapNextFreeRange(size);
}
// If we can't map the buffer we allocate local memory to hold the
// buffer data and return a pointer to it. The data will be submitted
// to the actual buffer object when the user calls unmap().
if (size_t(d->dataStore.size()) < size)
if (size_t(d->dataStore.size()) < size) {
d->dataStore.resize(size);
}
return (GLvoid *)d->dataStore.data();
}
@ -1915,8 +1953,9 @@ void GLVertexBuffer::unmap()
}
// Free the local memory buffer if it's unlikely to be used again
if (d->usage == GL_STATIC_DRAW)
if (d->usage == GL_STATIC_DRAW) {
d->dataStore = QByteArray();
}
}
d->mappedSize = 0;
@ -1980,8 +2019,9 @@ void GLVertexBuffer::draw(const QRegion &region, GLenum primitiveMode, int first
if (primitiveMode == GL_QUADS) {
IndexBuffer *&indexBuffer = GLVertexBufferPrivate::s_indexBuffer;
if (!indexBuffer)
if (!indexBuffer) {
indexBuffer = new IndexBuffer;
}
indexBuffer->bind();
indexBuffer->accommodate(count / 4);
@ -2043,8 +2083,9 @@ void GLVertexBuffer::reset()
void GLVertexBuffer::endOfFrame()
{
if (!d->persistent)
if (!d->persistent) {
return;
}
// Emit a fence if we have uploaded data
if (d->frameSize > 0) {
@ -2074,8 +2115,9 @@ void GLVertexBuffer::endOfFrame()
void GLVertexBuffer::beginFrame()
{
if (!d->persistent)
if (!d->persistent) {
return;
}
// Remove finished fences from the list and update the bufferEnd offset
while (d->fences.size() > 1 && d->fences.front().signaled()) {

View File

@ -89,8 +89,9 @@ XRenderPicture xRenderBlendPicture(double opacity)
static xcb_render_picture_t createPicture(xcb_pixmap_t pix, int depth)
{
if (pix == XCB_PIXMAP_NONE)
if (pix == XCB_PIXMAP_NONE) {
return XCB_RENDER_PICTURE_NONE;
}
xcb_connection_t *c = XRenderUtils::s_connection;
static QHash<int, xcb_render_pictformat_t> s_renderFormats;
if (!s_renderFormats.contains(depth)) {
@ -240,8 +241,9 @@ struct PictFormatData
const xcb_render_pictvisual_t *visuals = xcb_render_pictdepth_visuals(depths.data);
const int len = xcb_render_pictdepth_visuals_length(depths.data);
for (int i = 0; i < len; i++)
for (int i = 0; i < len; i++) {
visualHash.insert(visuals[i].visual, visuals[i].format);
}
}
}
@ -250,8 +252,9 @@ struct PictFormatData
const int len = xcb_render_query_pict_formats_formats_length(reply);
for (int i = 0; i < len; i++) {
if (formats[i].type == XCB_RENDER_PICT_TYPE_DIRECT)
if (formats[i].type == XCB_RENDER_PICT_TYPE_DIRECT) {
formatInfoHash.insert(formats[i].id, &formats[i].direct);
}
}
}

View File

@ -313,12 +313,15 @@ int main(int argc, char *argv[])
KWin::gainRealTime();
KWin::dropNiceCapability();
if (signal(SIGTERM, KWin::sighandler) == SIG_IGN)
if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) {
signal(SIGTERM, SIG_IGN);
if (signal(SIGINT, KWin::sighandler) == SIG_IGN)
}
if (signal(SIGINT, KWin::sighandler) == SIG_IGN) {
signal(SIGINT, SIG_IGN);
if (signal(SIGHUP, KWin::sighandler) == SIG_IGN)
}
if (signal(SIGHUP, KWin::sighandler) == SIG_IGN) {
signal(SIGHUP, SIG_IGN);
}
signal(SIGPIPE, SIG_IGN);
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();

View File

@ -90,8 +90,9 @@ public:
void addWM(const QString &wm)
{
// TODO: Check if WM is installed
if (!QStandardPaths::findExecutable(wm).isEmpty())
if (!QStandardPaths::findExecutable(wm).isEmpty()) {
wmList->addItem(wm);
}
}
QString selectedWM() const
{
@ -118,8 +119,9 @@ private:
int32_t version[] = {2, 0};
xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_REPLACE, requestor_P,
property_P, XCB_ATOM_INTEGER, 32, 2, version);
} else
} else {
return KSelectionOwner::genericReply(target_P, property_P, requestor_P);
}
return true;
}
@ -149,8 +151,9 @@ private:
xcb_atom_t make_selection_atom(int screen_P)
{
if (screen_P < 0)
if (screen_P < 0) {
screen_P = QX11Info::appScreen();
}
QByteArray screen(QByteArrayLiteral("WM_S"));
screen.append(QByteArray::number(screen_P));
ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply(
@ -184,8 +187,9 @@ ApplicationX11::~ApplicationX11()
setTerminating();
destroyCompositor();
destroyWorkspace();
if (!owner.isNull() && owner->ownerWindow() != XCB_WINDOW_NONE) // If there was no --replace (no new WM)
if (!owner.isNull() && owner->ownerWindow() != XCB_WINDOW_NONE) { // If there was no --replace (no new WM)
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);
}
}
void ApplicationX11::setReplace(bool replace)
@ -251,8 +255,9 @@ void ApplicationX11::performStartup()
maskValues)));
if (!redirectCheck.isNull()) {
fputs(i18n("kwin: another window manager is running (try using --replace)\n").toLocal8Bit().constData(), stderr);
if (!wasCrash()) // if this is a crash-restart, DrKonqi may have stopped the process w/o killing the connection
if (!wasCrash()) { // if this is a crash-restart, DrKonqi may have stopped the process w/o killing the connection
::exit(1);
}
}
createInput();
@ -273,8 +278,9 @@ void ApplicationX11::performStartup()
bool ApplicationX11::notify(QObject *o, QEvent *e)
{
if (e->spontaneous() && Workspace::self()->workspaceEvent(e))
if (e->spontaneous() && Workspace::self()->workspaceEvent(e)) {
return true;
}
return QApplication::notify(o, e);
}
@ -290,10 +296,11 @@ void ApplicationX11::crashChecking()
// Something has gone seriously wrong
AlternativeWMDialog dialog;
QString cmd = QStringLiteral(KWIN_INTERNAL_NAME_X11);
if (dialog.exec() == QDialog::Accepted)
if (dialog.exec() == QDialog::Accepted) {
cmd = dialog.selectedWM();
else
} else {
::exit(1);
}
if (cmd.length() > 500) {
qCDebug(KWIN_CORE) << "Command is too long, truncating";
cmd = cmd.left(500);
@ -371,8 +378,9 @@ int main(int argc, char *argv[])
int pos; // Temporarily needed to reconstruct DISPLAY var if multi-head
QByteArray display_name = qgetenv("DISPLAY");
if ((pos = display_name.lastIndexOf('.')) != -1)
if ((pos = display_name.lastIndexOf('.')) != -1) {
display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s"
}
for (int i = 0; i < number_of_screens; i++) {
// If execution doesn't pass by here, then kwin
@ -402,12 +410,15 @@ int main(int argc, char *argv[])
}
}
if (signal(SIGTERM, KWin::sighandler) == SIG_IGN)
if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) {
signal(SIGTERM, SIG_IGN);
if (signal(SIGINT, KWin::sighandler) == SIG_IGN)
}
if (signal(SIGINT, KWin::sighandler) == SIG_IGN) {
signal(SIGINT, SIG_IGN);
if (signal(SIGHUP, KWin::sighandler) == SIG_IGN)
}
if (signal(SIGHUP, KWin::sighandler) == SIG_IGN) {
signal(SIGHUP, SIG_IGN);
}
signal(SIGPIPE, SIG_IGN);
// Disable the glib event loop integration, since it seems to be responsible

View File

@ -152,26 +152,29 @@ void RootInfo::changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_ti
{
Workspace *workspace = Workspace::self();
if (X11Client *c = workspace->findClient(Predicate::WindowMatch, w)) {
if (timestamp == XCB_CURRENT_TIME)
if (timestamp == XCB_CURRENT_TIME) {
timestamp = c->userTime();
if (src != NET::FromApplication && src != FromTool)
}
if (src != NET::FromApplication && src != FromTool) {
src = NET::FromTool;
if (src == NET::FromTool)
}
if (src == NET::FromTool) {
workspace->activateClient(c, true); // force
else if (c == workspace->mostRecentlyActivatedClient()) {
} else if (c == workspace->mostRecentlyActivatedClient()) {
return; // WORKAROUND? With > 1 plasma activities, we cause this ourselves. bug #240673
} else { // NET::FromApplication
X11Client *c2;
if (workspace->allowClientActivation(c, timestamp, false, true))
if (workspace->allowClientActivation(c, timestamp, false, true)) {
workspace->activateClient(c);
// if activation of the requestor's window would be allowed, allow activation too
else if (active_window != XCB_WINDOW_NONE
&& (c2 = workspace->findClient(Predicate::WindowMatch, active_window)) != nullptr
&& workspace->allowClientActivation(c2,
timestampCompare(timestamp, c2->userTime() > 0 ? timestamp : c2->userTime()), false, true)) {
} else if (active_window != XCB_WINDOW_NONE
&& (c2 = workspace->findClient(Predicate::WindowMatch, active_window)) != nullptr
&& workspace->allowClientActivation(c2,
timestampCompare(timestamp, c2->userTime() > 0 ? timestamp : c2->userTime()), false, true)) {
workspace->activateClient(c);
} else
} else {
c->demandAttention();
}
}
}
}
@ -179,10 +182,12 @@ void RootInfo::changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_ti
void RootInfo::restackWindow(xcb_window_t w, RequestSource src, xcb_window_t above, int detail, xcb_timestamp_t timestamp)
{
if (X11Client *c = Workspace::self()->findClient(Predicate::WindowMatch, w)) {
if (timestamp == XCB_CURRENT_TIME)
if (timestamp == XCB_CURRENT_TIME) {
timestamp = c->userTime();
if (src != NET::FromApplication && src != FromTool)
}
if (src != NET::FromApplication && src != FromTool) {
src = NET::FromTool;
}
c->restackWindow(above, detail, src, timestamp, true);
}
}
@ -190,8 +195,9 @@ void RootInfo::restackWindow(xcb_window_t w, RequestSource src, xcb_window_t abo
void RootInfo::closeWindow(xcb_window_t w)
{
X11Client *c = Workspace::self()->findClient(Predicate::WindowMatch, w);
if (c)
if (c) {
c->closeWindow();
}
}
void RootInfo::moveResize(xcb_window_t w, int x_root, int y_root, unsigned long direction)
@ -206,14 +212,16 @@ void RootInfo::moveResize(xcb_window_t w, int x_root, int y_root, unsigned long
void RootInfo::moveResizeWindow(xcb_window_t w, int flags, int x, int y, int width, int height)
{
X11Client *c = Workspace::self()->findClient(Predicate::WindowMatch, w);
if (c)
if (c) {
c->NETMoveResizeWindow(flags, x, y, width, height);
}
}
void RootInfo::gotPing(xcb_window_t w, xcb_timestamp_t timestamp)
{
if (X11Client *c = Workspace::self()->findClient(Predicate::WindowMatch, w))
if (X11Client *c = Workspace::self()->findClient(Predicate::WindowMatch, w)) {
c->gotPing(timestamp);
}
}
void RootInfo::changeShowingDesktop(bool showing)
@ -258,34 +266,45 @@ void WinInfo::changeState(NET::States state, NET::States mask)
mask &= ~NET::Hidden; // clients are not allowed to change this directly
state &= mask; // for safety, clear all other bits
if ((mask & NET::FullScreen) != 0 && (state & NET::FullScreen) == 0)
if ((mask & NET::FullScreen) != 0 && (state & NET::FullScreen) == 0) {
m_client->setFullScreen(false, false);
if ((mask & NET::Max) == NET::Max)
}
if ((mask & NET::Max) == NET::Max) {
m_client->setMaximize(state & NET::MaxVert, state & NET::MaxHoriz);
else if (mask & NET::MaxVert)
} else if (mask & NET::MaxVert) {
m_client->setMaximize(state & NET::MaxVert, m_client->maximizeMode() & MaximizeHorizontal);
else if (mask & NET::MaxHoriz)
} else if (mask & NET::MaxHoriz) {
m_client->setMaximize(m_client->maximizeMode() & MaximizeVertical, state & NET::MaxHoriz);
}
if (mask & NET::Shaded)
if (mask & NET::Shaded) {
m_client->setShade(state & NET::Shaded ? ShadeNormal : ShadeNone);
if (mask & NET::KeepAbove)
}
if (mask & NET::KeepAbove) {
m_client->setKeepAbove((state & NET::KeepAbove) != 0);
if (mask & NET::KeepBelow)
}
if (mask & NET::KeepBelow) {
m_client->setKeepBelow((state & NET::KeepBelow) != 0);
if (mask & NET::SkipTaskbar)
}
if (mask & NET::SkipTaskbar) {
m_client->setOriginalSkipTaskbar((state & NET::SkipTaskbar) != 0);
if (mask & NET::SkipPager)
}
if (mask & NET::SkipPager) {
m_client->setSkipPager((state & NET::SkipPager) != 0);
if (mask & NET::SkipSwitcher)
}
if (mask & NET::SkipSwitcher) {
m_client->setSkipSwitcher((state & NET::SkipSwitcher) != 0);
if (mask & NET::DemandsAttention)
}
if (mask & NET::DemandsAttention) {
m_client->demandAttention((state & NET::DemandsAttention) != 0);
if (mask & NET::Modal)
}
if (mask & NET::Modal) {
m_client->setModal((state & NET::Modal) != 0);
}
// unsetting fullscreen first, setting it last (because e.g. maximize works only for !isFullScreen() )
if ((mask & NET::FullScreen) != 0 && (state & NET::FullScreen) != 0)
if ((mask & NET::FullScreen) != 0 && (state & NET::FullScreen) != 0) {
m_client->setFullScreen(true, false);
}
}
void WinInfo::disable()

View File

@ -603,10 +603,11 @@ void Options::setGlPreferBufferSwap(char glPreferBufferSwap)
// buffer copying is very fast with the nvidia blob
// but due to restrictions in DRI2 *incredibly* slow for all MESA drivers
// see https://www.x.org/releases/X11R7.7/doc/dri2proto/dri2proto.txt, item 2.5
if (GLPlatform::instance()->driver() == Driver_NVidia)
if (GLPlatform::instance()->driver() == Driver_NVidia) {
glPreferBufferSwap = CopyFrontBuffer;
else if (GLPlatform::instance()->driver() != Driver_Unknown) // undetected, finally resolved when context is initialized
} else if (GLPlatform::instance()->driver() != Driver_Unknown) { // undetected, finally resolved when context is initialized
glPreferBufferSwap = ExtendDamage;
}
}
if (m_glPreferBufferSwap == (GlSwapStrategy)glPreferBufferSwap) {
return;
@ -797,10 +798,11 @@ bool Options::loadCompositingConfig(bool force)
bool useCompositing = false;
CompositingType compositingMode = NoCompositing;
QString compositingBackend = config.readEntry("Backend", "OpenGL");
if (compositingBackend == "QPainter")
if (compositingBackend == "QPainter") {
compositingMode = QPainterCompositing;
else
} else {
compositingMode = OpenGLCompositing;
}
if (const char *c = getenv("KWIN_COMPOSE")) {
switch (c[0]) {
@ -815,10 +817,11 @@ bool Options::loadCompositingConfig(bool force)
useCompositing = true;
break;
case 'N':
if (getenv("KDE_FAILSAFE"))
if (getenv("KDE_FAILSAFE")) {
qCDebug(KWIN_CORE) << "Compositing disabled forcefully by KDE failsafe mode";
else
} else {
qCDebug(KWIN_CORE) << "Compositing disabled forcefully by environment variable";
}
compositingMode = NoCompositing;
break;
default:
@ -837,8 +840,9 @@ bool Options::loadCompositingConfig(bool force)
// it's either enforced by env or by initial resume from "suspend" or we check the settings
setUseCompositing(useCompositing || force || config.readEntry("Enabled", Options::defaultUseCompositing() || !platformSupportsNoCompositing));
if (!m_useCompositing)
if (!m_useCompositing) {
return false; // not enforced or necessary and not "enabled" by settings
}
return true;
}
@ -861,21 +865,24 @@ void Options::reloadCompositingSettings(bool force)
char c = 0;
const QString s = config.readEntry("GLPreferBufferSwap", QString(QLatin1Char(Options::defaultGlPreferBufferSwap())));
if (!s.isEmpty())
if (!s.isEmpty()) {
c = s.at(0).toLatin1();
if (c != 'a' && c != 'c' && c != 'p' && c != 'e')
}
if (c != 'a' && c != 'c' && c != 'p' && c != 'e') {
c = Options::defaultGlPreferBufferSwap();
}
setGlPreferBufferSwap(c);
HiddenPreviews previews = Options::defaultHiddenPreviews();
// 4 - off, 5 - shown, 6 - always, other are old values
int hps = config.readEntry("HiddenPreviews", 5);
if (hps == 4)
if (hps == 4) {
previews = HiddenPreviewsNever;
else if (hps == 5)
} else if (hps == 5) {
previews = HiddenPreviewsShown;
else if (hps == 6)
} else if (hps == 6) {
previews = HiddenPreviewsAlways;
}
setHiddenPreviews(previews);
auto interfaceToKey = [](OpenGLPlatformInterface interface) {
@ -905,96 +912,125 @@ void Options::reloadCompositingSettings(bool force)
// may not be able to move it back, unless they know about Meta+LMB)
Options::WindowOperation Options::windowOperation(const QString &name, bool restricted)
{
if (name == QStringLiteral("Move"))
if (name == QStringLiteral("Move")) {
return restricted ? MoveOp : UnrestrictedMoveOp;
else if (name == QStringLiteral("Resize"))
} else if (name == QStringLiteral("Resize")) {
return restricted ? ResizeOp : UnrestrictedResizeOp;
else if (name == QStringLiteral("Maximize"))
} else if (name == QStringLiteral("Maximize")) {
return MaximizeOp;
else if (name == QStringLiteral("Minimize"))
} else if (name == QStringLiteral("Minimize")) {
return MinimizeOp;
else if (name == QStringLiteral("Close"))
} else if (name == QStringLiteral("Close")) {
return CloseOp;
else if (name == QStringLiteral("OnAllDesktops"))
} else if (name == QStringLiteral("OnAllDesktops")) {
return OnAllDesktopsOp;
else if (name == QStringLiteral("Shade"))
} else if (name == QStringLiteral("Shade")) {
return ShadeOp;
else if (name == QStringLiteral("Operations"))
} else if (name == QStringLiteral("Operations")) {
return OperationsOp;
else if (name == QStringLiteral("Maximize (vertical only)"))
} else if (name == QStringLiteral("Maximize (vertical only)")) {
return VMaximizeOp;
else if (name == QStringLiteral("Maximize (horizontal only)"))
} else if (name == QStringLiteral("Maximize (horizontal only)")) {
return HMaximizeOp;
else if (name == QStringLiteral("Lower"))
} else if (name == QStringLiteral("Lower")) {
return LowerOp;
}
return NoOp;
}
Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted)
{
QString lowerName = name.toLower();
if (lowerName == QStringLiteral("raise"))
if (lowerName == QStringLiteral("raise")) {
return MouseRaise;
if (lowerName == QStringLiteral("lower"))
}
if (lowerName == QStringLiteral("lower")) {
return MouseLower;
if (lowerName == QStringLiteral("operations menu"))
}
if (lowerName == QStringLiteral("operations menu")) {
return MouseOperationsMenu;
if (lowerName == QStringLiteral("toggle raise and lower"))
}
if (lowerName == QStringLiteral("toggle raise and lower")) {
return MouseToggleRaiseAndLower;
if (lowerName == QStringLiteral("activate and raise"))
}
if (lowerName == QStringLiteral("activate and raise")) {
return MouseActivateAndRaise;
if (lowerName == QStringLiteral("activate and lower"))
}
if (lowerName == QStringLiteral("activate and lower")) {
return MouseActivateAndLower;
if (lowerName == QStringLiteral("activate"))
}
if (lowerName == QStringLiteral("activate")) {
return MouseActivate;
if (lowerName == QStringLiteral("activate, raise and pass click"))
}
if (lowerName == QStringLiteral("activate, raise and pass click")) {
return MouseActivateRaiseAndPassClick;
if (lowerName == QStringLiteral("activate and pass click"))
}
if (lowerName == QStringLiteral("activate and pass click")) {
return MouseActivateAndPassClick;
if (lowerName == QStringLiteral("scroll"))
}
if (lowerName == QStringLiteral("scroll")) {
return MouseNothing;
if (lowerName == QStringLiteral("activate and scroll"))
}
if (lowerName == QStringLiteral("activate and scroll")) {
return MouseActivateAndPassClick;
if (lowerName == QStringLiteral("activate, raise and scroll"))
}
if (lowerName == QStringLiteral("activate, raise and scroll")) {
return MouseActivateRaiseAndPassClick;
if (lowerName == QStringLiteral("activate, raise and move"))
}
if (lowerName == QStringLiteral("activate, raise and move")) {
return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
if (lowerName == QStringLiteral("move"))
}
if (lowerName == QStringLiteral("move")) {
return restricted ? MouseMove : MouseUnrestrictedMove;
if (lowerName == QStringLiteral("resize"))
}
if (lowerName == QStringLiteral("resize")) {
return restricted ? MouseResize : MouseUnrestrictedResize;
if (lowerName == QStringLiteral("shade"))
}
if (lowerName == QStringLiteral("shade")) {
return MouseShade;
if (lowerName == QStringLiteral("minimize"))
}
if (lowerName == QStringLiteral("minimize")) {
return MouseMinimize;
if (lowerName == QStringLiteral("close"))
}
if (lowerName == QStringLiteral("close")) {
return MouseClose;
if (lowerName == QStringLiteral("increase opacity"))
}
if (lowerName == QStringLiteral("increase opacity")) {
return MouseOpacityMore;
if (lowerName == QStringLiteral("decrease opacity"))
}
if (lowerName == QStringLiteral("decrease opacity")) {
return MouseOpacityLess;
if (lowerName == QStringLiteral("nothing"))
}
if (lowerName == QStringLiteral("nothing")) {
return MouseNothing;
}
return MouseNothing;
}
Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name)
{
QString lowerName = name.toLower();
if (lowerName == QStringLiteral("raise/lower"))
if (lowerName == QStringLiteral("raise/lower")) {
return MouseWheelRaiseLower;
if (lowerName == QStringLiteral("shade/unshade"))
}
if (lowerName == QStringLiteral("shade/unshade")) {
return MouseWheelShadeUnshade;
if (lowerName == QStringLiteral("maximize/restore"))
}
if (lowerName == QStringLiteral("maximize/restore")) {
return MouseWheelMaximizeRestore;
if (lowerName == QStringLiteral("above/below"))
}
if (lowerName == QStringLiteral("above/below")) {
return MouseWheelAboveBelow;
if (lowerName == QStringLiteral("previous/next desktop"))
}
if (lowerName == QStringLiteral("previous/next desktop")) {
return MouseWheelPreviousNextDesktop;
if (lowerName == QStringLiteral("change opacity"))
}
if (lowerName == QStringLiteral("change opacity")) {
return MouseWheelChangeOpacity;
if (lowerName == QStringLiteral("nothing"))
}
if (lowerName == QStringLiteral("nothing")) {
return MouseWheelNothing;
}
return MouseWheelNothing;
}

View File

@ -52,26 +52,28 @@ void Placement::place(AbstractClient *c, const QRect &area)
return;
}
if (c->isUtility())
if (c->isUtility()) {
placeUtility(c, area, options->placement());
else if (c->isDialog())
} else if (c->isDialog()) {
placeDialog(c, area, options->placement());
else if (c->isSplash())
} else if (c->isSplash()) {
placeOnMainWindow(c, area); // on mainwindow, if any, otherwise centered
else if (c->isOnScreenDisplay() || c->isNotification() || c->isCriticalNotification())
} else if (c->isOnScreenDisplay() || c->isNotification() || c->isCriticalNotification()) {
placeOnScreenDisplay(c, area);
else if (c->isTransient() && c->hasTransientPlacementHint())
} else if (c->isTransient() && c->hasTransientPlacementHint()) {
placeTransient(c);
else if (c->isTransient() && c->surface())
} else if (c->isTransient() && c->surface()) {
placeDialog(c, area, options->placement());
else
} else {
place(c, area, options->placement());
}
}
void Placement::place(AbstractClient *c, const QRect &area, Policy policy, Policy nextPlacement)
{
if (policy == Unknown || policy == Default)
if (policy == Unknown || policy == Default) {
policy = options->placement();
}
switch (policy) {
case NoPlacement:
@ -134,14 +136,16 @@ void Placement::placeAtRandom(AbstractClient *c, const QRect &area, Policy /*nex
ty = py;
if (tx + c->width() > area.right()) {
tx = area.right() - c->width();
if (tx < 0)
if (tx < 0) {
tx = 0;
}
px = area.x();
}
if (ty + c->height() > area.bottom()) {
ty = area.bottom() - c->height();
if (ty < 0)
if (ty < 0) {
ty = 0;
}
py = area.y();
}
c->move(QPoint(tx, ty));
@ -150,18 +154,24 @@ void Placement::placeAtRandom(AbstractClient *c, const QRect &area, Policy /*nex
// TODO: one day, there'll be C++11 ...
static inline bool isIrrelevant(const AbstractClient *client, const AbstractClient *regarding, int desktop)
{
if (!client)
if (!client) {
return true;
if (client == regarding)
}
if (client == regarding) {
return true;
if (!client->isShown() || client->isShade())
}
if (!client->isShown() || client->isShade()) {
return true;
if (!client->isOnDesktop(desktop))
}
if (!client->isOnDesktop(desktop)) {
return true;
if (!client->isOnCurrentActivity())
}
if (!client->isOnCurrentActivity()) {
return true;
if (client->isDesktop())
}
if (client->isDesktop()) {
return true;
}
return false;
}
@ -237,12 +247,13 @@ void Placement::placeSmart(AbstractClient *c, const QRect &area, Policy /*next*/
xr = qMin(cxr, xr);
yt = qMax(cyt, yt);
yb = qMin(cyb, yb);
if (client->keepAbove())
if (client->keepAbove()) {
overlap += 16 * (xr - xl) * (yb - yt);
else if (client->keepBelow() && !client->isDock()) // ignore KeepBelow windows
} else if (client->keepBelow() && !client->isDock()) { // ignore KeepBelow windows
overlap += 0; // for placement (see X11Client::belongsToLayer() for Dock)
else
} else {
overlap += (xr - xl) * (yb - yt);
}
}
}
}
@ -269,8 +280,9 @@ void Placement::placeSmart(AbstractClient *c, const QRect &area, Policy /*next*/
if (overlap > none) {
possible = area.right();
if (possible - cw > x)
if (possible - cw > x) {
possible -= cw;
}
// compare to the position of each client on the same desk
for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd(); ++l) {
@ -288,12 +300,14 @@ void Placement::placeSmart(AbstractClient *c, const QRect &area, Policy /*next*/
// determine the first non-overlapped x position
if ((y < yb) && (yt < ch + y)) {
if ((xr > x) && (possible > xr))
if ((xr > x) && (possible > xr)) {
possible = xr;
}
basket = xl - cw;
if ((basket > x) && (possible > basket))
if ((basket > x) && (possible > basket)) {
possible = basket;
}
}
}
x = possible;
@ -304,8 +318,9 @@ void Placement::placeSmart(AbstractClient *c, const QRect &area, Policy /*next*/
x = area.left();
possible = area.bottom();
if (possible - ch > y)
if (possible - ch > y) {
possible -= ch;
}
// test the position of each window on the desk
for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd(); ++l) {
@ -321,12 +336,14 @@ void Placement::placeSmart(AbstractClient *c, const QRect &area, Policy /*next*/
// if not enough room to the left or right of the current tested client
// determine the first non-overlapped y position
if ((yb > y) && (possible > yb))
if ((yb > y) && (possible > yb)) {
possible = yb;
}
basket = yt - ch;
if ((basket > y) && (possible > basket))
if ((basket > y) && (possible > basket)) {
possible = basket;
}
}
y = possible;
}
@ -393,8 +410,9 @@ void Placement::placeCascaded(AbstractClient *c, const QRect &area, Policy nextP
const int H = area.height();
const int W = area.width();
if (nextPlacement == Unknown)
if (nextPlacement == Unknown) {
nextPlacement = Smart;
}
// initialize if needed
if (cci[dn].pos.x() < 0 || cci[dn].pos.x() < X || cci[dn].pos.y() < Y) {
@ -406,15 +424,17 @@ void Placement::placeCascaded(AbstractClient *c, const QRect &area, Policy nextP
yp = cci[dn].pos.y();
// here to touch in case people vote for resize on placement
if ((yp + ch) > H)
if ((yp + ch) > H) {
yp = Y;
}
if ((xp + cw) > W) {
if (!yp) {
place(c, area, nextPlacement);
return;
} else
} else {
xp = X;
}
}
// if this isn't the first window
@ -535,23 +555,26 @@ void Placement::placeOnMainWindow(AbstractClient *c, const QRect &area, Policy n
{
Q_ASSERT(area.isValid());
if (nextPlacement == Unknown)
if (nextPlacement == Unknown) {
nextPlacement = Centered;
if (nextPlacement == Maximizing) // maximize if needed
}
if (nextPlacement == Maximizing) { // maximize if needed
placeMaximizing(c, area, NoPlacement);
}
auto mainwindows = c->mainClients();
AbstractClient *place_on = nullptr;
AbstractClient *place_on2 = nullptr;
int mains_count = 0;
for (auto it = mainwindows.constBegin(); it != mainwindows.constEnd(); ++it) {
if (mainwindows.count() > 1 && (*it)->isSpecialWindow())
if (mainwindows.count() > 1 && (*it)->isSpecialWindow()) {
continue; // don't consider toolbars etc when placing
}
++mains_count;
place_on2 = *it;
if ((*it)->isOnCurrentDesktop()) {
if (place_on == nullptr)
if (place_on == nullptr) {
place_on = *it;
else {
} else {
// two or more on current desktop -> center
// That's the default at least. However, with maximizing placement
// policy as the default, the dialog should be either maximized or
@ -587,12 +610,13 @@ void Placement::placeMaximizing(AbstractClient *c, const QRect &area, Policy nex
{
Q_ASSERT(area.isValid());
if (nextPlacement == Unknown)
if (nextPlacement == Unknown) {
nextPlacement = Smart;
}
if (c->isMaximizable() && c->maxSize().width() >= area.width() && c->maxSize().height() >= area.height()) {
if (workspace()->clientArea(MaximizeArea, c) == area)
if (workspace()->clientArea(MaximizeArea, c) == area) {
c->maximize(MaximizeFull);
else { // if the geometry doesn't match default maximize area (xinerama case?),
} else { // if the geometry doesn't match default maximize area (xinerama case?),
// it's probably better to use the given area
c->moveResize(area);
}
@ -610,8 +634,9 @@ void Placement::cascadeDesktop()
const auto stackingOrder = ws->stackingOrder();
for (Toplevel *toplevel : stackingOrder) {
auto client = qobject_cast<AbstractClient *>(toplevel);
if (!client || (!client->isOnCurrentDesktop()) || (client->isMinimized()) || (client->isOnAllDesktops()) || (!client->isMovable()))
if (!client || (!client->isOnCurrentDesktop()) || (client->isMinimized()) || (client->isOnAllDesktops()) || (!client->isMovable())) {
continue;
}
const QRect placementArea = workspace()->clientArea(PlacementArea, client);
placeCascaded(client, placementArea);
}
@ -622,8 +647,9 @@ void Placement::unclutterDesktop()
const auto &clients = Workspace::self()->allClientList();
for (int i = clients.size() - 1; i >= 0; i--) {
auto client = clients.at(i);
if ((!client->isOnCurrentDesktop()) || (client->isMinimized()) || (client->isOnAllDesktops()) || (!client->isMovable()))
if ((!client->isOnCurrentDesktop()) || (client->isMinimized()) || (client->isOnAllDesktops()) || (!client->isMovable())) {
continue;
}
const QRect placementArea = workspace()->clientArea(PlacementArea, client);
placeSmart(client, placementArea);
}
@ -654,8 +680,9 @@ void AbstractClient::packTo(int left, int top)
move(QPoint(left, top));
if (output() != oldOutput) {
workspace()->sendClientToOutput(this, output()); // checks rule validity
if (maximizeMode() != MaximizeRestore)
if (maximizeMode() != MaximizeRestore) {
checkWorkspacePosition();
}
}
}
@ -711,14 +738,16 @@ void Workspace::slotWindowCenter()
void Workspace::slotWindowExpandHorizontal()
{
if (active_client)
if (active_client) {
active_client->growHorizontal();
}
}
void AbstractClient::growHorizontal()
{
if (!isResizable() || isShade())
if (!isResizable() || isShade()) {
return;
}
QRect geom = moveResizeGeometry();
geom.setRight(workspace()->packPositionRight(this, geom.right(), true));
QSize adjsize = constrainFrameSize(geom.size(), SizeModeFixedW);
@ -730,8 +759,9 @@ void AbstractClient::growHorizontal()
this,
QPoint((x() + newright) / 2, moveResizeGeometry().center().y()))
.right()
>= newright)
>= newright) {
geom.setRight(newright);
}
}
geom.setSize(constrainFrameSize(geom.size(), SizeModeFixedW));
geom.setSize(constrainFrameSize(geom.size(), SizeModeFixedH));
@ -741,18 +771,21 @@ void AbstractClient::growHorizontal()
void Workspace::slotWindowShrinkHorizontal()
{
if (active_client)
if (active_client) {
active_client->shrinkHorizontal();
}
}
void AbstractClient::shrinkHorizontal()
{
if (!isResizable() || isShade())
if (!isResizable() || isShade()) {
return;
}
QRect geom = moveResizeGeometry();
geom.setRight(workspace()->packPositionLeft(this, geom.right(), false));
if (geom.width() <= 1)
if (geom.width() <= 1) {
return;
}
geom.setSize(constrainFrameSize(geom.size(), SizeModeFixedW));
if (geom.width() > 20) {
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event;
@ -762,14 +795,16 @@ void AbstractClient::shrinkHorizontal()
void Workspace::slotWindowExpandVertical()
{
if (active_client)
if (active_client) {
active_client->growVertical();
}
}
void AbstractClient::growVertical()
{
if (!isResizable() || isShade())
if (!isResizable() || isShade()) {
return;
}
QRect geom = moveResizeGeometry();
geom.setBottom(workspace()->packPositionDown(this, geom.bottom(), true));
QSize adjsize = constrainFrameSize(geom.size(), SizeModeFixedH);
@ -780,8 +815,9 @@ void AbstractClient::growVertical()
this,
QPoint(moveResizeGeometry().center().x(), (y() + newbottom) / 2))
.bottom()
>= newbottom)
>= newbottom) {
geom.setBottom(newbottom);
}
}
geom.setSize(constrainFrameSize(geom.size(), SizeModeFixedH));
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event;
@ -790,18 +826,21 @@ void AbstractClient::growVertical()
void Workspace::slotWindowShrinkVertical()
{
if (active_client)
if (active_client) {
active_client->shrinkVertical();
}
}
void AbstractClient::shrinkVertical()
{
if (!isResizable() || isShade())
if (!isResizable() || isShade()) {
return;
}
QRect geom = moveResizeGeometry();
geom.setBottom(workspace()->packPositionUp(this, geom.bottom(), false));
if (geom.height() <= 1)
if (geom.height() <= 1) {
return;
}
geom.setSize(constrainFrameSize(geom.size(), SizeModeFixedH));
if (geom.height() > 20) {
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event;

View File

@ -526,8 +526,9 @@ static quint32 monotonicTime()
timespec ts;
const int result = clock_gettime(CLOCK_MONOTONIC, &ts);
if (result)
if (result) {
qCWarning(KWIN_CORE, "Failed to query monotonic time: %s", strerror(errno));
}
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000L;
}

View File

@ -145,8 +145,9 @@ void AbstractEglBackend::initKWinGL()
GLPlatform *glPlatform = GLPlatform::instance();
glPlatform->detect(EglPlatformInterface);
options->setGlPreferBufferSwap(options->glPreferBufferSwap()); // resolve autosetting
if (options->glPreferBufferSwap() == Options::AutoSwapStrategy)
if (options->glPreferBufferSwap() == Options::AutoSwapStrategy) {
options->setGlPreferBufferSwap('e'); // for unknown drivers - should not happen
}
glPlatform->printResults();
initGL(&getProcAddress);
}

View File

@ -103,8 +103,9 @@ QPixmap PlastikButtonProvider::requestPixmap(const QString &id, QSize *size, con
QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool shadow)
{
Q_UNUSED(active);
if (size % 2 == 0)
if (size % 2 == 0) {
--size;
}
QPixmap image(size, size);
image.fill(Qt::transparent);
@ -175,8 +176,9 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool
int margin1, margin2;
margin1 = margin2 = lineWidth2 * 2;
if (r.width() < 8)
if (r.width() < 8) {
margin1 = 1;
}
// background window
drawObject(p, HorizontalLine, r.x() + margin1, r.top(), r.width() - margin1, lineWidth2);
@ -258,8 +260,9 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool
case NotOnAllDesktopsIcon: {
int lwMark = r.width() - lwTitleBar * 2 - 2;
if (lwMark < 1)
if (lwMark < 1) {
lwMark = 3;
}
drawObject(p, HorizontalLine, r.x() + (r.width() - lwMark) / 2, r.y() + (r.height() - lwMark) / 2, lwMark, lwMark);
@ -283,8 +286,9 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool
// arrow
drawObject(p, CrossDiagonalLine, r.x(), center + 2 * lwArrow, center - r.x(), lwArrow);
drawObject(p, DiagonalLine, r.x() + center, r.y() + 1 + 2 * lwArrow, center - r.x(), lwArrow);
if (lwArrow > 1)
if (lwArrow > 1) {
drawObject(p, HorizontalLine, center - (lwArrow - 2), r.y() + 2 * lwArrow, (lwArrow - 2) * 2, lwArrow);
}
// Fall through to KeepAboveIcon intended!
Q_FALLTHROUGH();
@ -295,8 +299,9 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool
// arrow
drawObject(p, CrossDiagonalLine, r.x(), center, center - r.x(), lwArrow);
drawObject(p, DiagonalLine, r.x() + center, r.y() + 1, center - r.x(), lwArrow);
if (lwArrow > 1)
if (lwArrow > 1) {
drawObject(p, HorizontalLine, center - (lwArrow - 2), r.y(), (lwArrow - 2) * 2, lwArrow);
}
break;
}
@ -307,8 +312,9 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool
// arrow
drawObject(p, DiagonalLine, r.x(), center - 2 * lwArrow, center - r.x(), lwArrow);
drawObject(p, CrossDiagonalLine, r.x() + center, r.bottom() - 1 - 2 * lwArrow, center - r.x(), lwArrow);
if (lwArrow > 1)
if (lwArrow > 1) {
drawObject(p, HorizontalLine, center - (lwArrow - 2), r.bottom() - (lwArrow - 1) - 2 * lwArrow, (lwArrow - 2) * 2, lwArrow);
}
// Fall through to KeepBelowIcon intended!
Q_FALLTHROUGH();
@ -319,8 +325,9 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool
// arrow
drawObject(p, DiagonalLine, r.x(), center, center - r.x(), lwArrow);
drawObject(p, CrossDiagonalLine, r.x() + center, r.bottom() - 1, center - r.x(), lwArrow);
if (lwArrow > 1)
if (lwArrow > 1) {
drawObject(p, HorizontalLine, center - (lwArrow - 2), r.bottom() - (lwArrow - 1), (lwArrow - 2) * 2, lwArrow);
}
break;
}

View File

@ -67,8 +67,9 @@ bool PipeWireCore::init()
QSocketNotifier *notifier = new QSocketNotifier(pw_loop_get_fd(pwMainLoop), QSocketNotifier::Read, this);
connect(notifier, &QSocketNotifier::activated, this, [this] {
int result = pw_loop_iterate(pwMainLoop, 0);
if (result < 0)
if (result < 0) {
qCWarning(KWIN_SCREENCAST) << "pipewire_loop_iterate failed: " << result;
}
});
pwContext = pw_context_new(pwMainLoop, nullptr, 0);

View File

@ -141,8 +141,9 @@ void ScreenCastStream::onStreamAddBuffer(void *data, pw_buffer *buffer)
spa_data->mapoffset = 0;
spa_data->flags = SPA_DATA_FLAG_READWRITE;
if (spa_data[0].type != SPA_ID_INVALID && spa_data[0].type & (1 << SPA_DATA_DmaBuf))
if (spa_data[0].type != SPA_ID_INVALID && spa_data[0].type & (1 << SPA_DATA_DmaBuf)) {
dmabuf.reset(kwinApp()->platform()->createDmaBufTexture(stream->m_resolution));
}
if (dmabuf) {
spa_data->type = SPA_DATA_DmaBuf;
@ -175,8 +176,9 @@ void ScreenCastStream::onStreamAddBuffer(void *data, pw_buffer *buffer)
}
unsigned int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL;
if (fcntl(spa_data->fd, F_ADD_SEALS, seals) == -1)
if (fcntl(spa_data->fd, F_ADD_SEALS, seals) == -1) {
qCWarning(KWIN_SCREENCAST) << "memfd: Failed to add seals";
}
spa_data->data = mmap(nullptr,
spa_data->maxsize,
@ -184,10 +186,11 @@ void ScreenCastStream::onStreamAddBuffer(void *data, pw_buffer *buffer)
MAP_SHARED,
spa_data->fd,
spa_data->mapoffset);
if (spa_data->data == MAP_FAILED)
if (spa_data->data == MAP_FAILED) {
qCCritical(KWIN_SCREENCAST) << "memfd: Failed to mmap memory";
else
} else {
qCDebug(KWIN_SCREENCAST) << "memfd: created successfully" << spa_data->data << spa_data->maxsize;
}
#endif
}
}
@ -412,8 +415,9 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion)
mvp.ortho(r);
shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
if (!m_cursor.texture || m_cursor.lastKey != cursor->image().cacheKey())
if (!m_cursor.texture || m_cursor.lastKey != cursor->image().cacheKey()) {
m_cursor.texture.reset(new GLTexture(cursor->image()));
}
m_cursor.texture->setYInverted(false);
m_cursor.texture->bind();

View File

@ -24,10 +24,12 @@ bool RootInfoFilter::event(xcb_generic_event_t *event)
NET::Properties dirtyProtocols;
NET::Properties2 dirtyProtocols2;
m_rootInfo->event(event, &dirtyProtocols, &dirtyProtocols2);
if (dirtyProtocols & NET::DesktopNames)
if (dirtyProtocols & NET::DesktopNames) {
VirtualDesktopManager::self()->save();
if (dirtyProtocols2 & NET::WM2DesktopLayout)
}
if (dirtyProtocols2 & NET::WM2DesktopLayout) {
VirtualDesktopManager::self()->updateLayout();
}
return false;
}

View File

@ -93,8 +93,9 @@ Rules::Rules(const QString &str, bool temporary)
auto cfg = KSharedConfig::openConfig(file.fileName(), KConfig::SimpleConfig);
RuleSettings settings(cfg, QString());
readFromSettings(&settings);
if (description.isEmpty())
if (description.isEmpty()) {
description = QStringLiteral("temporary");
}
}
#define READ_MATCH_STRING(var, func) \
@ -130,14 +131,17 @@ void Rules::readFromSettings(const RuleSettings *settings)
READ_FORCE_RULE(placement, );
READ_SET_RULE(position);
READ_SET_RULE(size);
if (size.isEmpty() && sizerule != static_cast<SetRule>(Remember))
if (size.isEmpty() && sizerule != static_cast<SetRule>(Remember)) {
sizerule = UnusedSetRule;
}
READ_FORCE_RULE(minsize, );
if (!minsize.isValid())
if (!minsize.isValid()) {
minsize = QSize(1, 1);
}
READ_FORCE_RULE(maxsize, );
if (maxsize.isEmpty())
if (maxsize.isEmpty()) {
maxsize = QSize(32767, 32767);
}
READ_FORCE_RULE(opacityactive, );
READ_FORCE_RULE(opacityinactive, );
READ_SET_RULE(ignoregeometry);
@ -145,8 +149,9 @@ void Rules::readFromSettings(const RuleSettings *settings)
READ_SET_RULE(screen);
READ_SET_RULE(activity);
READ_FORCE_RULE(type, static_cast<NET::WindowType>);
if (type == NET::Unknown)
if (type == NET::Unknown) {
typerule = UnusedForceRule;
}
READ_SET_RULE(maximizevert);
READ_SET_RULE(maximizehoriz);
READ_SET_RULE(minimize);
@ -160,8 +165,9 @@ void Rules::readFromSettings(const RuleSettings *settings)
READ_SET_RULE(noborder);
READ_FORCE_RULE(decocolor, getDecoColor);
if (decocolor.isEmpty())
if (decocolor.isEmpty()) {
decocolorrule = UnusedForceRule;
}
READ_FORCE_RULE(blockcompositing, );
READ_FORCE_RULE(fsplevel, );
@ -302,8 +308,9 @@ bool Rules::isEmpty() const
Rules::ForceRule Rules::convertForceRule(int v)
{
if (v == DontAffect || v == Force || v == ForceTemporarily)
if (v == DontAffect || v == Force || v == ForceTemporarily) {
return static_cast<ForceRule>(v);
}
return UnusedForceRule;
}
@ -320,10 +327,12 @@ QString Rules::getDecoColor(const QString &themeName)
bool Rules::matchType(NET::WindowType match_type) const
{
if (types != NET::AllTypesMask) {
if (match_type == NET::Unknown)
if (match_type == NET::Unknown) {
match_type = NET::Normal; // NET::Unknown->NET::Normal is only here for matching
if (!NET::typeMatchesMask(match_type, types))
}
if (!NET::typeMatchesMask(match_type, types)) {
return false;
}
}
return true;
}
@ -335,12 +344,15 @@ bool Rules::matchWMClass(const QByteArray &match_class, const QByteArray &match_
QByteArray cwmclass = wmclasscomplete
? match_name + ' ' + match_class
: match_class;
if (wmclassmatch == RegExpMatch && !QRegularExpression(QString::fromUtf8(wmclass)).match(QString::fromUtf8(cwmclass)).hasMatch())
if (wmclassmatch == RegExpMatch && !QRegularExpression(QString::fromUtf8(wmclass)).match(QString::fromUtf8(cwmclass)).hasMatch()) {
return false;
if (wmclassmatch == ExactMatch && wmclass != cwmclass)
}
if (wmclassmatch == ExactMatch && wmclass != cwmclass) {
return false;
if (wmclassmatch == SubstringMatch && !cwmclass.contains(wmclass))
}
if (wmclassmatch == SubstringMatch && !cwmclass.contains(wmclass)) {
return false;
}
}
return true;
}
@ -348,12 +360,15 @@ bool Rules::matchWMClass(const QByteArray &match_class, const QByteArray &match_
bool Rules::matchRole(const QByteArray &match_role) const
{
if (windowrolematch != UnimportantMatch) {
if (windowrolematch == RegExpMatch && !QRegularExpression(QString::fromUtf8(windowrole)).match(QString::fromUtf8(match_role)).hasMatch())
if (windowrolematch == RegExpMatch && !QRegularExpression(QString::fromUtf8(windowrole)).match(QString::fromUtf8(match_role)).hasMatch()) {
return false;
if (windowrolematch == ExactMatch && windowrole != match_role)
}
if (windowrolematch == ExactMatch && windowrole != match_role) {
return false;
if (windowrolematch == SubstringMatch && !match_role.contains(windowrole))
}
if (windowrolematch == SubstringMatch && !match_role.contains(windowrole)) {
return false;
}
}
return true;
}
@ -361,12 +376,15 @@ bool Rules::matchRole(const QByteArray &match_role) const
bool Rules::matchTitle(const QString &match_title) const
{
if (titlematch != UnimportantMatch) {
if (titlematch == RegExpMatch && !QRegularExpression(title).match(match_title).hasMatch())
if (titlematch == RegExpMatch && !QRegularExpression(title).match(match_title).hasMatch()) {
return false;
if (titlematch == ExactMatch && title != match_title)
}
if (titlematch == ExactMatch && title != match_title) {
return false;
if (titlematch == SubstringMatch && !match_title.contains(title))
}
if (titlematch == SubstringMatch && !match_title.contains(title)) {
return false;
}
}
return true;
}
@ -376,17 +394,21 @@ bool Rules::matchClientMachine(const QByteArray &match_machine, bool local) cons
if (clientmachinematch != UnimportantMatch) {
// if it's localhost, check also "localhost" before checking hostname
if (match_machine != "localhost" && local
&& matchClientMachine("localhost", true))
&& matchClientMachine("localhost", true)) {
return true;
}
if (clientmachinematch == RegExpMatch
&& !QRegularExpression(QString::fromUtf8(clientmachine)).match(QString::fromUtf8(match_machine)).hasMatch())
&& !QRegularExpression(QString::fromUtf8(clientmachine)).match(QString::fromUtf8(match_machine)).hasMatch()) {
return false;
}
if (clientmachinematch == ExactMatch
&& clientmachine != match_machine)
&& clientmachine != match_machine) {
return false;
}
if (clientmachinematch == SubstringMatch
&& !match_machine.contains(clientmachine))
&& !match_machine.contains(clientmachine)) {
return false;
}
}
return true;
}
@ -394,21 +416,27 @@ bool Rules::matchClientMachine(const QByteArray &match_machine, bool local) cons
#ifndef KCMRULES
bool Rules::match(const AbstractClient *c) const
{
if (!matchType(c->windowType(true)))
if (!matchType(c->windowType(true))) {
return false;
if (!matchWMClass(c->resourceClass(), c->resourceName()))
}
if (!matchWMClass(c->resourceClass(), c->resourceName())) {
return false;
if (!matchRole(c->windowRole().toLower()))
}
if (!matchRole(c->windowRole().toLower())) {
return false;
if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal()))
}
if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal())) {
return false;
if (titlematch != UnimportantMatch) // track title changes to rematch rules
}
if (titlematch != UnimportantMatch) { // track title changes to rematch rules
QObject::connect(c, &AbstractClient::captionChanged, c, &AbstractClient::evaluateWindowRules,
// QueuedConnection, because title may change before
// the client is ready (could segfault!)
static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
if (!matchTitle(c->captionNormal()))
}
if (!matchTitle(c->captionNormal())) {
return false;
}
return true;
}
@ -422,10 +450,12 @@ bool Rules::update(AbstractClient *c, int selection)
if (!c->isFullScreen()) {
QPoint new_pos = position;
// don't use the position in the direction which is maximized
if ((c->maximizeMode() & MaximizeHorizontal) == 0)
if ((c->maximizeMode() & MaximizeHorizontal) == 0) {
new_pos.setX(c->pos().x());
if ((c->maximizeMode() & MaximizeVertical) == 0)
}
if ((c->maximizeMode() & MaximizeVertical) == 0) {
new_pos.setY(c->pos().y());
}
updated = updated || position != new_pos;
position = new_pos;
}
@ -434,10 +464,12 @@ bool Rules::update(AbstractClient *c, int selection)
if (!c->isFullScreen()) {
QSize new_size = size;
// don't use the position in the direction which is maximized
if ((c->maximizeMode() & MaximizeHorizontal) == 0)
if ((c->maximizeMode() & MaximizeHorizontal) == 0) {
new_size.setWidth(c->size().width());
if ((c->maximizeMode() & MaximizeVertical) == 0)
}
if ((c->maximizeMode() & MaximizeVertical) == 0) {
new_size.setHeight(c->size().height());
}
updated = updated || size != new_size;
size = new_size;
}
@ -543,15 +575,17 @@ bool Rules::applyGeometry(QRect &rect, bool init) const
bool Rules::applyPosition(QPoint &pos, bool init) const
{
if (this->position != invalidPoint && checkSetRule(positionrule, init))
if (this->position != invalidPoint && checkSetRule(positionrule, init)) {
pos = this->position;
}
return checkSetStop(positionrule);
}
bool Rules::applySize(QSize &s, bool init) const
{
if (this->size.isValid() && checkSetRule(sizerule, init))
if (this->size.isValid() && checkSetRule(sizerule, init)) {
s = this->size;
}
return checkSetStop(sizerule);
}
@ -580,15 +614,17 @@ bool Rules::applyDesktops(QVector<VirtualDesktop *> &vds, bool init) const
bool Rules::applyMaximizeHoriz(MaximizeMode &mode, bool init) const
{
if (checkSetRule(maximizehorizrule, init))
if (checkSetRule(maximizehorizrule, init)) {
mode = static_cast<MaximizeMode>((maximizehoriz ? MaximizeHorizontal : 0) | (mode & MaximizeVertical));
}
return checkSetStop(maximizehorizrule);
}
bool Rules::applyMaximizeVert(MaximizeMode &mode, bool init) const
{
if (checkSetRule(maximizevertrule, init))
if (checkSetRule(maximizevertrule, init)) {
mode = static_cast<MaximizeMode>((maximizevert ? MaximizeVertical : 0) | (mode & MaximizeHorizontal));
}
return checkSetStop(maximizevertrule);
}
@ -597,10 +633,12 @@ APPLY_RULE(minimize, Minimize, bool)
bool Rules::applyShade(ShadeMode &sh, bool init) const
{
if (checkSetRule(shaderule, init)) {
if (!this->shade)
if (!this->shade) {
sh = ShadeNone;
if (this->shade && sh == ShadeNone)
}
if (this->shade && sh == ShadeNone) {
sh = ShadeNormal;
}
}
return checkSetStop(shaderule);
}
@ -636,8 +674,9 @@ bool Rules::isTemporary() const
bool Rules::discardTemporary(bool force)
{
if (temporary_state == 0) // not temporary
if (temporary_state == 0) { // not temporary
return false;
}
if (force || --temporary_state == 0) { // too old
delete this;
return true;
@ -718,9 +757,9 @@ void WindowRules::discardTemporary()
QVector<Rules *>::Iterator it2 = rules.begin();
for (QVector<Rules *>::Iterator it = rules.begin();
it != rules.end();) {
if ((*it)->discardTemporary(true))
if ((*it)->discardTemporary(true)) {
++it;
else {
} else {
*it2++ = *it++;
}
}
@ -732,11 +771,14 @@ void WindowRules::update(AbstractClient *c, int selection)
bool updated = false;
for (QVector<Rules *>::ConstIterator it = rules.constBegin();
it != rules.constEnd();
++it)
if ((*it)->update(c, selection)) // no short-circuiting here
++it) {
if ((*it)->update(c, selection)) { // no short-circuiting here
updated = true;
if (updated)
}
}
if (updated) {
RuleBook::self()->requestDiskStorage();
}
}
#define CHECK_RULE(rule, type) \
@ -868,10 +910,11 @@ void AbstractClient::applyWindowRules()
// Type
maximize(maximizeMode());
// Minimize : functions don't check, and there are two functions
if (client_rules->checkMinimize(isMinimized()))
if (client_rules->checkMinimize(isMinimized())) {
minimize();
else
} else {
unminimize();
}
setShade(shadeMode());
setOriginalSkipTaskbar(skipTaskbar());
setSkipPager(skipPager());
@ -884,8 +927,9 @@ void AbstractClient::applyWindowRules()
// FSP
// AcceptFocus :
if (workspace()->mostRecentlyActivatedClient() == this
&& !client_rules->checkAcceptFocus(true))
&& !client_rules->checkAcceptFocus(true)) {
workspace()->activateNextClient(this);
}
// Autogrouping : Only checked on window manage
// AutogroupInForeground : Only checked on window manage
// AutogroupById : Only checked on window manage
@ -895,22 +939,25 @@ void AbstractClient::applyWindowRules()
if (isActive()) {
setOpacity(rules()->checkOpacityActive(qRound(opacity() * 100.0)) / 100.0);
workspace()->disableGlobalShortcutsForClient(rules()->checkDisableGlobalShortcuts(false));
} else
} else {
setOpacity(rules()->checkOpacityInactive(qRound(opacity() * 100.0)) / 100.0);
}
setDesktopFileName(rules()->checkDesktopFile(desktopFileName()).toUtf8());
}
void X11Client::updateWindowRules(Rules::Types selection)
{
if (!isManaged()) // not fully setup yet
if (!isManaged()) { // not fully setup yet
return;
}
AbstractClient::updateWindowRules(selection);
}
void AbstractClient::updateWindowRules(Rules::Types selection)
{
if (RuleBook::self()->areUpdatesDisabled())
if (RuleBook::self()->areUpdatesDisabled()) {
return;
}
m_rules.update(this, selection);
}
@ -976,10 +1023,11 @@ WindowRules RuleBook::find(const AbstractClient *c, bool ignore_temporary)
if ((*it)->match(c)) {
Rules *rule = *it;
qCDebug(KWIN_CORE) << "Rule found:" << rule << ":" << c;
if (rule->isTemporary())
if (rule->isTemporary()) {
it = m_rules.erase(it);
else
} else {
++it;
}
ret.append(rule);
continue;
}
@ -993,8 +1041,9 @@ void RuleBook::edit(AbstractClient *c, bool whole_app)
save();
QStringList args;
args << QStringLiteral("--uuid") << c->internalId().toString();
if (whole_app)
if (whole_app) {
args << QStringLiteral("--whole-app");
}
QProcess *p = new QProcess(this);
p->setArguments(args);
p->setProcessEnvironment(kwinApp()->processStartupEnvironment());
@ -1046,13 +1095,16 @@ void RuleBook::temporaryRulesMessage(const QString &message)
bool was_temporary = false;
for (QList<Rules *>::ConstIterator it = m_rules.constBegin();
it != m_rules.constEnd();
++it)
if ((*it)->isTemporary())
++it) {
if ((*it)->isTemporary()) {
was_temporary = true;
}
}
Rules *rule = new Rules(message, true);
m_rules.prepend(rule); // highest priority first
if (!was_temporary)
if (!was_temporary) {
QTimer::singleShot(60000, this, &RuleBook::cleanupTemporaryRules);
}
}
void RuleBook::cleanupTemporaryRules()
@ -1063,13 +1115,15 @@ void RuleBook::cleanupTemporaryRules()
if ((*it)->discardTemporary(false)) { // deletes (*it)
it = m_rules.erase(it);
} else {
if ((*it)->isTemporary())
if ((*it)->isTemporary()) {
has_temporary = true;
}
++it;
}
}
if (has_temporary)
if (has_temporary) {
QTimer::singleShot(60000, this, &RuleBook::cleanupTemporaryRules);
}
}
void RuleBook::discardUsed(AbstractClient *c, bool withdrawn)
@ -1091,8 +1145,9 @@ void RuleBook::discardUsed(AbstractClient *c, bool withdrawn)
}
++it;
}
if (updated)
if (updated) {
requestDiskStorage();
}
}
void RuleBook::requestDiskStorage()

View File

@ -342,8 +342,9 @@ inline bool Rules::checkSetRule(SetRule rule, bool init)
{
if (rule > (SetRule)DontAffect) { // Unused or DontAffect
if (rule == (SetRule)Force || rule == (SetRule)ApplyNow
|| rule == (SetRule)ForceTemporarily || init)
|| rule == (SetRule)ForceTemporarily || init) {
return true;
}
}
return false;
}

View File

@ -641,8 +641,9 @@ void Scene::clearStackingOrder()
void Scene::paintWindow(Window *w, int mask, const QRegion &region)
{
if (region.isEmpty()) // completely clipped
if (region.isEmpty()) { // completely clipped
return;
}
WindowPaintData data(w->window()->effectWindow(), screenProjectionMatrix());
effects->paintWindow(effectWindow(w), mask, region, data);
@ -795,14 +796,18 @@ QRegion Scene::Window::decorationShape() const
bool Scene::Window::isVisible() const
{
if (toplevel->isDeleted())
if (toplevel->isDeleted()) {
return false;
if (!toplevel->isOnCurrentDesktop())
}
if (!toplevel->isOnCurrentDesktop()) {
return false;
if (!toplevel->isOnCurrentActivity())
}
if (!toplevel->isOnCurrentActivity()) {
return false;
if (AbstractClient *c = dynamic_cast<AbstractClient *>(toplevel))
}
if (AbstractClient *c = dynamic_cast<AbstractClient *>(toplevel)) {
return c->isShown();
}
return true; // Unmanaged is always visible
}
@ -819,21 +824,25 @@ bool Scene::Window::isPaintingEnabled() const
void Scene::Window::resetPaintingEnabled()
{
disable_painting = 0;
if (toplevel->isDeleted())
if (toplevel->isDeleted()) {
disable_painting |= PAINT_DISABLED_BY_DELETE;
}
if (static_cast<EffectsHandlerImpl *>(effects)->isDesktopRendering()) {
if (!toplevel->isOnDesktop(static_cast<EffectsHandlerImpl *>(effects)->currentRenderedDesktop())) {
disable_painting |= PAINT_DISABLED_BY_DESKTOP;
}
} else {
if (!toplevel->isOnCurrentDesktop())
if (!toplevel->isOnCurrentDesktop()) {
disable_painting |= PAINT_DISABLED_BY_DESKTOP;
}
}
if (!toplevel->isOnCurrentActivity())
if (!toplevel->isOnCurrentActivity()) {
disable_painting |= PAINT_DISABLED_BY_ACTIVITY;
}
if (AbstractClient *c = dynamic_cast<AbstractClient *>(toplevel)) {
if (c->isMinimized())
if (c->isMinimized()) {
disable_painting |= PAINT_DISABLED_BY_MINIMIZE;
}
if (c->isHiddenInternal()) {
disable_painting |= PAINT_DISABLED;
}

View File

@ -46,27 +46,32 @@ LanczosFilter::~LanczosFilter()
void LanczosFilter::init()
{
if (m_inited)
if (m_inited) {
return;
}
m_inited = true;
const bool force = (qstrcmp(qgetenv("KWIN_FORCE_LANCZOS"), "1") == 0);
if (force) {
qCWarning(KWIN_OPENGL) << "Lanczos Filter forced on by environment variable";
}
if (!force && options->glSmoothScale() != 2)
if (!force && options->glSmoothScale() != 2) {
return; // disabled by config
if (!GLRenderTarget::supported())
}
if (!GLRenderTarget::supported()) {
return;
}
GLPlatform *gl = GLPlatform::instance();
if (!force) {
// The lanczos filter is reported to be broken with the Intel driver prior SandyBridge
if (gl->driver() == Driver_Intel && gl->chipClass() < SandyBridge)
if (gl->driver() == Driver_Intel && gl->chipClass() < SandyBridge) {
return;
}
// also radeon before R600 has trouble
if (gl->isRadeon() && gl->chipClass() < R600)
if (gl->isRadeon() && gl->chipClass() < R600) {
return;
}
// and also for software emulation (e.g. llvmpipe)
if (gl->isSoftwareEmulation()) {
return;
@ -109,11 +114,13 @@ static float sinc(float x)
static float lanczos(float x, float a)
{
if (qFuzzyCompare(x + 1.0, 1.0))
if (qFuzzyCompare(x + 1.0, 1.0)) {
return 1.0;
}
if (qAbs(x) >= a)
if (qAbs(x) >= a) {
return 0.0;
}
return sinc(x) * sinc(x / a);
}
@ -160,8 +167,9 @@ void LanczosFilter::createOffsets(int count, float width, Qt::Orientation direct
void LanczosFilter::performPaint(EffectWindowImpl *w, int mask, QRegion region, WindowPaintData &data)
{
if (data.xScale() < 0.9 || data.yScale() < 0.9) {
if (!m_inited)
if (!m_inited) {
init();
}
const QRect screenRect = Workspace::self()->clientArea(ScreenArea, w->window());
// window geometry may not be bigger than screen geometry to fit into the FBO
QRect winGeo(w->expandedGeometry());

View File

@ -108,15 +108,17 @@ QMatrix4x4 SceneOpenGL::transformation(int mask, const ScreenPaintData &data) co
{
QMatrix4x4 matrix;
if (!(mask & PAINT_SCREEN_TRANSFORMED))
if (!(mask & PAINT_SCREEN_TRANSFORMED)) {
return matrix;
}
matrix.translate(data.translation());
const QVector3D scale = data.scale();
matrix.scale(scale.x(), scale.y(), scale.z());
if (data.rotationAngle() == 0.0)
if (data.rotationAngle() == 0.0) {
return matrix;
}
// Apply the rotation
// cannot use data.rotation->applyTo(&matrix) as QGraphicsRotation uses projectedRotate to map back to 2D
@ -323,8 +325,9 @@ void SceneOpenGL::performPaintWindow(EffectWindowImpl *w, int mask, const QRegio
m_lanczosFilter = new LanczosFilter(this);
}
m_lanczosFilter->performPaint(w, mask, region, data);
} else
} else {
w->sceneWindow()->performPaint(mask, region, data);
}
}
//****************************************
@ -351,10 +354,11 @@ QVector4D OpenGLWindow::modulate(float opacity, float brightness) const
void OpenGLWindow::setBlendEnabled(bool enabled)
{
if (enabled && !m_blendingEnabled)
if (enabled && !m_blendingEnabled) {
glEnable(GL_BLEND);
else if (!enabled && m_blendingEnabled)
} else if (!enabled && m_blendingEnabled) {
glDisable(GL_BLEND);
}
m_blendingEnabled = enabled;
}
@ -505,14 +509,16 @@ QMatrix4x4 OpenGLWindow::modelViewProjectionMatrix(int mask, const WindowPaintDa
// the same dimensions as the default framebuffer.
//
// Note that the screen transformation is not applied here.
if (!pMatrix.isIdentity())
if (!pMatrix.isIdentity()) {
return pMatrix * mvMatrix;
}
// If an effect has specified a model-view matrix, we multiply that matrix
// with the default projection matrix. If the effect hasn't specified a
// model-view matrix, mvMatrix will be the identity matrix.
if (mask & Scene::PAINT_SCREEN_TRANSFORMED)
if (mask & Scene::PAINT_SCREEN_TRANSFORMED) {
return m_scene->screenProjectionMatrix() * mvMatrix;
}
return m_scene->renderTargetProjectionMatrix() * mvMatrix;
}
@ -574,11 +580,13 @@ void OpenGLWindow::performPaint(int mask, const QRegion &region, const WindowPai
if (!shader) {
ShaderTraits traits = ShaderTrait::MapTexture;
if (data.opacity() != 1.0 || data.brightness() != 1.0 || data.crossFadeProgress() != 1.0)
if (data.opacity() != 1.0 || data.brightness() != 1.0 || data.crossFadeProgress() != 1.0) {
traits |= ShaderTrait::Modulate;
}
if (data.saturation() != 1.0)
if (data.saturation() != 1.0) {
traits |= ShaderTrait::AdjustSaturation;
}
shader = ShaderManager::instance()->pushShader(traits);
}
@ -606,8 +614,9 @@ void OpenGLWindow::performPaint(int mask, const QRegion &region, const WindowPai
for (int i = 0, v = 0; i < renderContext.renderNodes.count(); i++) {
RenderNode &renderNode = renderContext.renderNodes[i];
if (renderNode.quads.isEmpty() || !renderNode.texture)
if (renderNode.quads.isEmpty() || !renderNode.texture) {
continue;
}
renderNode.firstVertex = v;
renderNode.vertexCount = renderNode.quads.count() * verticesPerQuad;
@ -635,8 +644,9 @@ void OpenGLWindow::performPaint(int mask, const QRegion &region, const WindowPai
const QMatrix4x4 modelViewProjection = modelViewProjectionMatrix(mask, data);
for (int i = 0; i < renderContext.renderNodes.count(); i++) {
const RenderNode &renderNode = renderContext.renderNodes[i];
if (renderNode.vertexCount == 0)
if (renderNode.vertexCount == 0) {
continue;
}
setBlendEnabled(renderNode.hasAlpha || renderNode.opacity < 1.0);
@ -660,8 +670,9 @@ void OpenGLWindow::performPaint(int mask, const QRegion &region, const WindowPai
setBlendEnabled(false);
if (!data.shader)
if (!data.shader) {
ShaderManager::instance()->popShader();
}
if (renderContext.hardwareClipping) {
glDisable(GL_SCISSOR_TEST);
@ -758,8 +769,9 @@ void SceneOpenGL::EffectFrame::crossFadeText()
void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, double frameOpacity)
{
if (m_effectFrame->geometry().isEmpty())
if (m_effectFrame->geometry().isEmpty()) {
return; // Nothing to display
}
Q_UNUSED(_region); // TODO: Old region doesn't seem to work with OpenGL
@ -906,8 +918,9 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do
m_unstyledVBO->render(GL_TRIANGLES);
m_unstyledTexture->unbind();
} else if (m_effectFrame->style() == EffectFrameStyled) {
if (!m_texture) // Lazy creation
if (!m_texture) { // Lazy creation
updateTexture();
}
if (shader) {
const float a = opacity * frameOpacity;
@ -928,8 +941,9 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do
if (!m_effectFrame->selection().isNull()) {
if (!m_selectionTexture) { // Lazy creation
QPixmap pixmap = m_effectFrame->selectionFrame().framePixmap();
if (!pixmap.isNull())
if (!pixmap.isNull()) {
m_selectionTexture = new GLTexture(pixmap);
}
}
if (m_selectionTexture) {
if (shader) {
@ -1008,8 +1022,9 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do
shader->setUniform(GLShader::ModulationConstant, constant);
}
}
if (!m_textTexture) // Lazy creation
if (!m_textTexture) { // Lazy creation
updateTextTexture();
}
if (m_textTexture) {
m_textTexture->bind();
@ -1041,13 +1056,15 @@ void SceneOpenGL::EffectFrame::updateTextTexture()
delete m_textPixmap;
m_textPixmap = nullptr;
if (m_effectFrame->text().isEmpty())
if (m_effectFrame->text().isEmpty()) {
return;
}
// Determine position on texture to paint text
QRect rect(QPoint(0, 0), m_effectFrame->geometry().size());
if (!m_effectFrame->icon().isNull() && !m_effectFrame->iconSize().isEmpty())
if (!m_effectFrame->icon().isNull() && !m_effectFrame->iconSize().isEmpty()) {
rect.setLeft(m_effectFrame->iconSize().width());
}
// If static size elide text as required
QString text = m_effectFrame->text();
@ -1060,10 +1077,11 @@ void SceneOpenGL::EffectFrame::updateTextTexture()
m_textPixmap->fill(Qt::transparent);
QPainter p(m_textPixmap);
p.setFont(m_effectFrame->font());
if (m_effectFrame->style() == EffectFrameStyled)
if (m_effectFrame->style() == EffectFrameStyled) {
p.setPen(m_effectFrame->styledTextColor());
else // TODO: What about no frame? Custom color setting required
} else { // TODO: What about no frame? Custom color setting required
p.setPen(Qt::white);
}
p.drawText(rect, m_effectFrame->alignment(), text);
p.end();
m_textTexture = new GLTexture(*m_textPixmap);
@ -1245,8 +1263,9 @@ bool SceneOpenGLShadow::prepareBackend()
uint8_t *const dst = reinterpret_cast<uint8_t *>(alphaImage.scanLine(y));
for (ptrdiff_t x = 0; x < image.width(); x++) {
if (src[x] & 0x00ffffff)
if (src[x] & 0x00ffffff) {
alphaOnly = false;
}
dst[x] = qAlpha(src[x]);
}
@ -1460,8 +1479,9 @@ void SceneOpenGLDecorationRenderer::resizeTexture()
size.rwidth() += 2 * TexturePad;
size.rwidth() = align(size.width(), 128);
if (m_texture && m_texture->size() == size)
if (m_texture && m_texture->size() == size) {
return;
}
if (!size.isEmpty()) {
m_texture.reset(new GLTexture(GL_RGBA8, size.width(), size.height()));

View File

@ -137,11 +137,13 @@ void SceneQPainter::Window::performPaint(int mask, const QRegion &_region, const
QRegion region = _region;
const QRect boundingRect = windowItem()->mapToGlobal(windowItem()->boundingRect());
if (!(mask & (PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED)))
if (!(mask & (PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED))) {
region &= boundingRect;
}
if (region.isEmpty())
if (region.isEmpty()) {
return;
}
QPainter *scenePainter = m_scene->scenePainter();
QPainter *painter = scenePainter;

View File

@ -502,8 +502,9 @@ void Edge::switchDesktop(const QPoint &cursorPos)
void Edge::pushCursorBack(const QPoint &cursorPos)
{
if (m_pushBackBlocked)
if (m_pushBackBlocked) {
return;
}
int x = cursorPos.x();
int y = cursorPos.y();
const QSize &distance = edges()->cursorPushBackDistance();
@ -1261,8 +1262,9 @@ ElectricBorderAction ScreenEdges::actionForTouchEdge(Edge *edge) const
void ScreenEdges::reserveDesktopSwitching(bool isToReserve, Qt::Orientations o)
{
if (!o)
if (!o) {
return;
}
for (auto it = m_edges.begin(); it != m_edges.end(); ++it) {
Edge *edge = *it;
if (edge->isCorner()) {
@ -1313,8 +1315,9 @@ void ScreenEdges::reserve(AbstractClient *client, ElectricBorder border)
if (border != ElectricNone) {
createEdgeForClient(client, border);
} else {
if (hadBorder) // show again
if (hadBorder) { // show again
client->showOnScreenEdge();
}
}
}

View File

@ -428,10 +428,11 @@ quint64 ScriptedEffect::animate(KWin::EffectWindow *window, KWin::AnimationEffec
int delay, bool fullScreen, bool keepAlive)
{
QEasingCurve qec;
if (curve < QEasingCurve::Custom)
if (curve < QEasingCurve::Custom) {
qec.setType(static_cast<QEasingCurve::Type>(curve));
else if (curve == GaussianCurve)
} else if (curve == GaussianCurve) {
qec.setCustomType(qecGaussian);
}
return AnimationEffect::animate(window, attribute, metaData, ms, fpx2FromScriptValue(to), qec,
delay, fpx2FromScriptValue(from), fullScreen, keepAlive);
}
@ -446,10 +447,11 @@ quint64 ScriptedEffect::set(KWin::EffectWindow *window, KWin::AnimationEffect::A
int delay, bool fullScreen, bool keepAlive)
{
QEasingCurve qec;
if (curve < QEasingCurve::Custom)
if (curve < QEasingCurve::Custom) {
qec.setType(static_cast<QEasingCurve::Type>(curve));
else if (curve == GaussianCurve)
} else if (curve == GaussianCurve) {
qec.setCustomType(qecGaussian);
}
return AnimationEffect::set(window, attribute, metaData, ms, fpx2FromScriptValue(to), qec,
delay, fpx2FromScriptValue(from), fullScreen, keepAlive);
}

View File

@ -308,8 +308,9 @@ void WorkspaceWrapper::setupClientConnections(AbstractClient *client)
this, &WorkspaceWrapper::clientMaximizeSet);
X11Client *x11Client = qobject_cast<X11Client *>(client); // TODO: Drop X11-specific signals.
if (!x11Client)
if (!x11Client) {
return;
}
connect(x11Client, &X11Client::clientManaging, this, &WorkspaceWrapper::clientManaging);
connect(x11Client, &X11Client::clientFullScreenSet, this, &WorkspaceWrapper::clientFullScreenSet);

View File

@ -52,10 +52,12 @@ static const char *const window_type_names[] = {
static const char *windowTypeToTxt(NET::WindowType type)
{
if (type >= NET::Unknown && type <= NET::Splash)
if (type >= NET::Unknown && type <= NET::Splash) {
return window_type_names[type + 1]; // +1 (unknown==-1)
if (type == -2) // undefined (not really part of NET::WindowType)
}
if (type == -2) { // undefined (not really part of NET::WindowType)
return "Undefined";
}
qFatal("Unknown Window Type");
return nullptr;
}
@ -64,9 +66,11 @@ static NET::WindowType txtToWindowType(const char *txt)
{
for (int i = NET::Unknown;
i <= NET::Splash;
++i)
if (qstrcmp(txt, window_type_names[i + 1]) == 0) // +1
++i) {
if (qstrcmp(txt, window_type_names[i + 1]) == 0) { // +1
return static_cast<NET::WindowType>(i);
}
}
return static_cast<NET::WindowType>(-2); // undefined
}
@ -93,16 +97,20 @@ void Workspace::storeSession(const QString &sessionName, SMSavePhase phase)
}
QByteArray sessionId = c->sessionId();
QByteArray wmCommand = c->wmCommand();
if (sessionId.isEmpty())
if (sessionId.isEmpty()) {
// remember also applications that are not XSMP capable
// and use the obsolete WM_COMMAND / WM_SAVE_YOURSELF
if (wmCommand.isEmpty())
if (wmCommand.isEmpty()) {
continue;
}
}
count++;
if (c->isActive())
if (c->isActive()) {
active_client = count;
if (phase == SMSavePhase2 || phase == SMSavePhase2Full)
}
if (phase == SMSavePhase2 || phase == SMSavePhase2Full) {
storeClient(cg, count, c);
}
}
if (phase == SMSavePhase0) {
// it would be much simpler to save these values to the config file,
@ -171,18 +179,22 @@ void Workspace::storeSubSession(const QString &name, QSet<QByteArray> sessionIds
}
QByteArray sessionId = c->sessionId();
QByteArray wmCommand = c->wmCommand();
if (sessionId.isEmpty())
if (sessionId.isEmpty()) {
// remember also applications that are not XSMP capable
// and use the obsolete WM_COMMAND / WM_SAVE_YOURSELF
if (wmCommand.isEmpty())
if (wmCommand.isEmpty()) {
continue;
if (!sessionIds.contains(sessionId))
}
}
if (!sessionIds.contains(sessionId)) {
continue;
}
qCDebug(KWIN_CORE) << "storing" << sessionId;
count++;
if (c->isActive())
if (c->isActive()) {
active_client = count;
}
storeClient(cg, count, c);
}
cg.writeEntry("count", count);
@ -277,8 +289,9 @@ SessionInfo *Workspace::takeSessionInfo(X11Client *c)
if (!sessionId.isEmpty()) {
// look for a real session managed client (algorithm suggested by ICCCM)
for (SessionInfo *info : qAsConst(session)) {
if (realInfo)
if (realInfo) {
break;
}
if (info->sessionId == sessionId && sessionInfoWindowTypeMatch(c, info)) {
if (!windowRole.isEmpty()) {
if (info->windowRole == windowRole) {
@ -298,8 +311,9 @@ SessionInfo *Workspace::takeSessionInfo(X11Client *c)
} else {
// look for a sessioninfo with matching features.
for (SessionInfo *info : qAsConst(session)) {
if (realInfo)
if (realInfo) {
break;
}
if (info->resourceName == resourceName
&& info->resourceClass == resourceClass
&& sessionInfoWindowTypeMatch(c, info)) {

View File

@ -35,16 +35,18 @@ ClientModel::~ClientModel()
QVariant ClientModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
if (!index.isValid()) {
return QVariant();
}
if (m_clientList.isEmpty()) {
return QVariant();
}
int clientIndex = index.row();
if (clientIndex >= m_clientList.count())
if (clientIndex >= m_clientList.count()) {
return QVariant();
}
QSharedPointer<TabBoxClient> client = m_clientList[clientIndex].toStrongRef();
if (!client) {
return QVariant();
@ -118,8 +120,9 @@ QModelIndex ClientModel::index(int row, int column, const QModelIndex &parent) c
return QModelIndex();
}
int index = row * columnCount();
if (index >= m_clientList.count() && !m_clientList.isEmpty())
if (index >= m_clientList.count() && !m_clientList.isEmpty()) {
return QModelIndex();
}
return createIndex(row, 0);
}
@ -137,8 +140,9 @@ QHash<int, QByteArray> ClientModel::roleNames() const
QModelIndex ClientModel::index(QWeakPointer<TabBoxClient> client) const
{
if (!m_clientList.contains(client))
if (!m_clientList.contains(client)) {
return QModelIndex();
}
int index = m_clientList.indexOf(client);
int row = index / columnCount();
int column = index % columnCount();
@ -199,8 +203,9 @@ void ClientModel::createClientList(int desktop, bool partialReset)
if (start == add.data()) {
m_clientList.removeAll(add);
m_clientList.prepend(add);
} else
} else {
m_clientList += add;
}
if (add.data()->isFirstInTabBox()) {
stickyClients << add;
}
@ -211,8 +216,9 @@ void ClientModel::createClientList(int desktop, bool partialReset)
c = stacking[++index];
}
if (c == stop)
if (c == stop) {
break;
}
}
break;
}
@ -224,8 +230,9 @@ void ClientModel::createClientList(int desktop, bool partialReset)
if (tabBox->config().clientApplicationsMode() != TabBoxConfig::AllWindowsCurrentApplication
&& (tabBox->config().showDesktopMode() == TabBoxConfig::ShowDesktopClient || m_clientList.isEmpty())) {
QWeakPointer<TabBoxClient> desktopClient = tabBox->desktopClient();
if (!desktopClient.isNull())
if (!desktopClient.isNull()) {
m_clientList.append(desktopClient);
}
}
endResetModel();
}

View File

@ -31,8 +31,9 @@ DesktopModel::~DesktopModel()
QVariant DesktopModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.column() != 0)
if (!index.isValid() || index.column() != 0) {
return QVariant();
}
if (index.parent().isValid()) {
// parent is valid -> access to Client
@ -41,8 +42,9 @@ QVariant DesktopModel::data(const QModelIndex &index, int role) const
}
const int desktopIndex = index.row();
if (desktopIndex >= m_desktopList.count())
if (desktopIndex >= m_desktopList.count()) {
return QVariant();
}
switch (role) {
case Qt::DisplayRole:
case DesktopNameRole:
@ -118,8 +120,9 @@ QModelIndex DesktopModel::index(int row, int column, const QModelIndex &parent)
}
return createIndex(row, column, parent.row() + 1);
}
if (row > m_desktopList.count() || m_desktopList.isEmpty())
if (row > m_desktopList.count() || m_desktopList.isEmpty()) {
return QModelIndex();
}
return createIndex(row, column);
}
@ -135,8 +138,9 @@ QHash<int, QByteArray> DesktopModel::roleNames() const
QModelIndex DesktopModel::desktopIndex(int desktop) const
{
if (desktop > m_desktopList.count())
if (desktop > m_desktopList.count()) {
return QModelIndex();
}
return createIndex(m_desktopList.indexOf(desktop), 0);
}

View File

@ -63,8 +63,9 @@ void SwitcherItem::setVisible(bool visible)
if (m_visible == visible) {
return;
}
if (visible)
if (visible) {
Q_EMIT screenGeometryChanged();
}
m_visible = visible;
Q_EMIT visibleChanged();
}

View File

@ -94,8 +94,9 @@ int TabBoxHandlerImpl::currentDesktop() const
QString TabBoxHandlerImpl::desktopName(TabBoxClient *client) const
{
if (TabBoxClientImpl *c = static_cast<TabBoxClientImpl *>(client)) {
if (!c->client()->isOnAllDesktops())
if (!c->client()->isOnAllDesktops()) {
return desktopName(c->client()->desktop());
}
}
return desktopName(VirtualDesktopManager::self()->current());
}
@ -110,8 +111,9 @@ QWeakPointer<TabBoxClient> TabBoxHandlerImpl::nextClientFocusChain(TabBoxClient
{
if (TabBoxClientImpl *c = static_cast<TabBoxClientImpl *>(client)) {
auto next = FocusChain::self()->nextMostRecentlyUsed(c->client());
if (next)
if (next) {
return qWeakPointerCast<TabBoxClient, TabBoxClientImpl>(next->tabBoxClient());
}
}
return QWeakPointer<TabBoxClient>();
}
@ -145,10 +147,11 @@ int TabBoxHandlerImpl::numberOfDesktops() const
QWeakPointer<TabBoxClient> TabBoxHandlerImpl::activeClient() const
{
if (Workspace::self()->activeClient())
if (Workspace::self()->activeClient()) {
return qWeakPointerCast<TabBoxClient, TabBoxClientImpl>(Workspace::self()->activeClient()->tabBoxClient());
else
} else {
return QWeakPointer<TabBoxClient>();
}
}
bool TabBoxHandlerImpl::checkDesktop(TabBoxClient *client, int desktop) const
@ -260,18 +263,19 @@ QWeakPointer<TabBoxClient> TabBoxHandlerImpl::clientToAddToList(TabBoxClient *cl
if (addClient) {
// don't add windows that have modal dialogs
AbstractClient *modal = current->findModal();
if (modal == nullptr || modal == current)
if (modal == nullptr || modal == current) {
ret = current;
else if (!clientList().contains(qWeakPointerCast<TabBoxClient, TabBoxClientImpl>(modal->tabBoxClient())))
} else if (!clientList().contains(qWeakPointerCast<TabBoxClient, TabBoxClientImpl>(modal->tabBoxClient()))) {
ret = modal;
else {
} else {
// nothing
}
}
if (ret)
if (ret) {
return qWeakPointerCast<TabBoxClient, TabBoxClientImpl>(ret->tabBoxClient());
else
} else {
return QWeakPointer<TabBoxClient>();
}
}
TabBoxClientList TabBoxHandlerImpl::stackingOrder() const
@ -306,18 +310,20 @@ void TabBoxHandlerImpl::elevateClient(TabBoxClient *c, QWindow *tabbox, bool b)
{
auto cl = static_cast<TabBoxClientImpl *>(c)->client();
cl->elevate(b);
if (Toplevel *w = Workspace::self()->findInternal(tabbox))
if (Toplevel *w = Workspace::self()->findInternal(tabbox)) {
w->elevate(b);
}
}
void TabBoxHandlerImpl::shadeClient(TabBoxClient *c, bool b) const
{
AbstractClient *client = static_cast<TabBoxClientImpl *>(c)->client();
client->cancelShadeHoverTimer(); // stop core shading action
if (!b && client->shadeMode() == ShadeNormal)
if (!b && client->shadeMode() == ShadeNormal) {
client->setShade(ShadeHover);
else if (b && client->shadeMode() == ShadeHover)
} else if (b && client->shadeMode() == ShadeHover) {
client->setShade(ShadeNormal);
}
}
QWeakPointer<TabBoxClient> TabBoxHandlerImpl::desktopClient() const
@ -373,9 +379,10 @@ TabBoxClientImpl::~TabBoxClientImpl()
QString TabBoxClientImpl::caption() const
{
if (m_client->isDesktop())
if (m_client->isDesktop()) {
return i18nc("Special entry in alt+tab list for minimizing all windows",
"Show Desktop");
}
return m_client->caption();
}
@ -615,22 +622,26 @@ void TabBox::reset(bool partial_reset)
case TabBoxConfig::ClientTabBox:
m_tabBox->createModel(partial_reset);
if (!partial_reset) {
if (Workspace::self()->activeClient())
if (Workspace::self()->activeClient()) {
setCurrentClient(Workspace::self()->activeClient());
}
// it's possible that the active client is not part of the model
// in that case the index is invalid
if (!m_tabBox->currentIndex().isValid())
if (!m_tabBox->currentIndex().isValid()) {
setCurrentIndex(m_tabBox->first());
}
} else {
if (!m_tabBox->currentIndex().isValid() || !m_tabBox->client(m_tabBox->currentIndex()))
if (!m_tabBox->currentIndex().isValid() || !m_tabBox->client(m_tabBox->currentIndex())) {
setCurrentIndex(m_tabBox->first());
}
}
break;
case TabBoxConfig::DesktopTabBox:
m_tabBox->createModel();
if (!partial_reset)
if (!partial_reset) {
setCurrentDesktop(VirtualDesktopManager::self()->current());
}
break;
}
@ -646,11 +657,13 @@ void TabBox::nextPrev(bool next)
AbstractClient *TabBox::currentClient()
{
if (TabBoxClientImpl *client = static_cast<TabBoxClientImpl *>(m_tabBox->client(m_tabBox->currentIndex()))) {
if (!Workspace::self()->hasClient(client->client()))
if (!Workspace::self()->hasClient(client->client())) {
return nullptr;
}
return client->client();
} else
} else {
return nullptr;
}
}
QList<AbstractClient *> TabBox::currentClientList()
@ -659,10 +672,12 @@ QList<AbstractClient *> TabBox::currentClientList()
QList<AbstractClient *> ret;
for (const QWeakPointer<TabBoxClient> &clientPointer : list) {
QSharedPointer<TabBoxClient> client = clientPointer.toStrongRef();
if (!client)
if (!client) {
continue;
if (const TabBoxClientImpl *c = static_cast<const TabBoxClientImpl *>(client.data()))
}
if (const TabBoxClientImpl *c = static_cast<const TabBoxClientImpl *>(client.data())) {
ret.append(c->client());
}
}
return ret;
}
@ -689,8 +704,9 @@ void TabBox::setCurrentDesktop(int newDesktop)
void TabBox::setCurrentIndex(QModelIndex index, bool notifyEffects)
{
if (!index.isValid())
if (!index.isValid()) {
return;
}
m_tabBox->setCurrentIndex(index);
if (notifyEffects) {
Q_EMIT tabBoxUpdated();
@ -718,8 +734,9 @@ void TabBox::hide(bool abort)
unreference();
}
Q_EMIT tabBoxClosed();
if (isDisplayed())
if (isDisplayed()) {
qCDebug(KWIN_TABBOX) << "Tab box was not properly closed by an effect";
}
m_tabBox->hide(abort);
if (kwinApp()->x11Connection()) {
Xcb::sync();
@ -759,8 +776,9 @@ void TabBox::reconfigure()
for (const QString &s : qAsConst(list)) {
bool ok;
const int i = s.toInt(&ok);
if (!ok)
if (!ok) {
continue;
}
borders->append(ElectricBorder(i));
ScreenEdges::self()->reserve(ElectricBorder(i), this, "toggle");
}
@ -819,9 +837,10 @@ void TabBox::loadConfig(const KConfigGroup &config, TabBoxConfig &tabBoxConfig)
void TabBox::delayedShow()
{
if (isDisplayed() || m_delayedShowTimer.isActive())
if (isDisplayed() || m_delayedShowTimer.isActive()) {
// already called show - no need to call it twice
return;
}
if (!m_delayShowTime) {
show();
@ -1003,8 +1022,9 @@ static bool areModKeysDepressedWayland(const QKeySequence &seq)
static bool areModKeysDepressed(const QKeySequence &seq)
{
if (seq.isEmpty())
if (seq.isEmpty()) {
return false;
}
if (kwinApp()->shouldUseWaylandForCompositing()) {
return areModKeysDepressedWayland(seq);
} else {
@ -1023,16 +1043,19 @@ void TabBox::navigatingThroughWindows(bool forward, const QKeySequence &shortcut
CDEWalkThroughWindows(forward);
} else {
workspace()->forEachAbstractClient([](Toplevel *toplevel) {
if (toplevel->isPopupWindow())
if (toplevel->isPopupWindow()) {
toplevel->popupDone();
}
});
if (areModKeysDepressed(shortcut)) {
if (startKDEWalkThroughWindows(mode))
if (startKDEWalkThroughWindows(mode)) {
KDEWalkThroughWindows(forward);
} else
}
} else {
// if the shortcut has no modifiers, don't show the tabbox,
// don't grab, but simply go to the next window
KDEOneStepThroughWindows(forward, mode);
}
}
}
@ -1082,8 +1105,9 @@ void TabBox::slotWalkThroughDesktops()
return;
}
if (areModKeysDepressed(m_cutWalkThroughDesktops)) {
if (startWalkThroughDesktops())
if (startWalkThroughDesktops()) {
walkThroughDesktops(true);
}
} else {
oneStepThroughDesktops(true);
}
@ -1095,8 +1119,9 @@ void TabBox::slotWalkBackThroughDesktops()
return;
}
if (areModKeysDepressed(m_cutWalkThroughDesktopsReverse)) {
if (startWalkThroughDesktops())
if (startWalkThroughDesktops()) {
walkThroughDesktops(false);
}
} else {
oneStepThroughDesktops(false);
}
@ -1108,8 +1133,9 @@ void TabBox::slotWalkThroughDesktopList()
return;
}
if (areModKeysDepressed(m_cutWalkThroughDesktopList)) {
if (startWalkThroughDesktopList())
if (startWalkThroughDesktopList()) {
walkThroughDesktops(true);
}
} else {
oneStepThroughDesktopList(true);
}
@ -1121,8 +1147,9 @@ void TabBox::slotWalkBackThroughDesktopList()
return;
}
if (areModKeysDepressed(m_cutWalkThroughDesktopListReverse)) {
if (startWalkThroughDesktopList())
if (startWalkThroughDesktopList()) {
walkThroughDesktops(false);
}
} else {
oneStepThroughDesktopList(false);
}
@ -1130,8 +1157,9 @@ void TabBox::slotWalkBackThroughDesktopList()
void TabBox::shadeActivate(AbstractClient *c)
{
if ((c->shadeMode() == ShadeNormal || c->shadeMode() == ShadeHover) && options->isShadeHover())
if ((c->shadeMode() == ShadeNormal || c->shadeMode() == ShadeHover) && options->isShadeHover()) {
c->setShade(ShadeActivated);
}
}
bool TabBox::toggle(ElectricBorder eb)
@ -1145,14 +1173,16 @@ bool TabBox::toggle(ElectricBorder eb)
bool TabBox::toggleMode(TabBoxMode mode)
{
if (!options->focusPolicyIsReasonable())
if (!options->focusPolicyIsReasonable()) {
return false; // not supported.
}
if (isDisplayed()) {
accept();
return true;
}
if (!establishTabBoxGrab())
if (!establishTabBoxGrab()) {
return false;
}
m_noModifierGrab = m_tabGrab = true;
setMode(mode);
reset();
@ -1162,8 +1192,9 @@ bool TabBox::toggleMode(TabBoxMode mode)
bool TabBox::startKDEWalkThroughWindows(TabBoxMode mode)
{
if (!establishTabBoxGrab())
if (!establishTabBoxGrab()) {
return false;
}
m_tabGrab = true;
m_noModifierGrab = false;
setMode(mode);
@ -1173,8 +1204,9 @@ bool TabBox::startKDEWalkThroughWindows(TabBoxMode mode)
bool TabBox::startWalkThroughDesktops(TabBoxMode mode)
{
if (!establishTabBoxGrab())
if (!establishTabBoxGrab()) {
return false;
}
m_desktopGrab = true;
m_noModifierGrab = false;
setMode(mode);
@ -1243,14 +1275,16 @@ void TabBox::CDEWalkThroughWindows(bool forward)
}
} while (nc && nc != c && ((!options_traverse_all && !nc->isOnDesktop(currentDesktop())) || nc->isMinimized() || !nc->wantsTabFocus() || nc->keepAbove() || nc->keepBelow() || !nc->isOnCurrentActivity()));
if (nc) {
if (c && c != nc)
if (c && c != nc) {
Workspace::self()->lowerClient(c);
}
if (options->focusPolicyIsReasonable()) {
Workspace::self()->activateClient(nc);
shadeActivate(nc);
} else {
if (!nc->isOnDesktop(currentDesktop()))
if (!nc->isOnDesktop(currentDesktop())) {
setCurrentDesktop(nc->desktop());
}
Workspace::self()->raiseClient(nc);
}
}
@ -1272,8 +1306,9 @@ void TabBox::oneStepThroughDesktops(bool forward, TabBoxMode mode)
setMode(mode);
reset();
nextPrev(forward);
if (currentDesktop() != -1)
if (currentDesktop() != -1) {
setCurrentDesktop(currentDesktop());
}
}
void TabBox::oneStepThroughDesktops(bool forward)
@ -1306,30 +1341,37 @@ void TabBox::keyPress(int keyQt)
// tests whether a shortcut matches and handles pitfalls on ShiftKey invocation
auto directionFor = [keyQt, contains](const QKeySequence &forward, const QKeySequence &backward) -> Direction {
if (contains(forward, keyQt))
if (contains(forward, keyQt)) {
return Forward;
if (contains(backward, keyQt))
}
if (contains(backward, keyQt)) {
return Backward;
if (!(keyQt & Qt::ShiftModifier))
}
if (!(keyQt & Qt::ShiftModifier)) {
return Steady;
}
// Before testing the unshifted key (Ctrl+A vs. Ctrl+Shift+a etc.), see whether this is +Shift+Tab
// and check that against +Shift+Backtab (as well)
Qt::KeyboardModifiers mods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier;
mods &= keyQt;
if ((keyQt & ~mods) == Qt::Key_Tab) {
if (contains(forward, mods | Qt::Key_Backtab))
if (contains(forward, mods | Qt::Key_Backtab)) {
return Forward;
if (contains(backward, mods | Qt::Key_Backtab))
}
if (contains(backward, mods | Qt::Key_Backtab)) {
return Backward;
}
}
// if the shortcuts do not match, try matching again after filtering the shift key from keyQt
// it is needed to handle correctly the ALT+~ shorcut for example as it is coded as ALT+SHIFT+~ in keyQt
if (contains(forward, keyQt & ~Qt::ShiftModifier))
if (contains(forward, keyQt & ~Qt::ShiftModifier)) {
return Forward;
if (contains(backward, keyQt & ~Qt::ShiftModifier))
}
if (contains(backward, keyQt & ~Qt::ShiftModifier)) {
return Backward;
}
return Steady;
};
@ -1382,10 +1424,12 @@ void TabBox::keyPress(int keyQt)
}
} else if (m_desktopGrab) {
direction = directionFor(m_cutWalkThroughDesktops, m_cutWalkThroughDesktopsReverse);
if (direction == Steady)
if (direction == Steady) {
direction = directionFor(m_cutWalkThroughDesktopList, m_cutWalkThroughDesktopListReverse);
if (direction != Steady)
}
if (direction != Steady) {
walkThroughDesktops(direction == Forward);
}
}
if (m_desktopGrab || m_tabGrab) {
@ -1414,13 +1458,15 @@ void TabBox::close(bool abort)
void TabBox::accept(bool closeTabBox)
{
AbstractClient *c = currentClient();
if (closeTabBox)
if (closeTabBox) {
close();
}
if (c) {
Workspace::self()->activateClient(c);
shadeActivate(c);
if (c->isDesktop())
if (c->isDesktop()) {
Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop());
}
}
}
@ -1465,14 +1511,17 @@ int TabBox::previousDesktopStatic(int iDesktop) const
AbstractClient *TabBox::nextClientStatic(AbstractClient *c) const
{
const auto &list = Workspace::self()->allClientList();
if (!c || list.isEmpty())
if (!c || list.isEmpty()) {
return nullptr;
}
int pos = list.indexOf(c);
if (pos == -1)
if (pos == -1) {
return list.first();
}
++pos;
if (pos == list.count())
if (pos == list.count()) {
return list.first();
}
return list.at(pos);
}
@ -1483,13 +1532,16 @@ AbstractClient *TabBox::nextClientStatic(AbstractClient *c) const
AbstractClient *TabBox::previousClientStatic(AbstractClient *c) const
{
const auto &list = Workspace::self()->allClientList();
if (!c || list.isEmpty())
if (!c || list.isEmpty()) {
return nullptr;
}
int pos = list.indexOf(c);
if (pos == -1)
if (pos == -1) {
return list.last();
if (pos == 0)
}
if (pos == 0) {
return list.last();
}
--pos;
return list.at(pos);
}
@ -1501,8 +1553,9 @@ bool TabBox::establishTabBoxGrab()
return true;
}
updateXTime();
if (!grabXKeyboard())
if (!grabXKeyboard()) {
return false;
}
// Don't try to establish a global mouse grab using XGrabPointer, as that would prevent
// using Alt+Tab while DND (#44972). However force passive grabs on all windows
// in order to catch MouseRelease events and close the tabbox (#67416).
@ -1510,8 +1563,9 @@ bool TabBox::establishTabBoxGrab()
// the active client, which may not have it.
Q_ASSERT(!m_forcedGlobalMouseGrab);
m_forcedGlobalMouseGrab = true;
if (Workspace::self()->activeClient() != nullptr)
if (Workspace::self()->activeClient() != nullptr) {
Workspace::self()->activeClient()->updateMouseGrab();
}
m_x11EventFilter.reset(new X11Filter);
return true;
}
@ -1526,8 +1580,9 @@ void TabBox::removeTabBoxGrab()
ungrabXKeyboard();
Q_ASSERT(m_forcedGlobalMouseGrab);
m_forcedGlobalMouseGrab = false;
if (Workspace::self()->activeClient() != nullptr)
if (Workspace::self()->activeClient() != nullptr) {
Workspace::self()->activeClient()->updateMouseGrab();
}
m_x11EventFilter.reset();
}
} // namespace TabBox

View File

@ -146,23 +146,27 @@ DesktopModel *TabBoxHandlerPrivate::desktopModel() const
void TabBoxHandlerPrivate::updateHighlightWindows()
{
if (!isShown || config.tabBoxMode() != TabBoxConfig::ClientTabBox)
if (!isShown || config.tabBoxMode() != TabBoxConfig::ClientTabBox) {
return;
}
TabBoxClient *currentClient = q->client(index);
QWindow *w = window();
if (q->isKWinCompositing()) {
if (lastRaisedClient)
if (lastRaisedClient) {
q->elevateClient(lastRaisedClient, w, false);
}
lastRaisedClient = currentClient;
if (currentClient)
if (currentClient) {
q->elevateClient(currentClient, w, true);
}
} else {
if (lastRaisedClient) {
q->shadeClient(lastRaisedClient, true);
if (lastRaisedClientSucc)
if (lastRaisedClientSucc) {
q->restack(lastRaisedClient, lastRaisedClientSucc);
}
// TODO lastRaisedClient->setMinimized( lastRaisedClientWasMinimized );
}
@ -205,10 +209,12 @@ void TabBoxHandlerPrivate::endHighlightWindows(bool abort)
}
}
QWindow *w = window();
if (currentClient)
if (currentClient) {
q->elevateClient(currentClient, w, false);
if (abort && lastRaisedClient && lastRaisedClientSucc)
}
if (abort && lastRaisedClient && lastRaisedClientSucc) {
q->restack(lastRaisedClient, lastRaisedClientSucc);
}
lastRaisedClient = nullptr;
lastRaisedClientSucc = nullptr;
// highlight windows
@ -438,60 +444,69 @@ QModelIndex TabBoxHandler::nextPrev(bool forward) const
if (column == model->columnCount()) {
column = 0;
row++;
if (row == model->rowCount())
if (row == model->rowCount()) {
row = 0;
}
}
ret = model->index(row, column);
if (!ret.isValid())
if (!ret.isValid()) {
ret = model->index(0, 0);
}
} else {
int column = d->index.column() - 1;
int row = d->index.row();
if (column < 0) {
column = model->columnCount() - 1;
row--;
if (row < 0)
if (row < 0) {
row = model->rowCount() - 1;
}
}
ret = model->index(row, column);
if (!ret.isValid()) {
row = model->rowCount() - 1;
for (int i = model->columnCount() - 1; i >= 0; i--) {
ret = model->index(row, i);
if (ret.isValid())
if (ret.isValid()) {
break;
}
}
}
}
if (ret.isValid())
if (ret.isValid()) {
return ret;
else
} else {
return d->index;
}
}
QModelIndex TabBoxHandler::desktopIndex(int desktop) const
{
if (d->config.tabBoxMode() != TabBoxConfig::DesktopTabBox)
if (d->config.tabBoxMode() != TabBoxConfig::DesktopTabBox) {
return QModelIndex();
}
return d->desktopModel()->desktopIndex(desktop);
}
QList<int> TabBoxHandler::desktopList() const
{
if (d->config.tabBoxMode() != TabBoxConfig::DesktopTabBox)
if (d->config.tabBoxMode() != TabBoxConfig::DesktopTabBox) {
return QList<int>();
}
return d->desktopModel()->desktopList();
}
int TabBoxHandler::desktop(const QModelIndex &index) const
{
if (!index.isValid() || (d->config.tabBoxMode() != TabBoxConfig::DesktopTabBox))
if (!index.isValid() || (d->config.tabBoxMode() != TabBoxConfig::DesktopTabBox)) {
return -1;
}
QVariant ret = d->desktopModel()->data(index, DesktopModel::DesktopRole);
if (ret.isValid())
if (ret.isValid()) {
return ret.toInt();
else
} else {
return -1;
}
}
void TabBoxHandler::setCurrentIndex(const QModelIndex &index)
@ -543,15 +558,17 @@ QModelIndex TabBoxHandler::index(QWeakPointer<KWin::TabBox::TabBoxClient> client
TabBoxClientList TabBoxHandler::clientList() const
{
if (d->config.tabBoxMode() != TabBoxConfig::ClientTabBox)
if (d->config.tabBoxMode() != TabBoxConfig::ClientTabBox) {
return TabBoxClientList();
}
return d->clientModel()->clientList();
}
TabBoxClient *TabBoxHandler::client(const QModelIndex &index) const
{
if ((!index.isValid()) || (d->config.tabBoxMode() != TabBoxConfig::ClientTabBox))
if ((!index.isValid()) || (d->config.tabBoxMode() != TabBoxConfig::ClientTabBox)) {
return nullptr;
}
TabBoxClient *c = static_cast<TabBoxClient *>(
d->clientModel()->data(index, ClientModel::ClientRole).value<void *>());
return c;
@ -578,10 +595,12 @@ void TabBoxHandler::createModel(bool partialReset)
lastRaisedSucc = true;
}
}
if (d->lastRaisedClient && !lastRaised)
if (d->lastRaisedClient && !lastRaised) {
d->lastRaisedClient = nullptr;
if (d->lastRaisedClientSucc && !lastRaisedSucc)
}
if (d->lastRaisedClientSucc && !lastRaisedSucc) {
d->lastRaisedClientSucc = nullptr;
}
break;
}
case TabBoxConfig::DesktopTabBox:

View File

@ -112,16 +112,18 @@ void X11Filter::keyRelease(xcb_generic_event_t *event)
int mod_index = -1;
for (int i = XCB_MAP_INDEX_SHIFT;
i <= XCB_MAP_INDEX_5;
++i)
++i) {
if ((mk & (1 << i)) != 0) {
if (mod_index >= 0)
if (mod_index >= 0) {
return;
}
mod_index = i;
}
}
bool release = false;
if (mod_index == -1)
if (mod_index == -1) {
release = true;
else {
} else {
Xcb::ModifierMapping xmk;
if (xmk) {
xcb_keycode_t *keycodes = xmk.keycodes();

View File

@ -116,8 +116,9 @@ void Toplevel::copyToDeleted(Toplevel *c)
ready_for_painting = c->ready_for_painting;
is_shape = c->is_shape;
effect_window = c->effect_window;
if (effect_window != nullptr)
if (effect_window != nullptr) {
effect_window->setWindow(this);
}
m_shadow = c->m_shadow;
if (m_shadow) {
m_shadow->setToplevel(this);
@ -271,8 +272,9 @@ void Toplevel::setOpacity(qreal opacity)
bool Toplevel::setupCompositing()
{
if (!Compositor::compositing())
if (!Compositor::compositing()) {
return false;
}
effect_window = new EffectWindowImpl(this);
updateShadow();

View File

@ -124,8 +124,9 @@ bool Unmanaged::track(xcb_window_t w)
getResourceClass();
getWmClientLeader();
getWmClientMachine();
if (Xcb::Extensions::self()->isShapeAvailable())
if (Xcb::Extensions::self()->isShapeAvailable()) {
xcb_shape_select_input(kwinApp()->x11Connection(), w, true);
}
detectShape(w);
getWmOpaqueRegion();
getSkipCloseAnimation();
@ -133,8 +134,9 @@ bool Unmanaged::track(xcb_window_t w)
if (QWindow *internalWindow = findInternalWindow()) {
m_outline = internalWindow->property("__kwin_outline").toBool();
}
if (effects)
if (effects) {
static_cast<EffectsHandlerImpl *>(effects)->checkInputWindowStacking();
}
return true;
}
@ -147,8 +149,9 @@ void Unmanaged::release(ReleaseReason releaseReason)
Q_EMIT windowClosed(this, del);
finishCompositing(releaseReason);
if (!QWidget::find(window()) && releaseReason != ReleaseReason::Destroyed) { // don't affect our own windows
if (Xcb::Extensions::self()->isShapeAvailable())
if (Xcb::Extensions::self()->isShapeAvailable()) {
xcb_shape_select_input(kwinApp()->x11Connection(), window(), false);
}
Xcb::selectInput(window(), XCB_EVENT_MASK_NO_EVENT);
}
workspace()->removeUnmanaged(this);

View File

@ -185,12 +185,14 @@ void UserActionsMenu::helperDialog(const QString &message, AbstractClient *clien
if (!type.isEmpty()) {
KConfig cfg(QStringLiteral("kwin_dialogsrc"));
KConfigGroup cg(&cfg, "Notification Messages"); // Depends on KMessageBox
if (!cg.readEntry(type, true))
if (!cg.readEntry(type, true)) {
return;
}
args << QStringLiteral("--dontagain") << QLatin1String("kwin_dialogsrc:") + type;
}
if (client)
if (client) {
args << QStringLiteral("--embed") << QString::number(client->window());
}
QtConcurrent::run([args]() {
KProcess::startDetached(QStringLiteral("kdialog"), args);
});
@ -200,9 +202,9 @@ QStringList configModules(bool controlCenter)
{
QStringList args;
args << QStringLiteral("kwindecoration");
if (controlCenter)
if (controlCenter) {
args << QStringLiteral("kwinoptions");
else if (KAuthorized::authorizeControlModule(QStringLiteral("kde-kwinoptions.desktop")))
} else if (KAuthorized::authorizeControlModule(QStringLiteral("kde-kwinoptions.desktop"))) {
args << QStringLiteral("kwinactions") << QStringLiteral("kwinfocus") << QStringLiteral("kwinmoving") << QStringLiteral("kwinadvanced")
<< QStringLiteral("kwinrules") << QStringLiteral("kwincompositing") << QStringLiteral("kwineffects")
#if KWIN_BUILD_TABBOX
@ -210,6 +212,7 @@ QStringList configModules(bool controlCenter)
#endif
<< QStringLiteral("kwinscreenedges")
<< QStringLiteral("kwinscripts");
}
return args;
}
@ -355,8 +358,9 @@ void UserActionsMenu::discard()
void UserActionsMenu::menuAboutToShow()
{
if (m_client.isNull() || !m_menu)
if (m_client.isNull() || !m_menu) {
return;
}
if (VirtualDesktopManager::self()->count() == 1) {
delete m_desktopMenu;
@ -446,8 +450,9 @@ void UserActionsMenu::initDesktopPopup()
action->setIcon(QIcon::fromTheme(QStringLiteral("virtual-desktops")));
} else {
if (m_desktopMenu)
if (m_desktopMenu) {
return;
}
m_desktopMenu = new QMenu(m_menu);
connect(m_desktopMenu, &QMenu::aboutToShow, this, &UserActionsMenu::desktopPopupAboutToShow);
@ -478,8 +483,9 @@ void UserActionsMenu::initScreenPopup()
void UserActionsMenu::initActivityPopup()
{
if (m_activityMenu)
if (m_activityMenu) {
return;
}
m_activityMenu = new QMenu(m_menu);
connect(m_activityMenu, &QMenu::triggered, this, &UserActionsMenu::slotToggleOnActivity);
@ -494,8 +500,9 @@ void UserActionsMenu::initActivityPopup()
void UserActionsMenu::desktopPopupAboutToShow()
{
if (!m_desktopMenu)
if (!m_desktopMenu) {
return;
}
const VirtualDesktopManager *vds = VirtualDesktopManager::self();
m_desktopMenu->clear();
@ -561,8 +568,9 @@ void UserActionsMenu::desktopPopupAboutToShow()
void UserActionsMenu::multipleDesktopsPopupAboutToShow()
{
if (!m_multipleDesktopsMenu)
if (!m_multipleDesktopsMenu) {
return;
}
VirtualDesktopManager *vds = VirtualDesktopManager::self();
m_multipleDesktopsMenu->clear();
@ -684,8 +692,9 @@ void UserActionsMenu::screenPopupAboutToShow()
void UserActionsMenu::activityPopupAboutToShow()
{
if (!m_activityMenu)
if (!m_activityMenu) {
return;
}
#if KWIN_BUILD_ACTIVITIES
if (!Activities::self()) {
@ -732,28 +741,33 @@ void UserActionsMenu::activityPopupAboutToShow()
void UserActionsMenu::slotWindowOperation(QAction *action)
{
if (!action->data().isValid())
if (!action->data().isValid()) {
return;
}
Options::WindowOperation op = static_cast<Options::WindowOperation>(action->data().toInt());
QPointer<AbstractClient> c = m_client ? m_client : QPointer<AbstractClient>(Workspace::self()->activeClient());
if (c.isNull())
if (c.isNull()) {
return;
}
QString type;
switch (op) {
case Options::FullScreenOp:
if (!c->isFullScreen() && c->userCanSetFullScreen())
if (!c->isFullScreen() && c->userCanSetFullScreen()) {
type = QStringLiteral("fullscreenaltf3");
}
break;
case Options::NoBorderOp:
if (!c->noBorder() && c->userCanSetNoBorder())
if (!c->noBorder() && c->userCanSetNoBorder()) {
type = QStringLiteral("noborderaltf3");
}
break;
default:
break;
}
if (!type.isEmpty())
if (!type.isEmpty()) {
helperDialog(type, c);
}
// need to delay performing the window operation as we need to have the
// user actions menu closed before we destroy the decoration. Otherwise Qt crashes
qRegisterMetaType<Options::WindowOperation>();
@ -767,8 +781,9 @@ void UserActionsMenu::slotToggleOnActivity(QAction *action)
return;
}
QString activity = action->data().toString();
if (m_client.isNull())
if (m_client.isNull()) {
return;
}
if (activity.isEmpty()) {
// the 'on_all_activities' menu entry
m_client->setOnAllActivities(!m_client->isOnAllActivities());
@ -843,8 +858,9 @@ void ShortcutDialog::keySequenceChanged()
{
activateWindow(); // where is the kbd focus lost? cause of popup state?
QKeySequence seq = m_ui.keySequenceEdit->keySequence();
if (_shortcut == seq)
if (_shortcut == seq) {
return; // don't try to update the same
}
if (seq.isEmpty()) { // clear
_shortcut = seq;
@ -869,8 +885,9 @@ void ShortcutDialog::keySequenceChanged()
m_ui.keySequenceEdit->setKeySequence(shortcut());
} else if (seq != _shortcut) {
m_ui.warning->hide();
if (QPushButton *ok = m_ui.buttonBox->button(QDialogButtonBox::Ok))
if (QPushButton *ok = m_ui.buttonBox->button(QDialogButtonBox::Ok)) {
ok->setFocus();
}
}
_shortcut = seq;
@ -1106,10 +1123,12 @@ void Workspace::setupWindowShortcut(AbstractClient *c)
QRect r = clientArea(ScreenArea, c);
QSize size = client_keys_dialog->sizeHint();
QPoint pos = c->pos() + c->clientPos();
if (pos.x() + size.width() >= r.right())
if (pos.x() + size.width() >= r.right()) {
pos.setX(r.right() - size.width());
if (pos.y() + size.height() >= r.bottom())
}
if (pos.y() + size.height() >= r.bottom()) {
pos.setY(r.bottom() - size.height());
}
client_keys_dialog->move(pos);
client_keys_dialog->show();
active_popup = client_keys_dialog;
@ -1121,14 +1140,16 @@ void Workspace::setupWindowShortcutDone(bool ok)
// keys->setEnabled( true );
// disable_shortcuts_keys->setEnabled( true );
// client_keys->setEnabled( true );
if (ok)
if (ok) {
client_keys_client->setShortcut(client_keys_dialog->shortcut().toString());
}
closeActivePopup();
client_keys_dialog->deleteLater();
client_keys_dialog = nullptr;
client_keys_client = nullptr;
if (active_client)
if (active_client) {
active_client->takeFocus();
}
}
void Workspace::clientShortcutUpdated(AbstractClient *c)
@ -1158,12 +1179,15 @@ void Workspace::clientShortcutUpdated(AbstractClient *c)
void Workspace::performWindowOperation(AbstractClient *c, Options::WindowOperation op)
{
if (!c)
if (!c) {
return;
if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp)
}
if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp) {
Cursors::self()->mouse()->setPos(c->frameGeometry().center());
if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp)
}
if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp) {
Cursors::self()->mouse()->setPos(c->frameGeometry().bottomRight());
}
switch (op) {
case Options::MoveOp:
c->performMouseCommand(Options::MouseMove, Cursors::self()->mouse()->pos());
@ -1219,16 +1243,18 @@ void Workspace::performWindowOperation(AbstractClient *c, Options::WindowOperati
StackingUpdatesBlocker blocker(this);
bool was = c->keepAbove();
c->setKeepAbove(!c->keepAbove());
if (was && !c->keepAbove())
if (was && !c->keepAbove()) {
raiseClient(c);
}
break;
}
case Options::KeepBelowOp: {
StackingUpdatesBlocker blocker(this);
bool was = c->keepBelow();
c->setKeepBelow(!c->keepBelow());
if (was && !c->keepBelow())
if (was && !c->keepBelow()) {
lowerClient(c);
}
break;
}
case Options::OperationsOp:
@ -1253,8 +1279,9 @@ void Workspace::performWindowOperation(AbstractClient *c, Options::WindowOperati
void Workspace::slotActivateAttentionWindow()
{
if (attention_chain.count() > 0)
if (attention_chain.count() > 0) {
activateClient(attention_chain.first());
}
}
static uint senderValue(QObject *sender)
@ -1262,10 +1289,12 @@ static uint senderValue(QObject *sender)
QAction *act = qobject_cast<QAction *>(sender);
bool ok = false;
uint i = -1;
if (act)
if (act) {
i = act->data().toUInt(&ok);
if (ok)
}
if (ok) {
return i;
}
return -1;
}
@ -1280,8 +1309,9 @@ void Workspace::slotWindowToDesktop(VirtualDesktop *desktop)
static bool screenSwitchImpossible()
{
if (!options->activeMouseScreen())
if (!options->activeMouseScreen()) {
return false;
}
QStringList args;
args << QStringLiteral("--passivepopup") << i18n("The window manager is configured to consider the screen with the mouse on it as active one.\n"
"Therefore it is not possible to switch to a screen explicitly.")
@ -1308,8 +1338,9 @@ AbstractOutput *Workspace::previousOutput(AbstractOutput *reference) const
void Workspace::slotSwitchToScreen()
{
if (screenSwitchImpossible())
if (screenSwitchImpossible()) {
return;
}
AbstractOutput *output = kwinApp()->platform()->findOutput(senderValue(sender()));
if (output) {
switchToOutput(output);
@ -1318,15 +1349,17 @@ void Workspace::slotSwitchToScreen()
void Workspace::slotSwitchToNextScreen()
{
if (screenSwitchImpossible())
if (screenSwitchImpossible()) {
return;
}
switchToOutput(nextOutput(activeOutput()));
}
void Workspace::slotSwitchToPrevScreen()
{
if (screenSwitchImpossible())
if (screenSwitchImpossible()) {
return;
}
switchToOutput(previousOutput(activeOutput()));
}
@ -1359,8 +1392,9 @@ void Workspace::slotWindowToPrevScreen()
*/
void Workspace::slotWindowMaximize()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::MaximizeOp);
}
}
/**
@ -1368,8 +1402,9 @@ void Workspace::slotWindowMaximize()
*/
void Workspace::slotWindowMaximizeVertical()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::VMaximizeOp);
}
}
/**
@ -1377,8 +1412,9 @@ void Workspace::slotWindowMaximizeVertical()
*/
void Workspace::slotWindowMaximizeHorizontal()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::HMaximizeOp);
}
}
/**
@ -1386,8 +1422,9 @@ void Workspace::slotWindowMaximizeHorizontal()
*/
void Workspace::slotWindowMinimize()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::MinimizeOp);
}
}
/**
@ -1395,8 +1432,9 @@ void Workspace::slotWindowMinimize()
*/
void Workspace::slotWindowShade()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::ShadeOp);
}
}
/**
@ -1404,8 +1442,9 @@ void Workspace::slotWindowShade()
*/
void Workspace::slotWindowRaise()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
raiseClient(active_client);
}
}
/**
@ -1421,8 +1460,9 @@ void Workspace::slotWindowLower()
if (active_client->isActive() && options->focusPolicyIsReasonable()) {
if (options->isNextFocusPrefersMouse()) {
AbstractClient *next = clientUnderMouse(active_client->output());
if (next && next != active_client)
if (next && next != active_client) {
requestFocus(next, false);
}
} else {
activateClient(topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop()));
}
@ -1435,43 +1475,50 @@ void Workspace::slotWindowLower()
*/
void Workspace::slotWindowRaiseOrLower()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
raiseOrLowerClient(active_client);
}
}
void Workspace::slotWindowOnAllDesktops()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
active_client->setOnAllDesktops(!active_client->isOnAllDesktops());
}
}
void Workspace::slotWindowFullScreen()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::FullScreenOp);
}
}
void Workspace::slotWindowNoBorder()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::NoBorderOp);
}
}
void Workspace::slotWindowAbove()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::KeepAboveOp);
}
}
void Workspace::slotWindowBelow()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::KeepBelowOp);
}
}
void Workspace::slotSetupWindowShortcut()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::SetupWindowShortcutOp);
}
}
/**
@ -1503,8 +1550,9 @@ void windowToDesktop(AbstractClient *c)
*/
void Workspace::slotWindowToNextDesktop()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
windowToNextDesktop(active_client);
}
}
void Workspace::windowToNextDesktop(AbstractClient *c)
@ -1517,8 +1565,9 @@ void Workspace::windowToNextDesktop(AbstractClient *c)
*/
void Workspace::slotWindowToPreviousDesktop()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
windowToPreviousDesktop(active_client);
}
}
void Workspace::windowToPreviousDesktop(AbstractClient *c)
@ -1586,8 +1635,9 @@ void Workspace::slotKillWindow()
*/
void Workspace::switchWindow(Direction direction)
{
if (!active_client)
if (!active_client) {
return;
}
AbstractClient *c = active_client;
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
@ -1675,8 +1725,9 @@ bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curP
*/
void Workspace::slotWindowOperations()
{
if (!active_client)
if (!active_client) {
return;
}
QPoint pos = active_client->pos() + active_client->clientPos();
showWindowMenu(QRect(pos, pos), active_client);
}
@ -1699,8 +1750,9 @@ void Workspace::slotWindowClose()
// TODO: why?
// if ( tab_box->isVisible())
// return;
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::CloseOp);
}
}
/**
@ -1708,8 +1760,9 @@ void Workspace::slotWindowClose()
*/
void Workspace::slotWindowMove()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::UnrestrictedMoveOp);
}
}
/**
@ -1717,8 +1770,9 @@ void Workspace::slotWindowMove()
*/
void Workspace::slotWindowResize()
{
if (USABLE_ACTIVE_CLIENT)
if (USABLE_ACTIVE_CLIENT) {
performWindowOperation(active_client, Options::UnrestrictedResizeOp);
}
}
#undef USABLE_ACTIVE_CLIENT
@ -1727,8 +1781,9 @@ void AbstractClient::setShortcut(const QString &_cut)
{
QString cut = rules()->checkShortcut(_cut);
auto updateShortcut = [this](const QKeySequence &cut = QKeySequence()) {
if (_shortcut == cut)
if (_shortcut == cut) {
return;
}
_shortcut = cut;
setShortcutInternal();
};
@ -1743,10 +1798,11 @@ void AbstractClient::setShortcut(const QString &_cut)
// base+(abcdef)<space>base+(abcdef)
// E.g. Alt+Ctrl+(ABCDEF);Meta+X,Meta+(ABCDEF)
if (!cut.contains(QLatin1Char('(')) && !cut.contains(QLatin1Char(')')) && !cut.contains(QLatin1String(" - "))) {
if (workspace()->shortcutAvailable(cut, this))
if (workspace()->shortcutAvailable(cut, this)) {
updateShortcut(QKeySequence(cut));
else
} else {
updateShortcut();
}
return;
}
const QRegularExpression reg(QStringLiteral("(.*\\+)\\((.*)\\)"));
@ -1763,8 +1819,9 @@ void AbstractClient::setShortcut(const QString &_cut)
i < list.length();
++i) {
QKeySequence c(base + list[i]);
if (!c.isEmpty())
if (!c.isEmpty()) {
keys.append(c);
}
}
} else {
// regexp doesn't match, so it should be a normal shortcut
@ -1777,8 +1834,9 @@ void AbstractClient::setShortcut(const QString &_cut)
for (auto it = keys.constBegin();
it != keys.constEnd();
++it) {
if (_shortcut == *it) // current one is in the list
if (_shortcut == *it) { // current one is in the list
return;
}
}
for (auto it = keys.constBegin();
it != keys.constEnd();
@ -1812,8 +1870,9 @@ void X11Client::setShortcutInternal()
bool Workspace::shortcutAvailable(const QKeySequence &cut, AbstractClient *ignore) const
{
if (ignore && cut == ignore->shortcut())
if (ignore && cut == ignore->shortcut()) {
return true;
}
// Check if the shortcut is already registered
const QList<KGlobalShortcutInfo> registeredShortcuts = KGlobalAccel::globalShortcutsByKey(cut);

View File

@ -84,8 +84,9 @@ static int server_grab_count = 0;
void grabXServer()
{
if (++server_grab_count == 1)
if (++server_grab_count == 1) {
xcb_grab_server(connection());
}
}
void ungrabXServer()
@ -101,14 +102,18 @@ static bool keyboard_grabbed = false;
bool grabXKeyboard(xcb_window_t w)
{
if (QWidget::keyboardGrabber() != nullptr)
if (QWidget::keyboardGrabber() != nullptr) {
return false;
if (keyboard_grabbed)
}
if (keyboard_grabbed) {
return false;
if (qApp->activePopupWidget() != nullptr)
}
if (qApp->activePopupWidget() != nullptr) {
return false;
if (w == XCB_WINDOW_NONE)
}
if (w == XCB_WINDOW_NONE) {
w = rootWindow();
}
const xcb_grab_keyboard_cookie_t c = xcb_grab_keyboard_unchecked(connection(), false, w, xTime(),
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
ScopedCPointer<xcb_grab_keyboard_reply_t> grab(xcb_grab_keyboard_reply(connection(), c, nullptr));
@ -138,46 +143,60 @@ void ungrabXKeyboard()
Qt::MouseButton x11ToQtMouseButton(int button)
{
if (button == XCB_BUTTON_INDEX_1)
if (button == XCB_BUTTON_INDEX_1) {
return Qt::LeftButton;
if (button == XCB_BUTTON_INDEX_2)
}
if (button == XCB_BUTTON_INDEX_2) {
return Qt::MiddleButton;
if (button == XCB_BUTTON_INDEX_3)
}
if (button == XCB_BUTTON_INDEX_3) {
return Qt::RightButton;
if (button == XCB_BUTTON_INDEX_4)
}
if (button == XCB_BUTTON_INDEX_4) {
return Qt::XButton1;
if (button == XCB_BUTTON_INDEX_5)
}
if (button == XCB_BUTTON_INDEX_5) {
return Qt::XButton2;
}
return Qt::NoButton;
}
Qt::MouseButtons x11ToQtMouseButtons(int state)
{
Qt::MouseButtons ret = {};
if (state & XCB_KEY_BUT_MASK_BUTTON_1)
if (state & XCB_KEY_BUT_MASK_BUTTON_1) {
ret |= Qt::LeftButton;
if (state & XCB_KEY_BUT_MASK_BUTTON_2)
}
if (state & XCB_KEY_BUT_MASK_BUTTON_2) {
ret |= Qt::MiddleButton;
if (state & XCB_KEY_BUT_MASK_BUTTON_3)
}
if (state & XCB_KEY_BUT_MASK_BUTTON_3) {
ret |= Qt::RightButton;
if (state & XCB_KEY_BUT_MASK_BUTTON_4)
}
if (state & XCB_KEY_BUT_MASK_BUTTON_4) {
ret |= Qt::XButton1;
if (state & XCB_KEY_BUT_MASK_BUTTON_5)
}
if (state & XCB_KEY_BUT_MASK_BUTTON_5) {
ret |= Qt::XButton2;
}
return ret;
}
Qt::KeyboardModifiers x11ToQtKeyboardModifiers(int state)
{
Qt::KeyboardModifiers ret = {};
if (state & XCB_KEY_BUT_MASK_SHIFT)
if (state & XCB_KEY_BUT_MASK_SHIFT) {
ret |= Qt::ShiftModifier;
if (state & XCB_KEY_BUT_MASK_CONTROL)
}
if (state & XCB_KEY_BUT_MASK_CONTROL) {
ret |= Qt::ControlModifier;
if (state & KKeyServer::modXAlt())
}
if (state & KKeyServer::modXAlt()) {
ret |= Qt::AltModifier;
if (state & KKeyServer::modXMeta())
}
if (state & KKeyServer::modXMeta()) {
ret |= Qt::MetaModifier;
}
return ret;
}

View File

@ -31,8 +31,9 @@ static QStringList fetchProcessServiceField(const QString &executablePath, const
// needed to be able to use the logging category in a header static function
static QLoggingCategory KWIN_UTILS("KWIN_UTILS", QtWarningMsg);
const auto servicesFound = KApplicationTrader::query([&executablePath](const KService::Ptr &service) {
if (service->exec().isEmpty() || QFileInfo(service->exec()).canonicalFilePath() != executablePath)
if (service->exec().isEmpty() || QFileInfo(service->exec()).canonicalFilePath() != executablePath) {
return false;
}
return true;
});

View File

@ -50,8 +50,9 @@ void SubSurfaceMonitor::registerSubSurface(SubSurfaceInterface *subSurface)
void SubSurfaceMonitor::unregisterSubSurface(SubSurfaceInterface *subSurface)
{
SurfaceInterface *surface = subSurface->surface();
if (!surface)
if (!surface) {
return;
}
disconnect(subSurface, nullptr, this, nullptr);

View File

@ -615,8 +615,9 @@ public:
}
inline xcb_window_t parent()
{
if (isNull())
if (isNull()) {
return XCB_WINDOW_NONE;
}
return (*this)->parent;
}
};
@ -639,8 +640,9 @@ public:
inline xcb_window_t window()
{
if (isNull())
if (isNull()) {
return XCB_WINDOW_NONE;
}
return (*this)->focus;
}
};

View File

@ -766,8 +766,9 @@ void WaylandServer::simulateUserActivity()
void WaylandServer::updateKeyState(KWin::LEDs leds)
{
if (!m_keyState)
if (!m_keyState) {
return;
}
m_keyState->setState(KeyStateInterface::Key::CapsLock, leds & KWin::LED::CapsLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
m_keyState->setState(KeyStateInterface::Key::NumLock, leds & KWin::LED::NumLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);

View File

@ -250,8 +250,9 @@ void Workspace::init()
// load is needed to be called again when starting xwayalnd to sync to RootInfo, see BUG 385260
vds->save();
if (!VirtualDesktopManager::self()->setCurrent(m_initialDesktop))
if (!VirtualDesktopManager::self()->setCurrent(m_initialDesktop)) {
VirtualDesktopManager::self()->setCurrent(1);
}
reconfigureTimer.setSingleShot(true);
updateToolWindowsTimer.setSingleShot(true);
@ -356,8 +357,9 @@ void Workspace::initializeX11()
rootInfo->setActiveWindow(XCB_WINDOW_NONE);
focusToNull();
if (!sessionRestored)
if (!sessionRestored) {
++block_focus; // Because it will be set below
}
{
// Begin updates blocker block
@ -384,9 +386,10 @@ void Workspace::initializeX11()
}
if (attr->override_redirect) {
if (attr->map_state == XCB_MAP_STATE_VIEWABLE && attr->_class != XCB_WINDOW_CLASS_INPUT_ONLY)
if (attr->map_state == XCB_MAP_STATE_VIEWABLE && attr->_class != XCB_WINDOW_CLASS_INPUT_ONLY) {
// ### This will request the attributes again
createUnmanaged(wins[i]);
}
} else if (attr->map_state != XCB_MAP_STATE_UNMAPPED) {
if (Application::wasCrash()) {
fixPositionAfterCrash(wins[i], windowGeometries.at(i).data());
@ -425,13 +428,16 @@ void Workspace::initializeX11()
if (new_active_client == nullptr
&& activeClient() == nullptr && should_get_focus.count() == 0) {
// No client activated in manage()
if (new_active_client == nullptr)
if (new_active_client == nullptr) {
new_active_client = topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop());
if (new_active_client == nullptr)
}
if (new_active_client == nullptr) {
new_active_client = findDesktop(true, VirtualDesktopManager::self()->currentDesktop());
}
}
if (new_active_client != nullptr)
if (new_active_client != nullptr) {
activateClient(new_active_client);
}
}
void Workspace::cleanupX11()
@ -692,12 +698,14 @@ void Workspace::addClient(X11Client *c)
Q_EMIT clientAdded(c);
if (grp != nullptr)
if (grp != nullptr) {
grp->gotLeader(c);
}
if (c->isDesktop()) {
if (active_client == nullptr && should_get_focus.isEmpty() && c->isOnCurrentDesktop())
if (active_client == nullptr && should_get_focus.isEmpty() && c->isOnCurrentDesktop()) {
requestFocus(c); // TODO: Make sure desktop is active after startup if there's no other window active
}
} else {
FocusChain::self()->update(c, FocusChain::Update);
}
@ -710,14 +718,16 @@ void Workspace::addClient(X11Client *c)
if (c->isDesktop()) {
raiseClient(c);
// If there's no active client, make this desktop the active one
if (activeClient() == nullptr && should_get_focus.count() == 0)
if (activeClient() == nullptr && should_get_focus.count() == 0) {
activateClient(findDesktop(true, VirtualDesktopManager::self()->currentDesktop()));
}
}
c->checkActiveModal();
checkTransients(c->window()); // SELI TODO: Does this really belong here?
updateStackingOrder(true); // Propagate new client
if (c->isUtility() || c->isMenu() || c->isToolbar())
if (c->isUtility() || c->isMenu() || c->isToolbar()) {
updateToolWindows(true);
}
updateTabbox();
}
@ -732,8 +742,9 @@ void Workspace::addUnmanaged(Unmanaged *c)
*/
void Workspace::removeX11Client(X11Client *c)
{
if (c == active_popup_client)
if (c == active_popup_client) {
closeActivePopup();
}
if (m_userActionsMenu->isMenuClient(c)) {
m_userActionsMenu->close();
}
@ -742,8 +753,9 @@ void Workspace::removeX11Client(X11Client *c)
// TODO: if marked client is removed, notify the marked list
m_x11Clients.removeAll(c);
Group *group = findGroup(c->window());
if (group != nullptr)
if (group != nullptr) {
group->lostLeader();
}
removeAbstractClient(c);
}
@ -867,8 +879,9 @@ void Workspace::updateToolWindows(bool also_hide)
{
// TODO: What if Client's transiency/group changes? should this be called too? (I'm paranoid, am I not?)
if (!options->isHideUtilityWindowsForInactive()) {
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it)
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it) {
(*it)->showClient();
}
return;
}
const Group *group = nullptr;
@ -876,8 +889,9 @@ void Workspace::updateToolWindows(bool also_hide)
// Go up in transiency hiearchy, if the top is found, only tool transients for the top mainwindow
// will be shown; if a group transient is group, all tools in the group will be shown
while (client != nullptr) {
if (!client->isTransient())
if (!client->isTransient()) {
break;
}
if (client->groupTransient()) {
group = client->group();
break;
@ -897,47 +911,56 @@ void Workspace::updateToolWindows(bool also_hide)
if (c->isUtility() || c->isMenu() || c->isToolbar()) {
bool show = true;
if (!c->isTransient()) {
if (!c->group() || c->group()->members().count() == 1) // Has its own group, keep always visible
if (!c->group() || c->group()->members().count() == 1) { // Has its own group, keep always visible
show = true;
else if (client != nullptr && c->group() == client->group())
} else if (client != nullptr && c->group() == client->group()) {
show = true;
else
} else {
show = false;
}
} else {
if (group != nullptr && c->group() == group)
if (group != nullptr && c->group() == group) {
show = true;
else if (client != nullptr && client->hasTransient(c, true))
} else if (client != nullptr && client->hasTransient(c, true)) {
show = true;
else
} else {
show = false;
}
}
if (!show && also_hide) {
const auto mainclients = c->mainClients();
// Don't hide utility windows which are standalone(?) or
// have e.g. kicker as mainwindow
if (mainclients.isEmpty())
if (mainclients.isEmpty()) {
show = true;
for (auto it2 = mainclients.constBegin(); it2 != mainclients.constEnd(); ++it2) {
if ((*it2)->isSpecialWindow())
show = true;
}
if (!show)
for (auto it2 = mainclients.constBegin(); it2 != mainclients.constEnd(); ++it2) {
if ((*it2)->isSpecialWindow()) {
show = true;
}
}
if (!show) {
to_hide.append(c);
}
}
if (show)
if (show) {
to_show.append(c);
}
}
} // First show new ones, then hide
for (int i = to_show.size() - 1; i >= 0; --i) // From topmost
for (int i = to_show.size() - 1; i >= 0; --i) { // From topmost
// TODO: Since this is in stacking order, the order of taskbar entries changes :(
to_show.at(i)->showClient();
}
if (also_hide) {
for (auto it = to_hide.constBegin(); it != to_hide.constEnd(); ++it) // From bottommost
for (auto it = to_hide.constBegin(); it != to_hide.constEnd(); ++it) { // From bottommost
(*it)->hideClient();
}
updateToolWindowsTimer.stop();
} else // setActiveClient() is after called with NULL client, quickly followed
} else { // setActiveClient() is after called with NULL client, quickly followed
// by setting a new client, which would result in flickering
resetUpdateToolWindowsTimer();
}
}
void Workspace::resetUpdateToolWindowsTimer()
@ -990,8 +1013,9 @@ void Workspace::slotReconfigure()
// in case borderless maximized windows option changed and new option
// is to have borders, we need to unset the borders for all maximized windows
for (auto it = m_allClients.cbegin(); it != m_allClients.cend(); ++it) {
if ((*it)->maximizeMode() == MaximizeFull)
if ((*it)->maximizeMode() == MaximizeFull) {
(*it)->checkNoBorder();
}
}
}
}
@ -1034,11 +1058,13 @@ void Workspace::updateClientVisibilityOnDesktopChange(VirtualDesktop *newDesktop
if (!c) {
continue;
}
if (c->isOnDesktop(newDesktop) && c->isOnCurrentActivity())
if (c->isOnDesktop(newDesktop) && c->isOnCurrentActivity()) {
c->updateVisibility();
}
}
if (showingDesktop()) // Do this only after desktop change to avoid flicker
if (showingDesktop()) { // Do this only after desktop change to avoid flicker
setShowingDesktop(false);
}
}
void Workspace::activateClientOnNewDesktop(VirtualDesktop *desktop)
@ -1050,19 +1076,23 @@ void Workspace::activateClientOnNewDesktop(VirtualDesktop *desktop)
// If "unreasonable focus policy" and active_client is on_all_desktops and
// under mouse (Hence == old_active_client), conserve focus.
// (Thanks to Volker Schatz <V.Schatz at thphys.uni-heidelberg.de>)
else if (active_client && active_client->isShown() && active_client->isOnCurrentDesktop())
else if (active_client && active_client->isShown() && active_client->isOnCurrentDesktop()) {
c = active_client;
}
if (!c)
if (!c) {
c = findDesktop(true, desktop);
}
if (c != active_client)
if (c != active_client) {
setActiveClient(nullptr);
}
if (c)
if (c) {
requestFocus(c);
else
} else {
focusToNull();
}
}
AbstractClient *Workspace::findClientToActivateOnDesktop(VirtualDesktop *desktop)
@ -1080,12 +1110,14 @@ AbstractClient *Workspace::findClientToActivateOnDesktop(VirtualDesktop *desktop
continue;
}
if (!(!client->isShade() && client->isShown() && client->isOnDesktop(desktop) && client->isOnCurrentActivity() && client->isOnActiveOutput()))
if (!(!client->isShade() && client->isShown() && client->isOnDesktop(desktop) && client->isOnCurrentActivity() && client->isOnActiveOutput())) {
continue;
}
if (client->frameGeometry().contains(Cursors::self()->mouse()->pos())) {
if (!client->isDesktop())
if (!client->isDesktop()) {
return client;
}
break; // unconditional break - we do not pass the focus to some client below an unusable one
}
}
@ -1139,13 +1171,15 @@ void Workspace::updateCurrentActivity(const QString &new_activity)
if (!c) {
continue;
}
if (c->isOnActivity(new_activity))
if (c->isOnActivity(new_activity)) {
c->updateVisibility();
}
}
// FIXME not sure if I should do this either
if (showingDesktop()) // Do this only after desktop change to avoid flicker
if (showingDesktop()) { // Do this only after desktop change to avoid flicker
setShowingDesktop(false);
}
// Restore the focus on this desktop
--block_focus;
@ -1160,16 +1194,19 @@ void Workspace::updateCurrentActivity(const QString &new_activity)
c = FocusChain::self()->getForActivation(VirtualDesktopManager::self()->currentDesktop());
}
if (!c)
if (!c) {
c = findDesktop(true, VirtualDesktopManager::self()->currentDesktop());
}
if (c != active_client)
if (c != active_client) {
setActiveClient(nullptr);
}
if (c)
if (c) {
requestFocus(c);
else
} else {
focusToNull();
}
Q_EMIT currentActivityChanged();
#else
@ -1255,29 +1292,34 @@ void Workspace::selectWmInputEventMask()
*/
void Workspace::sendClientToDesktop(AbstractClient *c, int desk, bool dont_activate)
{
if ((desk < 1 && desk != NET::OnAllDesktops) || desk > static_cast<int>(VirtualDesktopManager::self()->count()))
if ((desk < 1 && desk != NET::OnAllDesktops) || desk > static_cast<int>(VirtualDesktopManager::self()->count())) {
return;
}
int old_desktop = c->desktop();
const bool wasOnCurrent = c->isOnCurrentDesktop();
c->setDesktop(desk);
if (c->desktop() != desk) // No change or desktop forced
if (c->desktop() != desk) { // No change or desktop forced
return;
}
desk = c->desktop(); // Client did range checking
if (c->isOnCurrentDesktop()) {
if (c->wantsTabFocus() && options->focusPolicyIsReasonable() && !wasOnCurrent && // for stickyness changes
!dont_activate)
!dont_activate) {
requestFocus(c);
else
} else {
restackClientUnderActive(c);
} else
}
} else {
raiseClient(c);
}
c->checkWorkspacePosition(QRect(), VirtualDesktopManager::self()->desktopForX11Id(old_desktop));
auto transients_stacking_order = ensureStackingOrder(c->transients());
for (auto it = transients_stacking_order.constBegin(); it != transients_stacking_order.constEnd(); ++it)
for (auto it = transients_stacking_order.constBegin(); it != transients_stacking_order.constEnd(); ++it) {
sendClientToDesktop(*it, desk, dont_activate);
}
updateClientArea();
}
@ -1376,8 +1418,9 @@ void Workspace::setShowingDesktop(bool showing)
} else if (c->isDesktop() && c->isShown()) {
c->updateLayer();
lowerClient(c);
if (!topDesk)
if (!topDesk) {
topDesk = c;
}
if (auto group = c->group()) {
const auto members = group->members();
for (X11Client *cm : members) {
@ -1397,14 +1440,16 @@ void Workspace::setShowingDesktop(bool showing)
activateClient(client);
}
}
if (changed)
if (changed) {
Q_EMIT showingDesktopChanged(showing);
}
}
void Workspace::disableGlobalShortcutsForClient(bool disable)
{
if (global_shortcuts_disabled_for_client == disable)
if (global_shortcuts_disabled_for_client == disable) {
return;
}
QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kglobalaccel"),
QStringLiteral("/kglobalaccel"),
QStringLiteral("org.kde.KGlobalAccel"),
@ -1414,8 +1459,9 @@ void Workspace::disableGlobalShortcutsForClient(bool disable)
global_shortcuts_disabled_for_client = disable;
// Update also Meta+LMB actions etc.
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it)
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it) {
(*it)->updateMouseGrab();
}
}
QString Workspace::supportInformation() const
@ -1550,10 +1596,11 @@ QString Workspace::supportInformation() const
support.append(QStringLiteral("no\n"));
}
support.append(QStringLiteral("Active screen follows mouse: "));
if (options->activeMouseScreen())
if (options->activeMouseScreen()) {
support.append(QStringLiteral(" yes\n"));
else
} else {
support.append(QStringLiteral(" no\n"));
}
const QVector<AbstractOutput *> outputs = kwinApp()->platform()->enabledOutputs();
support.append(QStringLiteral("Number of Screens: %1\n\n").arg(outputs.count()));
for (int i = 0; i < outputs.count(); ++i) {
@ -1616,26 +1663,32 @@ QString Workspace::supportInformation() const
}
support.append(QStringLiteral("\n"));
if (platform->supports(LimitedGLSL) || platform->supports(GLSL))
if (platform->supports(LimitedGLSL) || platform->supports(GLSL)) {
support.append(QStringLiteral("OpenGL shading language version string: ") + QString::fromUtf8(platform->glShadingLanguageVersionString()) + QStringLiteral("\n"));
}
support.append(QStringLiteral("Driver: ") + GLPlatform::driverToString(platform->driver()) + QStringLiteral("\n"));
if (!platform->isMesaDriver())
if (!platform->isMesaDriver()) {
support.append(QStringLiteral("Driver version: ") + GLPlatform::versionToString(platform->driverVersion()) + QStringLiteral("\n"));
}
support.append(QStringLiteral("GPU class: ") + GLPlatform::chipClassToString(platform->chipClass()) + QStringLiteral("\n"));
support.append(QStringLiteral("OpenGL version: ") + GLPlatform::versionToString(platform->glVersion()) + QStringLiteral("\n"));
if (platform->supports(LimitedGLSL) || platform->supports(GLSL))
if (platform->supports(LimitedGLSL) || platform->supports(GLSL)) {
support.append(QStringLiteral("GLSL version: ") + GLPlatform::versionToString(platform->glslVersion()) + QStringLiteral("\n"));
}
if (platform->isMesaDriver())
if (platform->isMesaDriver()) {
support.append(QStringLiteral("Mesa version: ") + GLPlatform::versionToString(platform->mesaVersion()) + QStringLiteral("\n"));
if (platform->serverVersion() > 0)
}
if (platform->serverVersion() > 0) {
support.append(QStringLiteral("X server version: ") + GLPlatform::versionToString(platform->serverVersion()) + QStringLiteral("\n"));
if (platform->kernelVersion() > 0)
}
if (platform->kernelVersion() > 0) {
support.append(QStringLiteral("Linux kernel version: ") + GLPlatform::versionToString(platform->kernelVersion()) + QStringLiteral("\n"));
}
support.append(QStringLiteral("Direct rendering: "));
support.append(QStringLiteral("Requires strict binding: "));
@ -1902,9 +1955,11 @@ void Workspace::removeInternalClient(InternalClient *client)
Group *Workspace::findGroup(xcb_window_t leader) const
{
Q_ASSERT(leader != XCB_WINDOW_NONE);
for (auto it = groups.constBegin(); it != groups.constEnd(); ++it)
if ((*it)->leader() == leader)
for (auto it = groups.constBegin(); it != groups.constEnd(); ++it) {
if ((*it)->leader() == leader) {
return *it;
}
}
return nullptr;
}
@ -1914,12 +1969,13 @@ Group *Workspace::findClientLeaderGroup(const X11Client *c) const
{
Group *ret = nullptr;
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it) {
if (*it == c)
if (*it == c) {
continue;
}
if ((*it)->wmClientLeader() == c->wmClientLeader()) {
if (ret == nullptr || ret == (*it)->group())
if (ret == nullptr || ret == (*it)->group()) {
ret = (*it)->group();
else {
} else {
// There are already two groups with the same client leader.
// This most probably means the app uses group transients without
// setting group for its windows. Merging the two groups is a bad
@ -1928,8 +1984,9 @@ Group *Workspace::findClientLeaderGroup(const X11Client *c) const
// old_group autodeletes when being empty
for (int pos = 0; pos < old_group.count(); ++pos) {
X11Client *tmp = old_group[pos];
if (tmp != c)
if (tmp != c) {
tmp->changeClientLeaderGroup(ret);
}
}
}
}
@ -1942,8 +1999,9 @@ void Workspace::updateMinimizedOfTransients(AbstractClient *c)
// if mainwindow is minimized or shaded, minimize transients too
if (c->isMinimized()) {
for (auto it = c->transients().constBegin(); it != c->transients().constEnd(); ++it) {
if ((*it)->isModal())
if ((*it)->isModal()) {
continue; // there's no reason to hide modal dialogs with the main client
}
// but to keep them to eg. watch progress or whatever
if (!(*it)->isMinimized()) {
(*it)->minimize();
@ -1979,16 +2037,18 @@ void Workspace::updateMinimizedOfTransients(AbstractClient *c)
void Workspace::updateOnAllDesktopsOfTransients(AbstractClient *c)
{
for (auto it = c->transients().constBegin(); it != c->transients().constEnd(); ++it) {
if ((*it)->isOnAllDesktops() != c->isOnAllDesktops())
if ((*it)->isOnAllDesktops() != c->isOnAllDesktops()) {
(*it)->setOnAllDesktops(c->isOnAllDesktops());
}
}
}
// A new window has been mapped. Check if it's not a mainwindow for some already existing transient window.
void Workspace::checkTransients(xcb_window_t w)
{
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it)
for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it) {
(*it)->checkTransient(w);
}
}
/**
@ -2254,10 +2314,11 @@ QRect Workspace::clientArea(clientAreaOption opt, const AbstractOutput *output,
case ScreenArea:
return effectiveOutput->geometry();
case WorkArea:
if (is_multihead)
if (is_multihead) {
return screenArea;
else
} else {
return workArea;
}
case FullArea:
return QRect(QPoint(0, 0), m_geometry.size());
@ -2458,18 +2519,24 @@ QPoint Workspace::adjustClientPosition(AbstractClient *c, QPoint pos, bool unres
int snap = options->windowSnapZone() * snapAdjust;
if (snap) {
for (auto l = m_allClients.constBegin(); l != m_allClients.constEnd(); ++l) {
if ((*l) == c)
if ((*l) == c) {
continue;
if ((*l)->isMinimized() || (*l)->isShade())
}
if ((*l)->isMinimized() || (*l)->isShade()) {
continue;
if (!(*l)->isShown())
}
if (!(*l)->isShown()) {
continue;
if (!(*l)->isOnCurrentDesktop())
}
if (!(*l)->isOnCurrentDesktop()) {
continue; // wrong virtual desktop
if (!(*l)->isOnCurrentActivity())
}
if (!(*l)->isOnCurrentActivity()) {
continue; // wrong activity
if ((*l)->isDesktop() || (*l)->isSplash() || (*l)->isNotification() || (*l)->isCriticalNotification() || (*l)->isOnScreenDisplay())
}
if ((*l)->isDesktop() || (*l)->isSplash() || (*l)->isNotification() || (*l)->isCriticalNotification() || (*l)->isOnScreenDisplay()) {
continue;
}
lx = (*l)->x();
ly = (*l)->y();
@ -2791,10 +2858,11 @@ void Workspace::setMoveResizeClient(AbstractClient *c)
Q_ASSERT(!c || !movingClient); // Catch attempts to move a second
// window while still moving the first one.
movingClient = c;
if (movingClient)
if (movingClient) {
++block_focus;
else
} else {
--block_focus;
}
}
// When kwin crashes, windows will not be gravitated back to their original position

File diff suppressed because it is too large Load Diff

View File

@ -1632,10 +1632,12 @@ void XdgToplevelClient::changeMaximize(bool horizontal, bool vertical, bool adju
// 'adjust == true' means to update the size only, e.g. after changing workspace size
if (!adjust) {
if (vertical)
if (vertical) {
m_requestedMaximizeMode = MaximizeMode(m_requestedMaximizeMode ^ MaximizeVertical);
if (horizontal)
}
if (horizontal) {
m_requestedMaximizeMode = MaximizeMode(m_requestedMaximizeMode ^ MaximizeHorizontal);
}
}
m_requestedMaximizeMode = rules()->checkMaximize(m_requestedMaximizeMode);