Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Unmaintained
KDE Workspace
Commits
8efb02e7
Commit
8efb02e7
authored
Feb 27, 2011
by
Thomas Lübking
Browse files
unify composite activation, 'Enable' only controls initial state
parent
0653f49c
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
kwin/composite.cpp
View file @
8efb02e7
...
...
@@ -89,39 +89,16 @@ void Workspace::setupCompositing()
#ifdef KWIN_HAVE_COMPOSITING
if
(
scene
!=
NULL
)
return
;
if
(
!
options
->
useCompositing
&&
getenv
(
"KWIN_COMPOSE"
)
==
NULL
)
{
kDebug
(
1212
)
<<
"Compositing is turned off in options or disabled"
;
return
;
}
else
if
(
compositingSuspended
)
{
if
(
compositingSuspended
)
{
kDebug
(
1212
)
<<
"Compositing is suspended"
;
return
;
}
else
if
(
!
CompositingPrefs
::
compositingPossible
())
{
kError
(
1212
)
<<
"Compositing is not possible"
;
return
;
}
CompositingType
type
=
options
->
compositingMode
;
if
(
getenv
(
"KWIN_COMPOSE"
))
{
char
c
=
getenv
(
"KWIN_COMPOSE"
)[
0
];
switch
(
c
)
{
case
'O'
:
kDebug
(
1212
)
<<
"Compositing forced to OpenGL mode by environment variable"
;
type
=
OpenGLCompositing
;
break
;
case
'X'
:
kDebug
(
1212
)
<<
"Compositing forced to XRender mode by environment variable"
;
type
=
XRenderCompositing
;
break
;
case
'N'
:
if
(
getenv
(
"KDE_FAILSAFE"
))
kDebug
(
1212
)
<<
"Compositing disabled forcefully by KDE failsafe mode"
;
else
kDebug
(
1212
)
<<
"Compositing disabled forcefully by environment variable"
;
return
;
// Return not break
default:
kDebug
(
1212
)
<<
"Unknown KWIN_COMPOSE mode set, ignoring"
;
break
;
}
}
if
(
!
options
->
compositingInitialized
)
options
->
reloadCompositingSettings
(
true
);
char
selection_name
[
100
];
sprintf
(
selection_name
,
"_NET_WM_CM_S%d"
,
DefaultScreen
(
display
()));
...
...
@@ -129,7 +106,7 @@ void Workspace::setupCompositing()
connect
(
cm_selection
,
SIGNAL
(
lostOwnership
()),
SLOT
(
lostCMSelection
()));
cm_selection
->
claim
(
true
);
// force claiming
switch
(
typ
e
)
{
switch
(
options
->
compositingMod
e
)
{
/*case 'B':
kDebug( 1212 ) << "X compositing";
scene = new SceneBasic( this );
...
...
@@ -295,7 +272,7 @@ void Workspace::toggleCompositing()
QString
shortcut
,
message
;
if
(
KAction
*
action
=
qobject_cast
<
KAction
*>
(
keys
->
action
(
"Suspend Compositing"
)))
shortcut
=
action
->
globalShortcut
().
primary
().
toString
(
QKeySequence
::
NativeText
);
if
(
!
shortcut
.
isEmpty
()
&&
options
->
useCompositing
)
{
if
(
!
shortcut
.
isEmpty
())
{
// display notification only if there is the shortcut
message
=
i18n
(
"Desktop effects have been suspended by another application.<br/>"
"You can resume using the '%1' shortcut."
,
shortcut
);
...
...
kwin/kcmkwin/kwincompositing/main.cpp
View file @
8efb02e7
...
...
@@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kwin_interface.h"
#include <kaboutdata.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kdebug.h>
...
...
@@ -74,13 +76,10 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
:
KCModule
(
KWinCompositingConfigFactory
::
componentData
(),
parent
)
,
mKWinConfig
(
KSharedConfig
::
openConfig
(
"kwinrc"
))
,
m_showConfirmDialog
(
false
)
,
kwinInterface
(
NULL
)
{
KGlobal
::
locale
()
->
insertCatalog
(
"kwin_effects"
);
ui
.
setupUi
(
this
);
layout
()
->
setMargin
(
0
);
ui
.
verticalSpacer
->
changeSize
(
20
,
KDialog
::
groupSpacingHint
());
ui
.
verticalSpacer_2
->
changeSize
(
20
,
KDialog
::
groupSpacingHint
());
ui
.
tabWidget
->
setCurrentIndex
(
0
);
ui
.
statusTitleWidget
->
hide
();
...
...
@@ -101,9 +100,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
#define XRENDER_INDEX -1
#endif
kwinInterface
=
new
OrgKdeKWinInterface
(
"org.kde.kwin"
,
"/KWin"
,
QDBusConnection
::
sessionBus
());
connect
(
ui
.
useCompositing
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
compositingEnabled
(
bool
)));
connect
(
ui
.
tabWidget
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
currentTabChanged
(
int
)));
connect
(
ui
.
useCompositing
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
changed
()));
...
...
@@ -128,8 +124,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
connect
(
ui
.
glDirect
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
changed
()));
connect
(
ui
.
glVSync
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
changed
()));
connect
(
ui
.
compositingStateButton
,
SIGNAL
(
clicked
(
bool
)),
kwinInterface
,
SLOT
(
toggleCompositing
()));
connect
(
kwinInterface
,
SIGNAL
(
compositingToggled
(
bool
)),
this
,
SLOT
(
setupCompositingState
(
bool
)));
// Open the temporary config file
// Temporary conf file is used to synchronize effect checkboxes with effect
...
...
@@ -138,6 +132,16 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
mTmpConfigFile
.
open
();
mTmpConfig
=
KSharedConfig
::
openConfig
(
mTmpConfigFile
.
fileName
());
// toggle effects shortcut button stuff - /HAS/ to happen before load!
m_actionCollection
=
new
KActionCollection
(
this
,
KComponentData
(
"kwin"
)
);
m_actionCollection
->
setConfigGroup
(
"Suspend Compositing"
);
m_actionCollection
->
setConfigGlobal
(
true
);
KAction
*
a
=
static_cast
<
KAction
*>
(
m_actionCollection
->
addAction
(
"Suspend Compositing"
));
a
->
setProperty
(
"isConfigurationAction"
,
true
);
a
->
setGlobalShortcut
(
KShortcut
(
Qt
::
ALT
+
Qt
::
SHIFT
+
Qt
::
Key_F12
));
connect
(
ui
.
toggleEffectsShortcut
,
SIGNAL
(
keySequenceChanged
(
const
QKeySequence
&
)),
this
,
SLOT
(
toggleEffectShortcutChanged
(
const
QKeySequence
&
)));
// NOTICE: this is intended to workaround broken GL implementations that successfully segfault on glXQuery :-(
KConfigGroup
unsafeConfig
(
mKWinConfig
,
"Compositing"
);
const
bool
glUnsafe
=
unsafeConfig
.
readEntry
(
"OpenGLIsUnsafe"
,
false
);
...
...
@@ -158,7 +162,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
ui
.
useCompositing
->
setEnabled
(
false
);
ui
.
useCompositing
->
setChecked
(
false
);
compositingEnabled
(
false
);
QString
text
=
i18n
(
"Desktop effects are not available on this system due to the following technical issues:"
);
text
+=
"<br>"
;
...
...
@@ -166,8 +169,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
ui
.
statusTitleWidget
->
setText
(
text
);
ui
.
statusTitleWidget
->
setPixmap
(
KTitleWidget
::
InfoMessage
,
KTitleWidget
::
ImageLeft
);
ui
.
statusTitleWidget
->
show
();
setupCompositingState
(
false
,
false
);
}
KAboutData
*
about
=
new
KAboutData
(
I18N_NOOP
(
"kcmkwincompositing"
),
0
,
...
...
@@ -225,14 +226,6 @@ void KWinCompositingConfig::reparseConfiguration(const QByteArray& conf)
KSettings
::
Dispatcher
::
reparseConfiguration
(
conf
);
}
void
KWinCompositingConfig
::
compositingEnabled
(
bool
enabled
)
{
// Enable the other configuration tabs only when compositing is enabled.
ui
.
compositingOptionsContainer
->
setEnabled
(
enabled
);
ui
.
tabWidget
->
setTabEnabled
(
1
,
enabled
);
ui
.
tabWidget
->
setTabEnabled
(
2
,
enabled
);
}
void
KWinCompositingConfig
::
showConfirmDialog
(
bool
reinitCompositing
)
{
bool
revert
=
false
;
...
...
@@ -252,7 +245,6 @@ void KWinCompositingConfig::showConfirmDialog(bool reinitCompositing)
revert
=
true
;
else
{
// compositing is enabled now
setupCompositingState
(
kwinInterface
->
compositingActive
());
checkLoadedEffects
();
}
}
...
...
@@ -315,6 +307,12 @@ void KWinCompositingConfig::loadGeneralTab()
KConfigGroup
config
(
mKWinConfig
,
"Compositing"
);
bool
enabled
=
config
.
readEntry
(
"Enabled"
,
mDefaultPrefs
.
recommendCompositing
());
ui
.
useCompositing
->
setChecked
(
enabled
);
// this works by global shortcut magics - it will pick the current sc
// but the constructor line that adds the default alt+shift+f12 gsc is IMPORTANT!
if
(
KAction
*
a
=
qobject_cast
<
KAction
*>
(
m_actionCollection
->
action
(
"Suspend Compositing"
)))
ui
.
toggleEffectsShortcut
->
setKeySequence
(
a
->
globalShortcut
().
primary
());
ui
.
animationSpeedCombo
->
setCurrentIndex
(
config
.
readEntry
(
"AnimationSpeed"
,
3
));
// Load effect settings
...
...
@@ -356,46 +354,8 @@ void KWinCompositingConfig::loadGeneralTab()
ui
.
desktopSwitchingCombo
->
setCurrentIndex
(
2
);
if
(
effectEnabled
(
"fadedesktop"
,
effectconfig
))
ui
.
desktopSwitchingCombo
->
setCurrentIndex
(
3
);
if
(
enabled
)
setupCompositingState
(
kwinInterface
->
compositingActive
());
else
setupCompositingState
(
false
,
false
);
}
void
KWinCompositingConfig
::
setupCompositingState
(
bool
active
,
bool
enabled
)
{
if
(
!
qgetenv
(
"KDE_FAILSAFE"
).
isNull
())
enabled
=
false
;
// compositing state
QString
stateIcon
;
QString
stateText
;
QString
stateButtonText
;
if
(
enabled
)
{
// check if compositing is active or suspended
if
(
active
)
{
stateIcon
=
QString
(
"dialog-ok-apply"
);
stateText
=
i18n
(
"Desktop effects are active"
);
stateButtonText
=
i18n
(
"Suspend Desktop Effects"
);
}
else
{
stateIcon
=
QString
(
"dialog-cancel"
);
stateText
=
i18n
(
"Desktop effects are temporarily disabled"
);
stateButtonText
=
i18n
(
"Resume Desktop Effects"
);
}
}
else
{
// compositing is disabled
stateIcon
=
QString
(
"dialog-cancel"
);
stateText
=
i18n
(
"Desktop effects are disabled"
);
stateButtonText
=
i18n
(
"Resume Desktop Effects"
);
}
const
int
iconSize
=
(
QApplication
::
fontMetrics
().
height
()
>
24
)
?
32
:
22
;
ui
.
compositingStateIcon
->
setPixmap
(
KIcon
(
stateIcon
).
pixmap
(
iconSize
,
iconSize
));
ui
.
compositingStateLabel
->
setText
(
stateText
);
ui
.
compositingStateButton
->
setText
(
stateButtonText
);
ui
.
compositingStateIcon
->
setEnabled
(
enabled
);
ui
.
compositingStateLabel
->
setEnabled
(
enabled
);
ui
.
compositingStateButton
->
setEnabled
(
enabled
);
}
void
KWinCompositingConfig
::
toogleSmoothScaleUi
(
int
compositingType
)
{
...
...
@@ -404,6 +364,13 @@ void KWinCompositingConfig::toogleSmoothScaleUi(int compositingType)
ui
.
scaleMethodLabel
->
setBuddy
(
compositingType
==
XRENDER_INDEX
?
ui
.
xrScaleFilter
:
ui
.
glScaleFilter
);
}
void
KWinCompositingConfig
::
toggleEffectShortcutChanged
(
const
QKeySequence
&
seq
)
{
if
(
KAction
*
a
=
qobject_cast
<
KAction
*>
(
m_actionCollection
->
action
(
"Suspend Compositing"
)))
a
->
setGlobalShortcut
(
KShortcut
(
seq
),
KAction
::
ActiveShortcut
,
KAction
::
NoAutoloading
);
m_actionCollection
->
writeSettings
();
}
bool
KWinCompositingConfig
::
effectEnabled
(
const
QString
&
effect
,
const
KConfigGroup
&
cfg
)
const
{
KService
::
List
services
=
KServiceTypeTrader
::
self
()
->
query
(
...
...
@@ -467,17 +434,9 @@ void KWinCompositingConfig::saveGeneralTab()
{
KConfigGroup
config
(
mKWinConfig
,
"Compositing"
);
// Check if any critical settings that need confirmation have changed
if
(
ui
.
useCompositing
->
isChecked
()
&&
ui
.
useCompositing
->
isChecked
()
!=
config
.
readEntry
(
"Enabled"
,
mDefaultPrefs
.
recommendCompositing
()))
m_showConfirmDialog
=
true
;
config
.
writeEntry
(
"Enabled"
,
ui
.
useCompositing
->
isChecked
());
config
.
writeEntry
(
"AnimationSpeed"
,
ui
.
animationSpeedCombo
->
currentIndex
());
// disable the compositing state if compositing was turned off
if
(
!
ui
.
useCompositing
->
isChecked
())
setupCompositingState
(
false
,
false
);
// Save effects
KConfigGroup
effectconfig
(
mTmpConfig
,
"Plugins"
);
#define WRITE_EFFECT_CONFIG(effectname, widget) effectconfig.writeEntry("kwin4_effect_" effectname "Enabled", widget->isChecked())
...
...
kwin/kcmkwin/kwincompositing/main.h
View file @
8efb02e7
...
...
@@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "ktimerdialog.h"
class
KPluginSelector
;
class
KActionCollection
;
class
QLabel
;
namespace
KWin
...
...
@@ -55,7 +56,6 @@ public:
virtual
QString
quickHelp
()
const
;
public
slots
:
virtual
void
compositingEnabled
(
bool
enabled
);
virtual
void
showConfirmDialog
(
bool
reinitCompositing
);
void
currentTabChanged
(
int
tab
);
...
...
@@ -74,10 +74,10 @@ public slots:
void
checkLoadedEffects
();
void
configChanged
(
bool
reinitCompositing
);
void
initEffectSelector
();
void
setupCompositingState
(
bool
active
,
bool
enabled
=
true
);
private
slots
:
void
toogleSmoothScaleUi
(
int
compositingType
);
void
toggleEffectShortcutChanged
(
const
QKeySequence
&
seq
);
private:
bool
effectEnabled
(
const
QString
&
effect
,
const
KConfigGroup
&
cfg
)
const
;
...
...
@@ -90,8 +90,7 @@ private:
KTemporaryFile
mTmpConfigFile
;
KSharedConfigPtr
mTmpConfig
;
bool
m_showConfirmDialog
;
OrgKdeKWinInterface
*
kwinInterface
;
KActionCollection
*
m_actionCollection
;
};
}
// namespace
...
...
kwin/kcmkwin/kwincompositing/main.ui
View file @
8efb02e7
This diff is collapsed.
Click to expand it.
kwin/options.cpp
View file @
8efb02e7
...
...
@@ -98,6 +98,7 @@ Options::Options()
:
electric_borders
(
0
)
,
electric_border_delay
(
0
)
{
compositingInitialized
=
false
;
updateSettings
();
}
...
...
@@ -264,39 +265,67 @@ FIXME: we have no mac style menu implementation in kwin anymore, so this just br
// KDE4 this probably needs to be done manually in clients
// Driver-specific config detection
compositingInitialized
=
false
;
reloadCompositingSettings
();
return
changed
;
}
void
Options
::
reloadCompositingSettings
()
void
Options
::
reloadCompositingSettings
(
bool
force
)
{
KSharedConfig
::
Ptr
_config
=
KGlobal
::
config
();
KConfigGroup
config
(
_config
,
"Compositing"
);
// do not even detect compositing preferences if explicitly disabled
bool
environmentForce
=
false
;
if
(
getenv
(
"KWIN_COMPOSE"
))
{
// if compositing is enforced by the environment variable, the preferences have to be read
const
char
c
=
getenv
(
"KWIN_COMPOSE"
)[
0
];
if
(
c
==
'X'
||
c
==
'O'
)
environmentForce
=
true
;
}
if
(
config
.
hasKey
(
"Enabled"
)
&&
!
config
.
readEntry
(
"Enabled"
,
true
)
&&
!
environmentForce
)
{
useCompositing
=
false
;
return
;
QString
compositingBackend
=
config
.
readEntry
(
"Backend"
,
"OpenGL"
);
if
(
compositingBackend
==
"XRender"
)
compositingMode
=
XRenderCompositing
;
else
compositingMode
=
OpenGLCompositing
;
useCompositing
=
false
;
if
(
const
char
*
c
=
getenv
(
"KWIN_COMPOSE"
))
{
switch
(
c
[
0
])
{
case
'O'
:
kDebug
(
1212
)
<<
"Compositing forced to OpenGL mode by environment variable"
;
compositingMode
=
OpenGLCompositing
;
useCompositing
=
true
;
break
;
case
'X'
:
kDebug
(
1212
)
<<
"Compositing forced to XRender mode by environment variable"
;
compositingMode
=
XRenderCompositing
;
useCompositing
=
true
;
break
;
case
'N'
:
if
(
getenv
(
"KDE_FAILSAFE"
))
kDebug
(
1212
)
<<
"Compositing disabled forcefully by KDE failsafe mode"
;
else
kDebug
(
1212
)
<<
"Compositing disabled forcefully by environment variable"
;
compositingMode
=
NoCompositing
;
break
;
default:
kDebug
(
1212
)
<<
"Unknown KWIN_COMPOSE mode set, ignoring"
;
break
;
}
}
if
(
compositingMode
==
NoCompositing
)
return
;
// do not even detect compositing preferences if explicitly disabled
// it's either enforced by env or by initial resume from "suspend" or we check the settings
useCompositing
=
useCompositing
||
force
||
config
.
readEntry
(
"Enabled"
,
true
);
if
(
!
useCompositing
)
return
;
// not enforced or necessary and not "enabled" by setting
// from now on we've an initial setup and don't have to reload settigns on compositing activation
// see Workspace::setupCompositing(), composite.cpp
compositingInitialized
=
true
;
// Compositing settings
CompositingPrefs
prefs
;
prefs
.
detect
();
useCompositing
=
config
.
readEntry
(
"Enabled"
,
prefs
.
recommendCompositing
());
QString
compositingBackend
=
config
.
readEntry
(
"Backend"
,
"OpenGL"
);
if
(
compositingBackend
==
"XRender"
)
compositingMode
=
XRenderCompositing
;
else
compositingMode
=
OpenGLCompositing
;
disableCompositingChecks
=
config
.
readEntry
(
"DisableChecks"
,
false
);
glDirect
=
config
.
readEntry
(
"GLDirect"
,
prefs
.
enableDirectRendering
());
glVSync
=
config
.
readEntry
(
"GLVSync"
,
prefs
.
enableVSync
());
...
...
kwin/options.h
View file @
8efb02e7
...
...
@@ -363,9 +363,10 @@ public:
//----------------------
// Compositing settings
void
reloadCompositingSettings
(
bool
force
=
false
);
CompositingType
compositingMode
;
bool
useCompositing
;
// Separate to mode so the user can toggle
bool
compositingInitialized
;
// General preferences
HiddenPreviews
hiddenPreviews
;
...
...
@@ -431,7 +432,6 @@ private:
int
animationSpeed
;
// 0 - instant, 5 - very slow
MouseCommand
wheelToMouseCommand
(
MouseWheelCommand
com
,
int
delta
);
void
reloadCompositingSettings
();
};
extern
Options
*
options
;
...
...
kwin/scene.cpp
View file @
8efb02e7
...
...
@@ -87,7 +87,7 @@ namespace KWin
// Scene
//****************************************
Scene
*
scene
;
Scene
*
scene
=
0
;
Scene
::
Scene
(
Workspace
*
ws
)
:
wspace
(
ws
)
...
...
kwin/workspace.cpp
View file @
8efb02e7
...
...
@@ -217,6 +217,7 @@ Workspace::Workspace(bool restore)
);
Extensions
::
init
();
compositingSuspended
=
!
options
->
useCompositing
;
setupCompositing
();
// Compatibility
...
...
@@ -1100,7 +1101,7 @@ void Workspace::slotReconfigure()
updateCurrentTopMenu
();
}
if
(
options
->
useCompositing
&&
!
compositingSuspended
)
{
if
(
!
compositingSuspended
)
{
setupCompositing
();
if
(
effects
)
// setupCompositing() may fail
effects
->
reconfigure
();
...
...
@@ -1143,7 +1144,6 @@ void Workspace::slotReinitCompositing()
{
// Reparse config. Config options will be reloaded by setupCompositing()
KGlobal
::
config
()
->
reparseConfiguration
();
options
->
updateSettings
();
// Update any settings that can be set in the compositing kcm.
updateElectricBorders
();
...
...
@@ -1153,6 +1153,7 @@ void Workspace::slotReinitCompositing()
// resume compositing if suspended
compositingSuspended
=
false
;
options
->
compositingInitialized
=
false
;
setupCompositing
();
KDecorationFactory
*
factory
=
mgr
->
factory
();
factory
->
reset
(
SettingCompositing
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment