mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: drop bogus multihead support
note that it is independant of X11 multiscreen, as the comment in KWin::Workspace::isOnCurrentHead() claims Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f06b7c74e6
commit
a5a07d46ca
10 changed files with 18 additions and 251 deletions
|
@ -36,7 +36,6 @@
|
|||
#include <kconfig.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <klocale.h>
|
||||
#include <ktoolinvocation.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kglobalsettings.h>
|
||||
|
||||
|
@ -169,11 +168,6 @@ KCMInit::KCMInit( KCmdLineArgs* args )
|
|||
list = KServiceTypeTrader::self()->query( "KCModuleInit" );
|
||||
|
||||
}
|
||||
// Pass env. var to klauncher.
|
||||
QString name = "KDE_MULTIHEAD";
|
||||
QString value = KGlobalSettings::isMultiHead() ? "true" : "false";
|
||||
KToolInvocation::setLaunchEnv(name, value);
|
||||
setenv( name.toLatin1().constData(), value.toLatin1().constData(), 1 ); // apply effect also to itself
|
||||
|
||||
if( startup )
|
||||
{
|
||||
|
|
|
@ -62,7 +62,6 @@ static inline int sign(int v) {
|
|||
//********************************************
|
||||
|
||||
extern int screen_number;
|
||||
extern bool is_multihead;
|
||||
|
||||
/*!
|
||||
Resizes the workspace after an XRANDR screen size change
|
||||
|
@ -272,42 +271,26 @@ QRect Workspace::clientArea(clientAreaOption opt, int screen, int desktop) const
|
|||
screen = screens()->current();
|
||||
|
||||
QRect sarea, warea;
|
||||
|
||||
if (is_multihead) {
|
||||
sarea = (!screenarea.isEmpty()
|
||||
&& screen < screenarea[ desktop ].size()) // screens may be missing during KWin initialization or screen config changes
|
||||
? screenarea[ desktop ][ screen_number ]
|
||||
: screens()->geometry(screen_number);
|
||||
warea = workarea[ desktop ].isNull()
|
||||
? screens()->geometry(screen_number)
|
||||
: workarea[ desktop ];
|
||||
} else {
|
||||
sarea = (!screenarea.isEmpty()
|
||||
&& screen < screenarea[ desktop ].size()) // screens may be missing during KWin initialization or screen config changes
|
||||
? screenarea[ desktop ][ screen ]
|
||||
: screens()->geometry(screen);
|
||||
warea = workarea[ desktop ].isNull()
|
||||
? QRect(0, 0, displayWidth(), displayHeight())
|
||||
: workarea[ desktop ];
|
||||
}
|
||||
// screens may be missing during KWin initialization or screen config changes
|
||||
sarea = (!screenarea.isEmpty()
|
||||
&& screen < screenarea[ desktop ].size())
|
||||
? screenarea[ desktop ][ screen ]
|
||||
: screens()->geometry(screen);
|
||||
warea = workarea[ desktop ].isNull()
|
||||
? QRect(0, 0, displayWidth(), displayHeight())
|
||||
: workarea[ desktop ];
|
||||
|
||||
switch(opt) {
|
||||
case MaximizeArea:
|
||||
case PlacementArea:
|
||||
return sarea;
|
||||
return sarea;
|
||||
case MaximizeFullArea:
|
||||
case FullScreenArea:
|
||||
case MovementArea:
|
||||
case ScreenArea:
|
||||
if (is_multihead)
|
||||
return screens()->geometry(screen_number);
|
||||
else
|
||||
return screens()->geometry(screen);
|
||||
return screens()->geometry(screen);
|
||||
case WorkArea:
|
||||
if (is_multihead)
|
||||
return sarea;
|
||||
else
|
||||
return warea;
|
||||
return warea;
|
||||
case FullArea:
|
||||
return QRect(0, 0, displayWidth(), displayHeight());
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ Options* options;
|
|||
Atoms* atoms;
|
||||
|
||||
int screen_number = -1;
|
||||
bool is_multihead = false;
|
||||
|
||||
bool initting = false;
|
||||
|
||||
|
@ -314,48 +313,6 @@ int main(int argc, char * argv[])
|
|||
mallopt(M_TRIM_THRESHOLD, 5*pagesize);
|
||||
#endif // M_TRIM_THRESHOLD
|
||||
|
||||
Display* dpy = XOpenDisplay(NULL);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "%s: FATAL ERROR while trying to open display %s\n",
|
||||
argv[0], XDisplayName(NULL));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int number_of_screens = ScreenCount(dpy);
|
||||
|
||||
// multi head
|
||||
if (number_of_screens != 1 && KGlobalSettings::isMultiHead()) {
|
||||
KWin::is_multihead = true;
|
||||
KWin::screen_number = DefaultScreen(dpy);
|
||||
int pos; // Temporarily needed to reconstruct DISPLAY var if multi-head
|
||||
QByteArray display_name = XDisplayString(dpy);
|
||||
XCloseDisplay(dpy);
|
||||
dpy = 0;
|
||||
|
||||
if ((pos = display_name.lastIndexOf('.')) != -1)
|
||||
display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s"
|
||||
|
||||
QString envir;
|
||||
for (int i = 0; i < number_of_screens; i++) {
|
||||
// If execution doesn't pass by here, then kwin
|
||||
// acts exactly as previously
|
||||
if (i != KWin::screen_number && fork() == 0) {
|
||||
KWin::screen_number = i;
|
||||
// Break here because we are the child process, we don't
|
||||
// want to fork() anymore
|
||||
break;
|
||||
}
|
||||
}
|
||||
// In the next statement, display_name shouldn't contain a screen
|
||||
// number. If it had it, it was removed at the "pos" check
|
||||
envir.sprintf("DISPLAY=%s.%d", display_name.data(), KWin::screen_number);
|
||||
|
||||
if (putenv(strdup(envir.toAscii()))) {
|
||||
fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]);
|
||||
perror("putenv()");
|
||||
}
|
||||
}
|
||||
|
||||
KAboutData aboutData(
|
||||
"kwin", // The program name used internally
|
||||
0, // The message catalog name. If null, program name is used instead
|
||||
|
|
|
@ -915,7 +915,7 @@ static bool areModKeysDepressed(const KShortcut& cut)
|
|||
|
||||
void TabBox::navigatingThroughWindows(bool forward, const KShortcut& shortcut, TabBoxMode mode)
|
||||
{
|
||||
if (!m_ready || isGrabbed() || !Workspace::self()->isOnCurrentHead()) {
|
||||
if (!m_ready || isGrabbed()) {
|
||||
return;
|
||||
}
|
||||
if (!options->focusPolicyIsReasonable()) {
|
||||
|
@ -975,7 +975,7 @@ void TabBox::slotWalkBackThroughCurrentAppWindowsAlternative()
|
|||
|
||||
void TabBox::slotWalkThroughDesktops()
|
||||
{
|
||||
if (!m_ready || isGrabbed() || !Workspace::self()->isOnCurrentHead()) {
|
||||
if (!m_ready || isGrabbed()) {
|
||||
return;
|
||||
}
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktops)) {
|
||||
|
@ -988,7 +988,7 @@ void TabBox::slotWalkThroughDesktops()
|
|||
|
||||
void TabBox::slotWalkBackThroughDesktops()
|
||||
{
|
||||
if (!m_ready || isGrabbed() || !Workspace::self()->isOnCurrentHead()) {
|
||||
if (!m_ready || isGrabbed()) {
|
||||
return;
|
||||
}
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktopsReverse)) {
|
||||
|
@ -1001,7 +1001,7 @@ void TabBox::slotWalkBackThroughDesktops()
|
|||
|
||||
void TabBox::slotWalkThroughDesktopList()
|
||||
{
|
||||
if (!m_ready || isGrabbed() || !Workspace::self()->isOnCurrentHead()) {
|
||||
if (!m_ready || isGrabbed()) {
|
||||
return;
|
||||
}
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktopList)) {
|
||||
|
@ -1014,7 +1014,7 @@ void TabBox::slotWalkThroughDesktopList()
|
|||
|
||||
void TabBox::slotWalkBackThroughDesktopList()
|
||||
{
|
||||
if (!m_ready || isGrabbed() || !Workspace::self()->isOnCurrentHead()) {
|
||||
if (!m_ready || isGrabbed()) {
|
||||
return;
|
||||
}
|
||||
if (areModKeysDepressed(m_cutWalkThroughDesktopListReverse)) {
|
||||
|
|
|
@ -67,7 +67,6 @@ namespace KWin
|
|||
|
||||
// main.cpp
|
||||
extern int screen_number;
|
||||
extern bool is_multihead;
|
||||
|
||||
ColorMapper::ColorMapper(QObject *parent)
|
||||
: QObject(parent)
|
||||
|
@ -1046,33 +1045,6 @@ void Workspace::sendClientToDesktop(Client* c, int desk, bool dont_activate)
|
|||
updateClientArea();
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the X Window with the input focus is on our X11 screen
|
||||
* if the window cannot be determined or inspected, resturn depends on whether there's actually
|
||||
* more than one screen
|
||||
*
|
||||
* this is NOT in any way related to XRandR multiscreen
|
||||
*
|
||||
*/
|
||||
bool Workspace::isOnCurrentHead()
|
||||
{
|
||||
if (!is_multihead) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Xcb::CurrentInput currentInput;
|
||||
if (currentInput.window() == XCB_WINDOW_NONE) {
|
||||
return !is_multihead;
|
||||
}
|
||||
|
||||
Xcb::WindowGeometry geometry(currentInput.window());
|
||||
if (geometry.isNull()) { // should not happen
|
||||
return !is_multihead;
|
||||
}
|
||||
|
||||
return rootWindow() == geometry->root;
|
||||
}
|
||||
|
||||
void Workspace::sendClientToScreen(Client* c, int screen)
|
||||
{
|
||||
c->sendToScreen(screen);
|
||||
|
@ -1272,13 +1244,6 @@ QString Workspace::supportInformation() const
|
|||
#endif
|
||||
support.append("\nScreens\n");
|
||||
support.append( "=======\n");
|
||||
support.append("Multi-Head: ");
|
||||
if (is_multihead) {
|
||||
support.append("yes\n");
|
||||
support.append(QString("Head: %1\n").arg(screen_number));
|
||||
} else {
|
||||
support.append("no\n");
|
||||
}
|
||||
support.append("Active screen follows mouse: ");
|
||||
if (screens()->isCurrentFollowsMouse())
|
||||
support.append(" yes\n");
|
||||
|
|
|
@ -178,7 +178,6 @@ private:
|
|||
// Unsorted
|
||||
|
||||
public:
|
||||
bool isOnCurrentHead();
|
||||
// True when performing Workspace::updateClientArea().
|
||||
// The calls below are valid only in that case.
|
||||
bool inUpdateClientArea() const;
|
||||
|
|
|
@ -112,30 +112,6 @@ void AppInterface::setTheme(const QString &name)
|
|||
Plasma::Theme::defaultTheme()->setThemeName(name);
|
||||
}
|
||||
|
||||
bool AppInterface::multihead() const
|
||||
{
|
||||
return KGlobalSettings::isMultiHead();
|
||||
}
|
||||
|
||||
int AppInterface::multiheadScreen() const
|
||||
{
|
||||
int id = -1;
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
if (KGlobalSettings::isMultiHead()) {
|
||||
// with multihead, we "lie" and say that screen 0 is the default screen, in fact, we pretend
|
||||
// we have only one screen at all
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
if (dpy) {
|
||||
id = DefaultScreen(dpy);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void AppInterface::lockCorona(bool locked)
|
||||
{
|
||||
m_env->corona()->setImmutability(locked ? Plasma::UserImmutable : Plasma::Mutable);
|
||||
|
|
|
@ -53,8 +53,6 @@ class PLASMAGENERICSHELL_EXPORT AppInterface : public QObject
|
|||
Q_PROPERTY(QString applicationVersion READ applicationVersion)
|
||||
Q_PROPERTY(QString platformVersion READ platformVersion)
|
||||
Q_PROPERTY(int scriptingVersion READ scriptingVersion)
|
||||
Q_PROPERTY(bool multihead READ multihead)
|
||||
Q_PROPERTY(bool multiheadScreen READ multihead)
|
||||
|
||||
public:
|
||||
AppInterface(ScriptEngine *env);
|
||||
|
@ -76,9 +74,6 @@ public:
|
|||
QString theme() const;
|
||||
void setTheme(const QString &name);
|
||||
|
||||
bool multihead() const;
|
||||
int multiheadScreen() const;
|
||||
|
||||
bool coronaLocked() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
|
|
@ -168,47 +168,16 @@ void DesktopCorona::checkScreen(int screen)
|
|||
|
||||
int DesktopCorona::numScreens() const
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
if (KGlobalSettings::isMultiHead()) {
|
||||
// with multihead, we "lie" and say that there is only one screen
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return QApplication::desktop()->screenCount();
|
||||
}
|
||||
|
||||
QRect DesktopCorona::screenGeometry(int id) const
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
if (KGlobalSettings::isMultiHead()) {
|
||||
// with multihead, we "lie" and say that screen 0 is the default screen, in fact, we pretend
|
||||
// we have only one screen at all
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
if (dpy) {
|
||||
id = DefaultScreen(dpy);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return QApplication::desktop()->screenGeometry(id);
|
||||
}
|
||||
|
||||
QRegion DesktopCorona::availableScreenRegion(int id) const
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
if (KGlobalSettings::isMultiHead()) {
|
||||
// with multihead, we "lie" and say that screen 0 is the default screen, in fact, we pretend
|
||||
// we have only one screen at all
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
if (dpy) {
|
||||
id = DefaultScreen(dpy);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (id < 0) {
|
||||
id = QApplication::desktop()->primaryScreen();
|
||||
}
|
||||
|
@ -270,13 +239,6 @@ QRect DesktopCorona::availableScreenRect(int id) const
|
|||
|
||||
int DesktopCorona::screenId(const QPoint &pos) const
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
if (KGlobalSettings::isMultiHead()) {
|
||||
// with multihead, we "lie" and say that there is only one screen
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return QApplication::desktop()->screenNumber(pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,88 +17,24 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <QDateTime>
|
||||
#include <KApplication>
|
||||
#include <KAboutData>
|
||||
#include <KCmdLineArgs>
|
||||
#include <KGlobalSettings>
|
||||
#include <KLocale>
|
||||
#include <KIcon>
|
||||
#include <KDebug>
|
||||
#include <kdeversion.h>
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
#include <config-workspace.h>
|
||||
#include "plasmaapp.h"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <X11/Xlib.h>
|
||||
#include <fixx11h.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static const char description[] = I18N_NOOP( "The KDE desktop, panels and widgets workspace application." );
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "START" << "(line:" << __LINE__ << ")";
|
||||
|
||||
// dual head support
|
||||
int associatedScreen = 0;
|
||||
#ifdef Q_WS_X11
|
||||
{
|
||||
if (KGlobalSettings::isMultiHead()) {
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "%s: FATAL ERROR: couldn't open display %s\n",
|
||||
argv[0], XDisplayName(NULL));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int numberOfScreens = ScreenCount(dpy);
|
||||
associatedScreen = DefaultScreen(dpy);
|
||||
QString displayName = QString::fromLocal8Bit(XDisplayString(dpy));
|
||||
int pos = displayName.lastIndexOf('.');
|
||||
|
||||
XCloseDisplay(dpy);
|
||||
dpy = 0;
|
||||
|
||||
if (pos != -1) {
|
||||
displayName.truncate(pos);
|
||||
}
|
||||
|
||||
if (numberOfScreens > 1) {
|
||||
for (int i = 0; i < numberOfScreens; ++i) {
|
||||
if (i != associatedScreen && fork() == 0) {
|
||||
associatedScreen = i;
|
||||
// break here because we are the child process, we don't
|
||||
// want to fork() anymore
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString env = QString("DISPLAY=%2.%1").arg(associatedScreen).arg(displayName);
|
||||
|
||||
if (putenv(strdup(env.toLocal8Bit()))) {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: unable to set DISPLAY environment variable\n",
|
||||
argv[0]);
|
||||
perror("putenv()");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QByteArray appName = "plasma-desktop";
|
||||
if (associatedScreen > 0) {
|
||||
appName.append("-screen-").append(QByteArray::number(associatedScreen));
|
||||
}
|
||||
|
||||
KAboutData aboutData(appName, 0, ki18n("Plasma Desktop Shell"),
|
||||
KAboutData aboutData("plasma-desktop", 0, ki18n("Plasma Desktop Shell"),
|
||||
KDE_VERSION_STRING, ki18n(description), KAboutData::License_GPL,
|
||||
ki18n("Copyright 2006-2009, The KDE Team"));
|
||||
aboutData.addAuthor(ki18n("Aaron J. Seigo"),
|
||||
|
|
Loading…
Add table
Reference in a new issue