2007-04-29 21:35:43 +04:00
|
|
|
/*
|
|
|
|
* windows.cpp
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca
|
|
|
|
* Copyright (c) 2001 Waldo Bastian bastian@kde.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-06-25 15:03:18 +04:00
|
|
|
#include <config-workspace.h>
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2008-05-12 16:13:52 +04:00
|
|
|
#include <QApplication>
|
2007-04-29 21:35:43 +04:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QLabel>
|
2009-10-30 11:10:35 +03:00
|
|
|
#include <KComboBox>
|
2007-04-29 21:35:43 +04:00
|
|
|
#include <QHBoxLayout>
|
2008-08-25 06:22:56 +04:00
|
|
|
#include <QFormLayout>
|
2013-02-26 12:00:51 +04:00
|
|
|
#include <QDesktopWidget>
|
2008-02-02 23:54:19 +03:00
|
|
|
#include <QtDBus/QtDBus>
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2008-05-12 16:13:52 +04:00
|
|
|
#include <KButtonGroup>
|
2013-09-30 09:30:06 +04:00
|
|
|
#include <KDE/KConfig>
|
2013-03-07 15:55:39 +04:00
|
|
|
#include <KDE/KLocalizedString>
|
2007-04-29 21:35:43 +04:00
|
|
|
#include <kdialog.h>
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
|
|
|
|
// kwin config keywords
|
|
|
|
#define KWIN_FOCUS "FocusPolicy"
|
|
|
|
#define KWIN_PLACEMENT "Placement"
|
|
|
|
#define KWIN_GEOMETRY "GeometryTip"
|
|
|
|
#define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval"
|
|
|
|
#define KWIN_AUTORAISE "AutoRaise"
|
|
|
|
#define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval"
|
|
|
|
#define KWIN_CLICKRAISE "ClickRaise"
|
|
|
|
#define KWIN_SHADEHOVER "ShadeHover"
|
|
|
|
#define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval"
|
|
|
|
#define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel"
|
|
|
|
#define KWIN_HIDE_UTILITY "HideUtilityWindowsForInactive"
|
2009-11-17 14:25:03 +03:00
|
|
|
#define KWIN_INACTIVE_SKIP_TASKBAR "InactiveTabsSkipTaskbar"
|
2009-11-16 13:09:03 +03:00
|
|
|
#define KWIN_AUTOGROUP_SIMILAR "AutogroupSimilarWindows"
|
2009-11-17 10:51:55 +03:00
|
|
|
#define KWIN_AUTOGROUP_FOREGROUND "AutogroupInForeground"
|
2007-05-09 16:34:55 +04:00
|
|
|
#define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus"
|
|
|
|
#define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen"
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
//CT 15mar 98 - magics
|
|
|
|
#define KWM_BRDR_SNAP_ZONE "BorderSnapZone"
|
|
|
|
#define KWM_BRDR_SNAP_ZONE_DEFAULT 10
|
|
|
|
#define KWM_WNDW_SNAP_ZONE "WindowSnapZone"
|
|
|
|
#define KWM_WNDW_SNAP_ZONE_DEFAULT 10
|
2008-07-09 19:18:47 +04:00
|
|
|
#define KWM_CNTR_SNAP_ZONE "CenterSnapZone"
|
|
|
|
#define KWM_CNTR_SNAP_ZONE_DEFAULT 0
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
#define MAX_BRDR_SNAP 100
|
|
|
|
#define MAX_WNDW_SNAP 100
|
2008-07-09 19:18:47 +04:00
|
|
|
#define MAX_CNTR_SNAP 100
|
2007-04-29 21:35:43 +04:00
|
|
|
#define MAX_EDGE_RES 1000
|
|
|
|
|
2013-04-13 22:07:08 +04:00
|
|
|
#define CLICK_TO_FOCUS 0
|
|
|
|
#define FOCUS_FOLLOWS_MOUSE 2
|
|
|
|
#define FOCUS_UNDER_MOUSE 4
|
|
|
|
#define FOCUS_STRICTLY_UNDER_MOUSE 5
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
KFocusConfig::~KFocusConfig()
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
if (standAlone)
|
|
|
|
delete config;
|
|
|
|
}
|
|
|
|
|
2012-09-22 14:10:07 +04:00
|
|
|
KWinFocusConfigForm::KWinFocusConfigForm(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2012-10-28 01:11:22 +04:00
|
|
|
setupUi(parent);
|
2012-09-22 14:10:07 +04:00
|
|
|
}
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
// removed the LCD display over the slider - this is not good GUI design :) RNolden 051701
|
2013-09-30 09:29:38 +04:00
|
|
|
KFocusConfig::KFocusConfig(bool _standAlone, KConfig *_config, QWidget * parent)
|
|
|
|
: KCModule(parent), config(_config), standAlone(_standAlone)
|
2012-09-22 14:10:07 +04:00
|
|
|
, m_ui(new KWinFocusConfigForm(this))
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
connect(m_ui->focusStealing, SIGNAL(activated(int)), SLOT(changed()));
|
2013-04-13 22:07:08 +04:00
|
|
|
connect(m_ui->windowFocusPolicy, SIGNAL(valueChanged(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->windowFocusPolicy, SIGNAL(valueChanged(int)), this, SLOT(focusPolicyChanged()));
|
|
|
|
connect(m_ui->windowFocusPolicy, SIGNAL(valueChanged(int)), this, SLOT(setDelayFocusEnabled()));
|
|
|
|
connect(m_ui->windowFocusPolicy, SIGNAL(valueChanged(int)), this, SLOT(updateActiveMouseScreen()));
|
2012-09-22 14:10:07 +04:00
|
|
|
connect(m_ui->autoRaiseOn, SIGNAL(clicked()), SLOT(changed()));
|
|
|
|
connect(m_ui->autoRaiseOn, SIGNAL(toggled(bool)), SLOT(autoRaiseOnTog(bool)));
|
|
|
|
connect(m_ui->clickRaiseOn, SIGNAL(clicked()), SLOT(changed()));
|
|
|
|
connect(m_ui->autoRaise, SIGNAL(valueChanged(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->delayFocus, SIGNAL(valueChanged(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->separateScreenFocus, SIGNAL(clicked()), SLOT(changed()));
|
|
|
|
connect(m_ui->activeMouseScreen, SIGNAL(clicked()), SLOT(changed()));
|
2013-04-13 22:07:08 +04:00
|
|
|
|
|
|
|
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(updateMultiScreen()));
|
|
|
|
updateMultiScreen();
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
|
2013-04-13 22:07:08 +04:00
|
|
|
void KFocusConfig::updateMultiScreen()
|
|
|
|
{
|
|
|
|
m_ui->multiscreenBox->setVisible(QApplication::desktop()->screenCount() > 1);
|
|
|
|
}
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
int KFocusConfig::getFocus()
|
|
|
|
{
|
2013-04-13 22:07:08 +04:00
|
|
|
int policy = m_ui->windowFocusPolicy->value();
|
|
|
|
if (policy == 1 || policy == 3)
|
|
|
|
--policy; // fix the NextFocusPrefersMouse condition
|
|
|
|
return policy;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::setFocus(int foc)
|
|
|
|
{
|
2013-04-13 22:07:08 +04:00
|
|
|
m_ui->windowFocusPolicy->setValue(foc);
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// this will disable/hide the auto raise delay widget if focus==click
|
2008-09-08 01:08:26 +04:00
|
|
|
focusPolicyChanged();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::setAutoRaiseInterval(int tb)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->autoRaise->setValue(tb);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::setDelayFocusInterval(int tb)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->delayFocus->setValue(tb);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int KFocusConfig::getAutoRaiseInterval()
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
return m_ui->autoRaise->value();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int KFocusConfig::getDelayFocusInterval()
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
return m_ui->delayFocus->value();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::setAutoRaise(bool on)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->autoRaiseOn->setChecked(on);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::setClickRaise(bool on)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->clickRaiseOn->setChecked(on);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2008-09-08 01:08:26 +04:00
|
|
|
void KFocusConfig::focusPolicyChanged()
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
2013-04-13 22:07:08 +04:00
|
|
|
int policyIndex = getFocus();
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
// the auto raise related widgets are: autoRaise
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->autoRaiseOn->setEnabled(policyIndex != CLICK_TO_FOCUS);
|
|
|
|
autoRaiseOnTog(policyIndex != CLICK_TO_FOCUS && m_ui->autoRaiseOn->isChecked());
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->focusStealing->setDisabled(policyIndex == FOCUS_UNDER_MOUSE || policyIndex == FOCUS_STRICTLY_UNDER_MOUSE);
|
2013-04-13 22:07:08 +04:00
|
|
|
m_ui->focusStealingLabel->setEnabled(m_ui->focusStealing->isEnabled());
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2013-04-13 22:07:08 +04:00
|
|
|
setDelayFocusEnabled();
|
2011-08-22 15:53:03 +04:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::setDelayFocusEnabled()
|
|
|
|
{
|
2013-04-13 22:07:08 +04:00
|
|
|
int policyIndex = getFocus();
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
// the delayed focus related widgets are: delayFocus
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->delayFocusOnLabel->setEnabled(policyIndex != CLICK_TO_FOCUS);
|
2011-11-28 23:12:58 +04:00
|
|
|
delayFocusOnTog(policyIndex != CLICK_TO_FOCUS);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::autoRaiseOnTog(bool a)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->autoRaise->setEnabled(a);
|
|
|
|
m_ui->clickRaiseOn->setEnabled(!a);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::delayFocusOnTog(bool a)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->delayFocus->setEnabled(a);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::setFocusStealing(int l)
|
|
|
|
{
|
|
|
|
l = qMax(0, qMin(4, l));
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->focusStealing->setCurrentIndex(l);
|
2008-09-08 01:08:26 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::setSeparateScreenFocus(bool s)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->separateScreenFocus->setChecked(s);
|
2007-05-09 16:34:55 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::setActiveMouseScreen(bool a)
|
|
|
|
{
|
2012-09-22 14:10:07 +04:00
|
|
|
m_ui->activeMouseScreen->setChecked(a);
|
2007-05-09 16:34:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::updateActiveMouseScreen()
|
|
|
|
{
|
|
|
|
// on by default for non click to focus policies
|
2011-01-30 17:34:42 +03:00
|
|
|
KConfigGroup cfg(config, "Windows");
|
|
|
|
if (!cfg.hasKey(KWIN_ACTIVE_MOUSE_SCREEN))
|
2013-04-13 22:07:08 +04:00
|
|
|
setActiveMouseScreen(getFocus() != 0);
|
2007-05-09 16:34:55 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::showEvent(QShowEvent *ev)
|
2009-12-14 06:18:43 +03:00
|
|
|
{
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!standAlone) {
|
|
|
|
QWidget::showEvent(ev);
|
2009-12-14 06:18:43 +03:00
|
|
|
return;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
KCModule::showEvent(ev);
|
2009-12-14 06:18:43 +03:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::load(void)
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
QString key;
|
|
|
|
|
|
|
|
KConfigGroup cg(config, "Windows");
|
|
|
|
|
2013-04-13 22:07:08 +04:00
|
|
|
const bool focusNextToMouse = cg.readEntry("NextFocusPrefersMouse", false);
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
key = cg.readEntry(KWIN_FOCUS);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (key == "ClickToFocus")
|
2013-04-13 22:07:08 +04:00
|
|
|
setFocus(CLICK_TO_FOCUS + focusNextToMouse);
|
2011-01-30 17:34:42 +03:00
|
|
|
else if (key == "FocusFollowsMouse")
|
2013-04-13 22:07:08 +04:00
|
|
|
setFocus(FOCUS_FOLLOWS_MOUSE + focusNextToMouse);
|
2011-01-30 17:34:42 +03:00
|
|
|
else if (key == "FocusUnderMouse")
|
2007-04-29 21:35:43 +04:00
|
|
|
setFocus(FOCUS_UNDER_MOUSE);
|
2011-01-30 17:34:42 +03:00
|
|
|
else if (key == "FocusStrictlyUnderMouse")
|
2007-04-29 21:35:43 +04:00
|
|
|
setFocus(FOCUS_STRICTLY_UNDER_MOUSE);
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
int k = cg.readEntry(KWIN_AUTORAISE_INTERVAL, 750);
|
2007-04-29 21:35:43 +04:00
|
|
|
setAutoRaiseInterval(k);
|
|
|
|
|
2013-01-09 12:14:35 +04:00
|
|
|
k = cg.readEntry(KWIN_DELAYFOCUS_INTERVAL, 300);
|
2007-04-29 21:35:43 +04:00
|
|
|
setDelayFocusInterval(k);
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
setAutoRaise(cg.readEntry(KWIN_AUTORAISE, false));
|
|
|
|
setClickRaise(cg.readEntry(KWIN_CLICKRAISE, true));
|
2008-09-08 01:08:26 +04:00
|
|
|
focusPolicyChanged(); // this will disable/hide the auto raise delay widget if focus==click
|
2007-09-18 18:44:41 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
setSeparateScreenFocus(cg.readEntry(KWIN_SEPARATE_SCREEN_FOCUS, false));
|
2007-05-09 16:34:55 +04:00
|
|
|
// on by default for non click to focus policies
|
2013-04-13 22:07:08 +04:00
|
|
|
setActiveMouseScreen(cg.readEntry(KWIN_ACTIVE_MOUSE_SCREEN, getFocus() != 0));
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2008-09-08 01:08:26 +04:00
|
|
|
// setFocusStealing( cg.readEntry(KWIN_FOCUS_STEALING, 2 ));
|
|
|
|
// TODO default to low for now
|
2011-01-30 17:34:42 +03:00
|
|
|
setFocusStealing(cg.readEntry(KWIN_FOCUS_STEALING, 1));
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2011-08-22 15:53:03 +04:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
emit KCModule::changed(false);
|
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KFocusConfig::save(void)
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
int v;
|
|
|
|
|
|
|
|
KConfigGroup cg(config, "Windows");
|
|
|
|
|
|
|
|
v = getFocus();
|
|
|
|
if (v == CLICK_TO_FOCUS)
|
2011-01-30 17:34:42 +03:00
|
|
|
cg.writeEntry(KWIN_FOCUS, "ClickToFocus");
|
2007-04-29 21:35:43 +04:00
|
|
|
else if (v == FOCUS_UNDER_MOUSE)
|
2011-01-30 17:34:42 +03:00
|
|
|
cg.writeEntry(KWIN_FOCUS, "FocusUnderMouse");
|
2007-04-29 21:35:43 +04:00
|
|
|
else if (v == FOCUS_STRICTLY_UNDER_MOUSE)
|
2011-01-30 17:34:42 +03:00
|
|
|
cg.writeEntry(KWIN_FOCUS, "FocusStrictlyUnderMouse");
|
2007-04-29 21:35:43 +04:00
|
|
|
else
|
2011-01-30 17:34:42 +03:00
|
|
|
cg.writeEntry(KWIN_FOCUS, "FocusFollowsMouse");
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-04-13 22:07:08 +04:00
|
|
|
cg.writeEntry("NextFocusPrefersMouse", v != m_ui->windowFocusPolicy->value());
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
v = getAutoRaiseInterval();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (v < 0) v = 0;
|
|
|
|
cg.writeEntry(KWIN_AUTORAISE_INTERVAL, v);
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
v = getDelayFocusInterval();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (v < 0) v = 0;
|
|
|
|
cg.writeEntry(KWIN_DELAYFOCUS_INTERVAL, v);
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-09-22 14:10:07 +04:00
|
|
|
cg.writeEntry(KWIN_AUTORAISE, m_ui->autoRaiseOn->isChecked());
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-09-22 14:10:07 +04:00
|
|
|
cg.writeEntry(KWIN_CLICKRAISE, m_ui->clickRaiseOn->isChecked());
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-09-22 14:10:07 +04:00
|
|
|
cg.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS, m_ui->separateScreenFocus->isChecked());
|
|
|
|
cg.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN, m_ui->activeMouseScreen->isChecked());
|
2007-05-09 16:34:55 +04:00
|
|
|
|
2012-09-22 14:10:07 +04:00
|
|
|
cg.writeEntry(KWIN_FOCUS_STEALING, m_ui->focusStealing->currentIndex());
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2012-09-22 14:10:07 +04:00
|
|
|
cg.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS, m_ui->separateScreenFocus->isChecked());
|
|
|
|
cg.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN, m_ui->activeMouseScreen->isChecked());
|
2011-08-22 15:53:03 +04:00
|
|
|
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (standAlone) {
|
2007-04-29 21:35:43 +04:00
|
|
|
config->sync();
|
2011-01-30 17:34:42 +03:00
|
|
|
// Send signal to all kwin instances
|
|
|
|
QDBusMessage message =
|
|
|
|
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
emit KCModule::changed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KFocusConfig::defaults()
|
|
|
|
{
|
|
|
|
setAutoRaiseInterval(0);
|
|
|
|
setDelayFocusInterval(0);
|
|
|
|
setFocus(CLICK_TO_FOCUS);
|
|
|
|
setAutoRaise(false);
|
|
|
|
setClickRaise(true);
|
2011-01-30 17:34:42 +03:00
|
|
|
setSeparateScreenFocus(false);
|
2008-09-08 01:08:26 +04:00
|
|
|
|
|
|
|
// setFocusStealing(2);
|
|
|
|
// TODO default to low for now
|
|
|
|
setFocusStealing(1);
|
|
|
|
|
2007-05-09 16:34:55 +04:00
|
|
|
// on by default for non click to focus policies
|
2013-04-13 22:07:08 +04:00
|
|
|
setActiveMouseScreen(getFocus() != 0);
|
2007-10-26 01:12:59 +04:00
|
|
|
setDelayFocusEnabled();
|
2007-04-29 21:35:43 +04:00
|
|
|
emit KCModule::changed(true);
|
|
|
|
}
|
|
|
|
|
2012-09-24 07:57:52 +04:00
|
|
|
KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2012-10-28 01:11:22 +04:00
|
|
|
setupUi(parent);
|
2012-09-24 07:57:52 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
KAdvancedConfig::~KAdvancedConfig()
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
if (standAlone)
|
|
|
|
delete config;
|
|
|
|
}
|
|
|
|
|
2013-09-30 09:29:38 +04:00
|
|
|
KAdvancedConfig::KAdvancedConfig(bool _standAlone, KConfig *_config, QWidget *parent)
|
|
|
|
: KCModule(parent), config(_config), standAlone(_standAlone)
|
2012-09-24 07:57:52 +04:00
|
|
|
, m_ui(new KWinAdvancedConfigForm(this))
|
|
|
|
{
|
|
|
|
m_ui->placementCombo->setItemData(0, "Smart");
|
|
|
|
m_ui->placementCombo->setItemData(1, "Maximizing");
|
|
|
|
m_ui->placementCombo->setItemData(2, "Cascade");
|
|
|
|
m_ui->placementCombo->setItemData(3, "Random");
|
|
|
|
m_ui->placementCombo->setItemData(4, "Centered");
|
|
|
|
m_ui->placementCombo->setItemData(5, "ZeroCornered");
|
|
|
|
m_ui->placementCombo->setItemData(6, "UnderMouse");
|
|
|
|
|
|
|
|
connect(m_ui->shadeHoverOn, SIGNAL(toggled(bool)), this, SLOT(shadeHoverChanged(bool)));
|
|
|
|
connect(m_ui->inactiveTabsSkipTaskbar, SIGNAL(toggled(bool)), SLOT(changed()));
|
|
|
|
connect(m_ui->autogroupSimilarWindows, SIGNAL(toggled(bool)), SLOT(changed()));
|
|
|
|
connect(m_ui->autogroupInForeground, SIGNAL(toggled(bool)), SLOT(changed()));
|
|
|
|
connect(m_ui->shadeHoverOn, SIGNAL(toggled(bool)), SLOT(changed()));
|
|
|
|
connect(m_ui->shadeHover, SIGNAL(valueChanged(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->placementCombo, SIGNAL(activated(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->hideUtilityWindowsForInactive, SIGNAL(toggled(bool)), SLOT(changed()));
|
|
|
|
m_ui->inactiveTabsSkipTaskbar->setVisible(false); // TODO: We want translations in case this is fixed...
|
2007-04-29 21:35:43 +04:00
|
|
|
load();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::setShadeHover(bool on)
|
|
|
|
{
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->shadeHoverOn->setChecked(on);
|
|
|
|
m_ui->shadeHoverLabel->setEnabled(on);
|
|
|
|
m_ui->shadeHover->setEnabled(on);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::setShadeHoverInterval(int k)
|
|
|
|
{
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->shadeHover->setValue(k);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
int KAdvancedConfig::getShadeHoverInterval()
|
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-09-24 07:57:52 +04:00
|
|
|
return m_ui->shadeHover->value();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::shadeHoverChanged(bool a)
|
|
|
|
{
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->shadeHoverLabel->setEnabled(a);
|
|
|
|
m_ui->shadeHover->setEnabled(a);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::showEvent(QShowEvent *ev)
|
2009-12-14 06:18:43 +03:00
|
|
|
{
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!standAlone) {
|
|
|
|
QWidget::showEvent(ev);
|
2009-12-14 06:18:43 +03:00
|
|
|
return;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
KCModule::showEvent(ev);
|
2009-12-14 06:18:43 +03:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::load(void)
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
KConfigGroup cg(config, "Windows");
|
|
|
|
|
|
|
|
setShadeHover(cg.readEntry(KWIN_SHADEHOVER, false));
|
|
|
|
setShadeHoverInterval(cg.readEntry(KWIN_SHADEHOVER_INTERVAL, 250));
|
|
|
|
|
2008-09-08 01:08:26 +04:00
|
|
|
QString key;
|
|
|
|
key = cg.readEntry(KWIN_PLACEMENT);
|
2012-09-24 07:57:52 +04:00
|
|
|
int idx = m_ui->placementCombo->findData(key);
|
2012-04-17 17:25:53 +04:00
|
|
|
if (idx < 0)
|
2012-09-24 07:57:52 +04:00
|
|
|
idx = m_ui->placementCombo->findData("Smart");
|
|
|
|
m_ui->placementCombo->setCurrentIndex(idx);
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
setHideUtilityWindowsForInactive(cg.readEntry(KWIN_HIDE_UTILITY, true));
|
|
|
|
setInactiveTabsSkipTaskbar(cg.readEntry(KWIN_INACTIVE_SKIP_TASKBAR, false));
|
|
|
|
setAutogroupSimilarWindows(cg.readEntry(KWIN_AUTOGROUP_SIMILAR, false));
|
|
|
|
setAutogroupInForeground(cg.readEntry(KWIN_AUTOGROUP_FOREGROUND, true));
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
emit KCModule::changed(false);
|
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::save(void)
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
int v;
|
|
|
|
|
|
|
|
KConfigGroup cg(config, "Windows");
|
2012-09-24 07:57:52 +04:00
|
|
|
cg.writeEntry(KWIN_SHADEHOVER, m_ui->shadeHoverOn->isChecked());
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
v = getShadeHoverInterval();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (v < 0) v = 0;
|
2007-04-29 21:35:43 +04:00
|
|
|
cg.writeEntry(KWIN_SHADEHOVER_INTERVAL, v);
|
|
|
|
|
2012-09-24 07:57:52 +04:00
|
|
|
cg.writeEntry(KWIN_PLACEMENT, m_ui->placementCombo->itemData(m_ui->placementCombo->currentIndex()).toString());
|
|
|
|
|
|
|
|
cg.writeEntry(KWIN_HIDE_UTILITY, m_ui->hideUtilityWindowsForInactive->isChecked());
|
|
|
|
cg.writeEntry(KWIN_INACTIVE_SKIP_TASKBAR, m_ui->inactiveTabsSkipTaskbar->isChecked());
|
|
|
|
cg.writeEntry(KWIN_AUTOGROUP_SIMILAR, m_ui->autogroupSimilarWindows->isChecked());
|
|
|
|
cg.writeEntry(KWIN_AUTOGROUP_FOREGROUND, m_ui->autogroupInForeground->isChecked());
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (standAlone) {
|
2007-04-29 21:35:43 +04:00
|
|
|
config->sync();
|
2011-01-30 17:34:42 +03:00
|
|
|
// Send signal to all kwin instances
|
|
|
|
QDBusMessage message =
|
|
|
|
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
2007-04-30 15:32:47 +04:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
emit KCModule::changed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KAdvancedConfig::defaults()
|
|
|
|
{
|
|
|
|
setShadeHover(false);
|
|
|
|
setShadeHoverInterval(250);
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->placementCombo->setCurrentIndex(0); // default to Smart
|
2011-01-30 17:34:42 +03:00
|
|
|
setHideUtilityWindowsForInactive(true);
|
|
|
|
setInactiveTabsSkipTaskbar(false);
|
|
|
|
setAutogroupSimilarWindows(false);
|
|
|
|
setAutogroupInForeground(true);
|
2007-04-29 21:35:43 +04:00
|
|
|
emit KCModule::changed(true);
|
|
|
|
}
|
|
|
|
|
2008-09-08 01:08:26 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::setHideUtilityWindowsForInactive(bool s)
|
|
|
|
{
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->hideUtilityWindowsForInactive->setChecked(s);
|
2008-09-08 01:08:26 +04:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::setInactiveTabsSkipTaskbar(bool s)
|
|
|
|
{
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->inactiveTabsSkipTaskbar->setChecked(s);
|
2009-11-17 14:25:03 +03:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::setAutogroupSimilarWindows(bool s)
|
|
|
|
{
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->autogroupSimilarWindows->setChecked(s);
|
2009-11-16 13:09:03 +03:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KAdvancedConfig::setAutogroupInForeground(bool s)
|
|
|
|
{
|
2012-09-24 07:57:52 +04:00
|
|
|
m_ui->autogroupInForeground->setChecked(s);
|
2009-11-17 10:51:55 +03:00
|
|
|
}
|
|
|
|
|
2012-09-24 07:24:31 +04:00
|
|
|
KWinMovingConfigForm::KWinMovingConfigForm(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2012-10-28 01:11:22 +04:00
|
|
|
setupUi(parent);
|
2012-09-24 07:24:31 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
KMovingConfig::~KMovingConfig()
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
if (standAlone)
|
|
|
|
delete config;
|
|
|
|
}
|
|
|
|
|
2013-09-30 09:29:38 +04:00
|
|
|
KMovingConfig::KMovingConfig(bool _standAlone, KConfig *_config, QWidget *parent)
|
|
|
|
: KCModule(parent), config(_config), standAlone(_standAlone)
|
2012-09-24 07:24:31 +04:00
|
|
|
, m_ui(new KWinMovingConfigForm(this))
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
// Any changes goes to slotChanged()
|
|
|
|
connect(m_ui->geometryTipOn, SIGNAL(clicked()), SLOT(changed()));
|
|
|
|
connect(m_ui->borderSnap, SIGNAL(valueChanged(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->windowSnap, SIGNAL(valueChanged(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->centerSnap, SIGNAL(valueChanged(int)), SLOT(changed()));
|
|
|
|
connect(m_ui->OverlapSnap, SIGNAL(clicked()), SLOT(changed()));
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KMovingConfig::setGeometryTip(bool showGeometryTip)
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
m_ui->geometryTipOn->setChecked(showGeometryTip);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KMovingConfig::getGeometryTip()
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
return m_ui->geometryTipOn->isChecked();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KMovingConfig::showEvent(QShowEvent *ev)
|
2009-12-14 06:18:43 +03:00
|
|
|
{
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!standAlone) {
|
|
|
|
QWidget::showEvent(ev);
|
2009-12-14 06:18:43 +03:00
|
|
|
return;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
KCModule::showEvent(ev);
|
2009-12-14 06:18:43 +03:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KMovingConfig::load(void)
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
QString key;
|
|
|
|
|
|
|
|
KConfigGroup cg(config, "Windows");
|
|
|
|
|
|
|
|
//KS 10Jan2003 - Geometry Tip during window move/resize
|
|
|
|
bool showGeomTip = cg.readEntry(KWIN_GEOMETRY, false);
|
2011-01-30 17:34:42 +03:00
|
|
|
setGeometryTip(showGeomTip);
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
int v;
|
|
|
|
|
|
|
|
v = cg.readEntry(KWM_BRDR_SNAP_ZONE, KWM_BRDR_SNAP_ZONE_DEFAULT);
|
|
|
|
if (v > MAX_BRDR_SNAP) setBorderSnapZone(MAX_BRDR_SNAP);
|
2011-01-30 17:34:42 +03:00
|
|
|
else if (v < 0) setBorderSnapZone(0);
|
2007-04-29 21:35:43 +04:00
|
|
|
else setBorderSnapZone(v);
|
|
|
|
|
|
|
|
v = cg.readEntry(KWM_WNDW_SNAP_ZONE, KWM_WNDW_SNAP_ZONE_DEFAULT);
|
|
|
|
if (v > MAX_WNDW_SNAP) setWindowSnapZone(MAX_WNDW_SNAP);
|
2011-01-30 17:34:42 +03:00
|
|
|
else if (v < 0) setWindowSnapZone(0);
|
2007-04-29 21:35:43 +04:00
|
|
|
else setWindowSnapZone(v);
|
|
|
|
|
2008-07-09 19:18:47 +04:00
|
|
|
v = cg.readEntry(KWM_CNTR_SNAP_ZONE, KWM_CNTR_SNAP_ZONE_DEFAULT);
|
|
|
|
if (v > MAX_CNTR_SNAP) setCenterSnapZone(MAX_CNTR_SNAP);
|
2011-01-30 17:34:42 +03:00
|
|
|
else if (v < 0) setCenterSnapZone(0);
|
2008-07-09 19:18:47 +04:00
|
|
|
else setCenterSnapZone(v);
|
|
|
|
|
2012-09-24 07:24:31 +04:00
|
|
|
m_ui->OverlapSnap->setChecked(cg.readEntry("SnapOnlyWhenOverlapping", false));
|
2007-04-29 21:35:43 +04:00
|
|
|
emit KCModule::changed(false);
|
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KMovingConfig::save(void)
|
2007-04-29 21:35:43 +04:00
|
|
|
{
|
|
|
|
KConfigGroup cg(config, "Windows");
|
2012-04-15 01:18:21 +04:00
|
|
|
cg.writeEntry(KWIN_GEOMETRY, getGeometryTip());
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
cg.writeEntry(KWM_BRDR_SNAP_ZONE, getBorderSnapZone());
|
|
|
|
cg.writeEntry(KWM_WNDW_SNAP_ZONE, getWindowSnapZone());
|
|
|
|
cg.writeEntry(KWM_CNTR_SNAP_ZONE, getCenterSnapZone());
|
2012-09-24 07:24:31 +04:00
|
|
|
cg.writeEntry("SnapOnlyWhenOverlapping", m_ui->OverlapSnap->isChecked());
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
KConfigGroup(config, "Plugins").writeEntry("kwin4_effect_windowgeometryEnabled", getGeometryTip());
|
2010-11-10 22:21:56 +03:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (standAlone) {
|
2007-04-29 21:35:43 +04:00
|
|
|
config->sync();
|
2007-04-30 15:32:47 +04:00
|
|
|
// Send signal to all kwin instances
|
|
|
|
QDBusMessage message =
|
2011-01-30 17:34:42 +03:00
|
|
|
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
2007-04-30 15:32:47 +04:00
|
|
|
QDBusConnection::sessionBus().send(message);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
emit KCModule::changed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KMovingConfig::defaults()
|
|
|
|
{
|
|
|
|
setGeometryTip(false);
|
|
|
|
|
|
|
|
//copied from kcontrol/konq/kwindesktop, aleXXX
|
|
|
|
setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT);
|
|
|
|
setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT);
|
2008-07-09 19:18:47 +04:00
|
|
|
setCenterSnapZone(KWM_CNTR_SNAP_ZONE_DEFAULT);
|
2012-09-24 07:24:31 +04:00
|
|
|
m_ui->OverlapSnap->setChecked(false);
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
emit KCModule::changed(true);
|
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
int KMovingConfig::getBorderSnapZone()
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
return m_ui->borderSnap->value();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KMovingConfig::setBorderSnapZone(int pxls)
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
m_ui->borderSnap->setValue(pxls);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
int KMovingConfig::getWindowSnapZone()
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
return m_ui->windowSnap->value();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KMovingConfig::setWindowSnapZone(int pxls)
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
m_ui->windowSnap->setValue(pxls);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
int KMovingConfig::getCenterSnapZone()
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
return m_ui->centerSnap->value();
|
2008-07-09 19:18:47 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void KMovingConfig::setCenterSnapZone(int pxls)
|
|
|
|
{
|
2012-09-24 07:24:31 +04:00
|
|
|
m_ui->centerSnap->setValue(pxls);
|
2008-07-09 19:18:47 +04:00
|
|
|
}
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "windows.moc"
|