Changeset View
Changeset View
Standalone View
Standalone View
composite.cpp
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Line(s) | 166 | if (qEnvironmentVariableIsSet("KWIN_MAX_FRAMES_TESTED")) | |||
---|---|---|---|---|---|
167 | m_framesToTestForSafety = qEnvironmentVariableIntValue("KWIN_MAX_FRAMES_TESTED"); | 167 | m_framesToTestForSafety = qEnvironmentVariableIntValue("KWIN_MAX_FRAMES_TESTED"); | ||
168 | 168 | | |||
169 | // register DBus | 169 | // register DBus | ||
170 | new CompositorDBusInterface(this); | 170 | new CompositorDBusInterface(this); | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | Compositor::~Compositor() | 173 | Compositor::~Compositor() | ||
174 | { | 174 | { | ||
175 | emit aboutToDestroy(); | | |||
176 | stop(); | | |||
177 | deleteUnusedSupportProperties(); | | |||
178 | destroyCompositorSelection(); | | |||
179 | s_compositor = NULL; | 175 | s_compositor = NULL; | ||
180 | } | 176 | } | ||
181 | 177 | | |||
182 | bool Compositor::setupStart() | 178 | bool Compositor::setupStart() | ||
183 | { | 179 | { | ||
184 | if (kwinApp()->isTerminating()) { | 180 | if (kwinApp()->isTerminating()) { | ||
185 | // Don't start while KWin is terminating. An event to restart might be lingering | 181 | // Don't start while KWin is terminating. An event to restart might be lingering | ||
186 | // in the event queue due to graphics reset. | 182 | // in the event queue due to graphics reset. | ||
▲ Show 20 Lines • Show All 663 Lines • ▼ Show 20 Line(s) | |||||
850 | 846 | | |||
851 | WaylandCompositor::WaylandCompositor(QObject *parent) | 847 | WaylandCompositor::WaylandCompositor(QObject *parent) | ||
852 | : Compositor(parent) | 848 | : Compositor(parent) | ||
853 | { | 849 | { | ||
854 | connect(kwinApp(), &Application::x11ConnectionAboutToBeDestroyed, | 850 | connect(kwinApp(), &Application::x11ConnectionAboutToBeDestroyed, | ||
855 | this, &WaylandCompositor::destroyCompositorSelection); | 851 | this, &WaylandCompositor::destroyCompositorSelection); | ||
856 | } | 852 | } | ||
857 | 853 | | |||
854 | WaylandCompositor::~WaylandCompositor() | ||||
855 | { | ||||
856 | emit aboutToDestroy(); | ||||
857 | stop(); | ||||
858 | deleteUnusedSupportProperties(); | ||||
859 | destroyCompositorSelection(); | ||||
860 | } | ||||
861 | | ||||
858 | void WaylandCompositor::toggleCompositing() | 862 | void WaylandCompositor::toggleCompositing() | ||
859 | { | 863 | { | ||
860 | // For the shortcut. Not possible on Wayland because we always composite. | 864 | // For the shortcut. Not possible on Wayland because we always composite. | ||
861 | } | 865 | } | ||
862 | 866 | | |||
863 | void WaylandCompositor::start() | 867 | void WaylandCompositor::start() | ||
864 | { | 868 | { | ||
865 | if (!Compositor::setupStart()) { | 869 | if (!Compositor::setupStart()) { | ||
Show All 38 Lines | |||||
904 | X11Compositor::X11Compositor(QObject *parent) | 908 | X11Compositor::X11Compositor(QObject *parent) | ||
905 | : Compositor(parent) | 909 | : Compositor(parent) | ||
906 | , m_suspended(options->isUseCompositing() ? NoReasonSuspend : UserSuspend) | 910 | , m_suspended(options->isUseCompositing() ? NoReasonSuspend : UserSuspend) | ||
907 | , m_xrrRefreshRate(0) | 911 | , m_xrrRefreshRate(0) | ||
908 | { | 912 | { | ||
909 | qRegisterMetaType<X11Compositor::SuspendReason>("X11Compositor::SuspendReason"); | 913 | qRegisterMetaType<X11Compositor::SuspendReason>("X11Compositor::SuspendReason"); | ||
910 | } | 914 | } | ||
911 | 915 | | |||
916 | X11Compositor::~X11Compositor() | ||||
917 | { | ||||
918 | emit aboutToDestroy(); | ||||
919 | stop(); | ||||
920 | deleteUnusedSupportProperties(); | ||||
921 | destroyCompositorSelection(); | ||||
922 | } | ||||
923 | | ||||
912 | void X11Compositor::toggleCompositing() | 924 | void X11Compositor::toggleCompositing() | ||
913 | { | 925 | { | ||
914 | if (m_suspended) { | 926 | if (m_suspended) { | ||
915 | // Direct user call; clear all bits. | 927 | // Direct user call; clear all bits. | ||
916 | resume(AllReasonSuspend); | 928 | resume(AllReasonSuspend); | ||
917 | } else { | 929 | } else { | ||
918 | // But only set the user one (sufficient to suspend). | 930 | // But only set the user one (sufficient to suspend). | ||
919 | suspend(UserSuspend); | 931 | suspend(UserSuspend); | ||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 1070 | if (resume) { | |||
1060 | QMetaObject::invokeMethod(this, "resume", Qt::QueuedConnection, | 1072 | QMetaObject::invokeMethod(this, "resume", Qt::QueuedConnection, | ||
1061 | Q_ARG(SuspendReason, BlockRuleSuspend)); | 1073 | Q_ARG(SuspendReason, BlockRuleSuspend)); | ||
1062 | } | 1074 | } | ||
1063 | } | 1075 | } | ||
1064 | } | 1076 | } | ||
1065 | 1077 | | |||
1066 | } | 1078 | } | ||
1067 | 1079 | | |||
1068 | // included for CompositorSelectionOwner | 1080 | // included for CompositorSelectionOwner | ||
anthonyfieroni: qobject_cast is slower in some cases can you do it
```
static QPointer<X11Compositor> x11;
if (! | |||||
zzag: > qobject_cast is slower in some cases
When? | |||||
Also static in a method or a function means taking a lock on a mutex... Performance impact won't be huge, but still... zzag: Also `static` in a method or a function means taking a lock on a mutex... Performance impact… | |||||
Being at construction time is no-op, cannot compare to qt cast. At least one commit in this repo is removing of qobject_cast being slow in drawing. anthonyfieroni: Being at construction time is no-op, cannot compare to qt cast. At least one commit in this… | |||||
zzag: Which commit? | |||||
I can't imagine it making a big difference. For now we only need it in two setup functions being called not regularly. But do you have some data on the difference in performance? If it's called more often in the future it might be an idea to benchmark it. romangg: I can't imagine it making a big difference. For now we only need it in two setup functions… | |||||
1069 | #include "composite.moc" | 1081 | #include "composite.moc" |
qobject_cast is slower in some cases can you do it