mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
plasma: replace kephal with single class [ci reset]
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
716acdb8f4
commit
0411eb46a8
98 changed files with 269 additions and 11884 deletions
|
@ -26,5 +26,4 @@ _kde4workspace_set_lib_vars( WEATHERION weather_ion)
|
|||
_kde4workspace_set_lib_vars( KWINEFFECTS kwineffects)
|
||||
_kde4workspace_set_lib_vars( KDECORATIONS kdecorations)
|
||||
_kde4workspace_set_lib_vars( KSGRD ksgrd)
|
||||
_kde4workspace_set_lib_vars( KEPHAL kephal)
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ include_directories(
|
|||
${CMAKE_BINARY_DIR}/libs
|
||||
)
|
||||
|
||||
add_subdirectory(kephal)
|
||||
add_subdirectory(kworkspace)
|
||||
add_subdirectory(oxygen)
|
||||
add_subdirectory(plasmaclock)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
PROJECT (kephal)
|
||||
ADD_SUBDIRECTORY(client)
|
||||
ADD_SUBDIRECTORY(service)
|
||||
IF(ENABLE_TESTING)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF()
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Kephal provides an API for easier handling of multihead systems.
|
||||
|
||||
The architecture features features 2 main components:
|
||||
|
||||
* kded_kephal (service/)
|
||||
The KDED-module that provides all of the data and configuration-options.
|
||||
It will currently query for xrandr-extension and fallback to
|
||||
QDesktopWidget if XRandR 1.2 is not available.
|
||||
The directory 'service' contains the actual module class, kephald.*, and
|
||||
classes for the service and its dbus interface. Interfaces and shared logic
|
||||
are in shared/
|
||||
|
||||
* libkephal (client/)
|
||||
This is the lib that wraps all of Kephals DBus-API. It uses the same
|
||||
interface classes from shared/ as kded_kephal, but uses the
|
||||
dbus client stubs that access kded_kephal, and if this is not available, queries
|
||||
QDesktopWidget directly.
|
||||
|
||||
kephalapp and kephald are intended for development/testing.
|
||||
They are not installed.
|
||||
|
||||
Some more infos are in READMEs in the subdirs or as API-Docs.
|
|
@ -1,57 +0,0 @@
|
|||
include_directories(${kephal_SOURCE_DIR}/kephal)
|
||||
|
||||
add_definitions(
|
||||
-DSCREENS_FACTORY=libkephal_factory
|
||||
-DOUTPUTS_FACTORY=libkephal_factory
|
||||
-DCONFIGURATIONS_FACTORY=libkephal_factory
|
||||
)
|
||||
|
||||
SET(kephalshared_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/simplescreen.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/screens.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/desktopwidgetscreens.cpp
|
||||
)
|
||||
|
||||
set(unused_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/outputs.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/configurations.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/simpleoutput.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/desktopwidgetoutputs.cpp
|
||||
)
|
||||
|
||||
set(libkephal_SRCS
|
||||
${kephalshared_SRCS}
|
||||
libkephal.cpp
|
||||
)
|
||||
|
||||
set(more_unused_SRCS
|
||||
dbusconfigurations.cpp
|
||||
dbusoutputs.cpp
|
||||
dbusscreens.cpp
|
||||
noconfigurations.cpp
|
||||
)
|
||||
|
||||
# generate dbus-interface from class and add the generated sources
|
||||
#QT4_GENERATE_DBUS_INTERFACE(../service/dbus/dbusapi_screens.h org.kde.Kephal.Screens.xml)
|
||||
#QT4_ADD_DBUS_INTERFACE(libkephal_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Kephal.Screens.xml screens_interface)
|
||||
#QT4_GENERATE_DBUS_INTERFACE(../service/dbus/dbusapi_outputs.h org.kde.Kephal.Outputs.xml)
|
||||
#QT4_ADD_DBUS_INTERFACE(libkephal_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Kephal.Outputs.xml outputs_interface)
|
||||
#QT4_GENERATE_DBUS_INTERFACE(../service/dbus/dbusapi_configurations.h org.kde.Kephal.Configurations.xml)
|
||||
#QT4_ADD_DBUS_INTERFACE(libkephal_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Kephal.Configurations.xml configurations_interface)
|
||||
|
||||
add_library(kephal SHARED ${libkephal_SRCS})
|
||||
|
||||
target_link_libraries(kephal PUBLIC
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
)
|
||||
|
||||
set_target_properties(kephal PROPERTIES
|
||||
VERSION ${GENERIC_LIB_VERSION}
|
||||
SOVERSION ${GENERIC_LIB_SOVERSION}
|
||||
)
|
||||
|
||||
install(TARGETS kephal EXPORT kdeworkspaceLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
install(FILES FindKephal.cmake DESTINATION ${KDE4_DATA_INSTALL_DIR}/cmake/modules)
|
|
@ -1,26 +0,0 @@
|
|||
IF (KEPHAL_INCLUDE_DIR AND KEPHAL_LIBRARY)
|
||||
SET(Kephal_FIND_QUIETLY TRUE)
|
||||
ENDIF (KEPHAL_INCLUDE_DIR AND KEPHAL_LIBRARY)
|
||||
|
||||
FIND_PATH(KEPHAL_INCLUDE_DIR NAMES kephal/screens.h PATHS
|
||||
${KDE4_INCLUDE_DIR}
|
||||
${KDE4_INCLUDE_INSTALL_DIR})
|
||||
|
||||
FIND_LIBRARY(KEPHAL_LIBRARY NAMES kephal PATHS
|
||||
${KDE4_LIB_DIR}
|
||||
${KDE4_LIB_INSTALL_DIR})
|
||||
|
||||
IF (KEPHAL_INCLUDE_DIR AND KEPHAL_LIBRARY)
|
||||
SET(KEPHAL_FOUND TRUE)
|
||||
ENDIF (KEPHAL_INCLUDE_DIR AND KEPHAL_LIBRARY)
|
||||
|
||||
|
||||
IF (KEPHAL_FOUND)
|
||||
IF (NOT Kephal_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found Kephal: ${KEPHAL_LIBRARY}")
|
||||
ENDIF (NOT Kephal_FIND_QUIETLY)
|
||||
ELSE (KEPHAL_FOUND)
|
||||
IF (Kephal_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find Kephal")
|
||||
ENDIF (Kephal_FIND_REQUIRED)
|
||||
ENDIF (KEPHAL_FOUND)
|
|
@ -1,186 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "dbusconfigurations.h"
|
||||
|
||||
#include "outputs.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
DBusConfiguration::DBusConfiguration(DBusConfigurations * parent, QString name)
|
||||
: Configuration(parent),
|
||||
m_name(name),
|
||||
m_parent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString DBusConfiguration::name() {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool DBusConfiguration::isModifiable() {
|
||||
return m_parent->interface()->isModifiable(m_name);
|
||||
}
|
||||
|
||||
bool DBusConfiguration::isActivated() {
|
||||
return m_parent->interface()->isActivated(m_name);
|
||||
}
|
||||
|
||||
QMap<int, QPoint> DBusConfiguration::layout() {
|
||||
return QMap<int, QPoint>();
|
||||
}
|
||||
|
||||
void DBusConfiguration::activate() {
|
||||
m_parent->interface()->activate(m_name);
|
||||
}
|
||||
|
||||
int DBusConfiguration::primaryScreen() {
|
||||
return m_parent->interface()->primaryScreen(m_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DBusConfigurations::DBusConfigurations(QObject * parent)
|
||||
: Configurations(parent)
|
||||
{
|
||||
m_interface = new org::kde::Kephal::Configurations(
|
||||
"org.kde.Kephal",
|
||||
"/modules/kephal/Configurations",
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
|
||||
if (! m_interface->isValid()) {
|
||||
m_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_valid = true;
|
||||
|
||||
const QStringList names = m_interface->configurations();
|
||||
foreach (const QString& name, names) {
|
||||
m_configs.insert(name, new DBusConfiguration(this, name));
|
||||
}
|
||||
|
||||
connect(m_interface, SIGNAL(configurationActivated(QString)), this, SLOT(configurationActivatedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(confirmed()), this, SIGNAL(confirmed()));
|
||||
connect(m_interface, SIGNAL(reverted()), this, SIGNAL(reverted()));
|
||||
connect(m_interface, SIGNAL(confirmTimeout(int)), this, SIGNAL(confirmTimeout(int)));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, Configuration *> DBusConfigurations::configurations() {
|
||||
QMap<QString, Configuration *> result;
|
||||
for (QMap<QString, DBusConfiguration *>::const_iterator i = m_configs.constBegin(); i != m_configs.constEnd(); ++i) {
|
||||
result.insert(i.key(), i.value());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Configuration * DBusConfigurations::activeConfiguration() {
|
||||
QString name = m_interface->activeConfiguration();
|
||||
if ((! name.isEmpty()) && m_configs.contains(name)) {
|
||||
return m_configs[name];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QList<Configuration *> DBusConfigurations::alternateConfigurations() {
|
||||
const QStringList names = m_interface->alternateConfigurations();
|
||||
QList<Configuration *> result;
|
||||
foreach (const QString& name, names) {
|
||||
if (m_configs.contains(name)) {
|
||||
result << m_configs[name];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<QPoint> DBusConfigurations::possiblePositions(const Output * output) {
|
||||
QList<QPoint> result;
|
||||
int num = m_interface->numAvailablePositions(output->id());
|
||||
for (int i = 0; i < num; ++i) {
|
||||
result << m_interface->availablePosition(output->id(), i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DBusConfigurations::move(Output * output, const QPoint & position) {
|
||||
return m_interface->move(output->id(), position);
|
||||
}
|
||||
|
||||
bool DBusConfigurations::resize(Output * output, const QSize & size) {
|
||||
return m_interface->resize(output->id(), size);
|
||||
}
|
||||
|
||||
bool DBusConfigurations::rotate(Output * output, Rotation rotation) {
|
||||
return m_interface->rotate(output->id(), rotation);
|
||||
}
|
||||
|
||||
bool DBusConfigurations::reflectX(Output * output, bool reflect) {
|
||||
return m_interface->reflectX(output->id(), reflect);
|
||||
}
|
||||
|
||||
bool DBusConfigurations::reflectY(Output * output, bool reflect) {
|
||||
return m_interface->reflectY(output->id(), reflect);
|
||||
}
|
||||
|
||||
bool DBusConfigurations::changeRate(Output * output, float rate) {
|
||||
return m_interface->changeRate(output->id(), rate);
|
||||
}
|
||||
|
||||
bool DBusConfigurations::isValid() {
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
org::kde::Kephal::Configurations * DBusConfigurations::interface() {
|
||||
return m_interface;
|
||||
}
|
||||
|
||||
int DBusConfigurations::screen(Output * output) {
|
||||
return m_interface->screen(output->id());
|
||||
}
|
||||
|
||||
void DBusConfigurations::applyOutputSettings() {
|
||||
}
|
||||
|
||||
void DBusConfigurations::setPolling(bool polling) {
|
||||
m_interface->setPolling(polling);
|
||||
}
|
||||
|
||||
bool DBusConfigurations::polling() {
|
||||
return m_interface->polling();
|
||||
}
|
||||
|
||||
void DBusConfigurations::configurationActivatedSlot(QString name) {
|
||||
if ((! name.isEmpty()) && m_configs.contains(name)) {
|
||||
emit configurationActivated(m_configs[name]);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusConfigurations::confirm() {
|
||||
m_interface->confirm();
|
||||
}
|
||||
|
||||
void DBusConfigurations::revert() {
|
||||
m_interface->revert();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_DBUSCONFIGURATIONS_H
|
||||
#define KEPHAL_DBUSCONFIGURATIONS_H
|
||||
|
||||
#include <QPoint>
|
||||
#include "configurations.h"
|
||||
#include "configurations_interface.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class DBusConfigurations;
|
||||
|
||||
/**
|
||||
* Client side representation of a Configuration.
|
||||
* Basic implementation of the Configuration interface for DBusConfigurations to return.
|
||||
* Most methods are implemented by calling back through to DBusConfigurations.
|
||||
*/
|
||||
class DBusConfiguration : public Configuration {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DBusConfiguration(DBusConfigurations * parent, QString name);
|
||||
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
QString name() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
bool isModifiable() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
bool isActivated() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
QMap<int, QPoint> layout() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
int primaryScreen() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void activate();
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
DBusConfigurations * m_parent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* DBUS stub to remote configurations provided by Kephal daemon
|
||||
*/
|
||||
class DBusConfigurations : public Configurations {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DBusConfigurations(QObject * parent);
|
||||
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
QMap<QString, Configuration *> configurations();
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
Configuration * activeConfiguration();
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
QList<Configuration *> alternateConfigurations();
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
QList<QPoint> possiblePositions(const Output * output);
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
bool move(Output * output, const QPoint & position);
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
bool resize(Output * output, const QSize & size);
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
bool rotate(Output * output, Rotation rotation);
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
bool reflectX(Output * output, bool reflect);
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
bool reflectY(Output * output, bool reflect);
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
bool changeRate(Output * output, float rate);
|
||||
/**
|
||||
* @reimp Kephal::Configurations
|
||||
*/
|
||||
int screen(Output * output);
|
||||
void applyOutputSettings();
|
||||
void setPolling(bool polling);
|
||||
bool polling() const;
|
||||
void confirm();
|
||||
void revert();
|
||||
|
||||
bool isValid();
|
||||
org::kde::Kephal::Configurations * interface();
|
||||
|
||||
private Q_SLOTS:
|
||||
void configurationActivatedSlot(QString name);
|
||||
|
||||
private:
|
||||
org::kde::Kephal::Configurations * m_interface;
|
||||
bool m_valid;
|
||||
QMap<QString, DBusConfiguration *> m_configs;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_DBUSCONFIGURATIONS_H
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "dbusoutputs.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "simpleoutput.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
DBusOutputs::DBusOutputs(QObject * parent)
|
||||
: Outputs(parent)
|
||||
{
|
||||
m_interface = new org::kde::Kephal::Outputs(
|
||||
"org.kde.Kephal",
|
||||
"/modules/kephal/Outputs",
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
|
||||
if (! m_interface->isValid()) {
|
||||
m_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_valid = true;
|
||||
|
||||
const QStringList ids = m_interface->outputIds();
|
||||
foreach (const QString& id, ids) {
|
||||
QPoint pos = m_interface->position(id);
|
||||
QSize size = m_interface->size(id);
|
||||
bool connected = m_interface->isConnected(id);
|
||||
bool activated = m_interface->isActivated(id);
|
||||
//qDebug() << "adding an output" << id << "with geom: " << pos << size;
|
||||
|
||||
SimpleOutput * output = new SimpleOutput(this,
|
||||
id,
|
||||
size,
|
||||
pos,
|
||||
connected,
|
||||
activated);
|
||||
|
||||
m_outputs.append(output);
|
||||
|
||||
if (connected) {
|
||||
output->_setRate(m_interface->rate(id));
|
||||
int rotation = m_interface->rotation(id);
|
||||
output->_setRotation((Rotation) rotation);
|
||||
output->_setReflectX(m_interface->reflectX(id));
|
||||
output->_setReflectY(m_interface->reflectY(id));
|
||||
|
||||
outputConnectedSlot(id);
|
||||
}
|
||||
}
|
||||
|
||||
connect(m_interface, SIGNAL(outputConnected(QString)), this, SLOT(outputConnectedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputDisconnected(QString)), this, SLOT(outputDisconnectedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputActivated(QString)), this, SLOT(outputActivatedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputDeactivated(QString)), this, SLOT(outputDeactivatedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputResized(QString)), this, SLOT(outputResizedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputMoved(QString)), this, SLOT(outputMovedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputRotated(QString)), this, SLOT(outputRotatedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputRateChanged(QString)), this, SLOT(outputRateChangedSlot(QString)));
|
||||
connect(m_interface, SIGNAL(outputReflected(QString)), this, SLOT(outputReflectedSlot(QString)));
|
||||
}
|
||||
|
||||
QList<Output *> DBusOutputs::outputs()
|
||||
{
|
||||
QList<Output *> result;
|
||||
foreach(SimpleOutput * output, m_outputs) {
|
||||
result.append(output);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void DBusOutputs::activateLayout(const QMap<Output *, QRect> & layout)
|
||||
{
|
||||
Q_UNUSED(layout)
|
||||
}
|
||||
|
||||
bool DBusOutputs::isValid() {
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
void DBusOutputs::outputConnectedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
o->_setConnected(true);
|
||||
|
||||
int numSizes = m_interface->numAvailableSizes(id);
|
||||
QList<QSize> sizes;
|
||||
for (int i = 0; i < numSizes; ++i) {
|
||||
sizes << m_interface->availableSize(id, i);
|
||||
}
|
||||
o->_setAvailableSizes(sizes);
|
||||
|
||||
int numRates = m_interface->numAvailableRates(id);
|
||||
QList<float> rates;
|
||||
for (int i = 0; i < numRates; ++i) {
|
||||
rates << m_interface->availableRate(id, i);
|
||||
}
|
||||
o->_setAvailableRates(rates);
|
||||
|
||||
emit outputConnected(o);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputDisconnectedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
o->_setConnected(false);
|
||||
emit outputDisconnected(o);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputActivatedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
o->_setActivated(true);
|
||||
o->_setSize(m_interface->size(id));
|
||||
emit outputActivated(o);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputDeactivatedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
o->_setActivated(false);
|
||||
emit outputDeactivated(o);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputResizedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
QSize prev = o->size();
|
||||
o->_setSize(m_interface->size(id));
|
||||
emit outputResized(o, prev, o->size());
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputMovedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
QPoint prev = o->position();
|
||||
o->_setPosition(m_interface->position(id));
|
||||
emit outputMoved(o, prev, o->position());
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputRotatedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
Rotation prev = o->rotation();
|
||||
int rotation = m_interface->rotation(id);
|
||||
o->_setRotation((Rotation) rotation);
|
||||
emit outputRotated(o, prev, o->rotation());
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputRateChangedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
float prev = o->rate();
|
||||
o->_setRate(m_interface->rate(id));
|
||||
emit outputRateChanged(o, prev, o->rate());
|
||||
}
|
||||
}
|
||||
|
||||
void DBusOutputs::outputReflectedSlot(QString id) {
|
||||
SimpleOutput * o = (SimpleOutput *) output(id);
|
||||
if (o) {
|
||||
bool prevX = o->reflectX();
|
||||
bool prevY = o->reflectY();
|
||||
o->_setReflectX(m_interface->reflectX(id));
|
||||
o->_setReflectY(m_interface->reflectY(id));
|
||||
emit outputReflected(o, prevX, prevY, o->reflectX(), o->reflectY());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_DBUSOUTPUTS_H
|
||||
#define KEPHAL_DBUSOUTPUTS_H
|
||||
|
||||
#include "outputs.h"
|
||||
#include "outputs_interface.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class SimpleOutput;
|
||||
/**
|
||||
* Client side interface to outputs. Setup by libkephal.cpp
|
||||
* Deals in SimpleOutput
|
||||
*/
|
||||
class DBusOutputs : public Outputs {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DBusOutputs(QObject * parent);
|
||||
|
||||
QList<Output *> outputs();
|
||||
void activateLayout(const QMap<Output *, QRect> & layout);
|
||||
|
||||
bool isValid();
|
||||
|
||||
private Q_SLOTS:
|
||||
void outputConnectedSlot(QString id);
|
||||
void outputDisconnectedSlot(QString id);
|
||||
void outputActivatedSlot(QString id);
|
||||
void outputDeactivatedSlot(QString id);
|
||||
void outputResizedSlot(QString id);
|
||||
void outputMovedSlot(QString id);
|
||||
void outputRotatedSlot(QString id);
|
||||
void outputRateChangedSlot(QString id);
|
||||
void outputReflectedSlot(QString id);
|
||||
|
||||
private:
|
||||
QList<SimpleOutput *> m_outputs;
|
||||
org::kde::Kephal::Outputs * m_interface;
|
||||
bool m_valid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_DBUSSCREENS_H
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "dbusscreens.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "simplescreen.h"
|
||||
|
||||
#include "outputs.h"
|
||||
|
||||
#include "screens_interface.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
DBusScreens::DBusScreens(QObject * parent)
|
||||
: Screens(parent)
|
||||
{
|
||||
m_interface = new org::kde::Kephal::Screens(
|
||||
"org.kde.Kephal",
|
||||
"/modules/kephal/Screens",
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
|
||||
if (! m_interface->isValid()) {
|
||||
m_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_valid = true;
|
||||
|
||||
int numScreens = m_interface->numScreens();
|
||||
for (int i = 0; i < numScreens; ++i) {
|
||||
int id = m_interface->id(i);
|
||||
QPoint pos = m_interface->position(id);
|
||||
QSize size = m_interface->size(id);
|
||||
//qDebug() << "adding a screen" << id << "with geom: " << pos << size;
|
||||
|
||||
SimpleScreen * screen = new SimpleScreen( id, size, pos, false, this);
|
||||
m_screens.append(screen);
|
||||
|
||||
const QStringList outputIds = m_interface->outputs(id);
|
||||
foreach (const QString& outputId, outputIds) {
|
||||
Output * output = Outputs::self()->output(outputId);
|
||||
if (output) {
|
||||
screen->_outputs() << output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connect(m_interface, SIGNAL(screenResized(int)), this, SLOT(screenResizedSlot(int)));
|
||||
connect(m_interface, SIGNAL(screenMoved(int)), this, SLOT(screenMovedSlot(int)));
|
||||
connect(m_interface, SIGNAL(screenAdded(int)), this, SLOT(screenAddedSlot(int)));
|
||||
connect(m_interface, SIGNAL(screenRemoved(int)), this, SLOT(screenRemovedSlot(int)));
|
||||
}
|
||||
|
||||
void DBusScreens::screenResizedSlot(int id) {
|
||||
SimpleScreen * s = (SimpleScreen *) screen(id);
|
||||
if (s) {
|
||||
QSize prev = s->size();
|
||||
s->_setSize(m_interface->size(id));
|
||||
emit screenResized(s, prev, s->size());
|
||||
}
|
||||
}
|
||||
|
||||
void DBusScreens::screenMovedSlot(int id) {
|
||||
SimpleScreen * s = (SimpleScreen *) screen(id);
|
||||
if (s) {
|
||||
QPoint prev = s->position();
|
||||
s->_setPosition(m_interface->position(id));
|
||||
emit screenMoved(s, prev, s->position());
|
||||
}
|
||||
}
|
||||
|
||||
void DBusScreens::screenAddedSlot(int id) {
|
||||
QPoint pos = m_interface->position(id);
|
||||
QSize size = m_interface->size(id);
|
||||
//qDebug() << "adding a screen" << id << "with geom: " << pos << size;
|
||||
|
||||
SimpleScreen * screen = new SimpleScreen(id, size, pos, false, this);
|
||||
m_screens.append(screen);
|
||||
|
||||
const QStringList outputIds = m_interface->outputs(id);
|
||||
foreach (const QString& outputId, outputIds) {
|
||||
Output * output = Outputs::self()->output(outputId);
|
||||
if (output) {
|
||||
screen->_outputs() << output;
|
||||
}
|
||||
}
|
||||
|
||||
emit screenAdded(screen);
|
||||
}
|
||||
|
||||
void DBusScreens::screenRemovedSlot(int id) {
|
||||
SimpleScreen * s = (SimpleScreen *) screen(id);
|
||||
if (s) {
|
||||
m_screens.removeAll(s);
|
||||
delete s;
|
||||
emit screenRemoved(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DBusScreens::~DBusScreens() {
|
||||
foreach(Screen * screen, m_screens) {
|
||||
delete screen;
|
||||
}
|
||||
m_screens.clear();
|
||||
}
|
||||
|
||||
QList<Screen *> DBusScreens::screens()
|
||||
{
|
||||
QList<Screen *> result;
|
||||
foreach(SimpleScreen * screen, m_screens) {
|
||||
result.append(screen);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DBusScreens::isValid() {
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_DBUSSCREENS_H
|
||||
#define KEPHAL_DBUSSCREENS_H
|
||||
|
||||
#include "screens.h"
|
||||
|
||||
class OrgKdeKephalScreensInterface;
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class SimpleScreen;
|
||||
/**
|
||||
* Client stub to Screens as provided by the Kephal service
|
||||
*/
|
||||
class DBusScreens : public Screens {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DBusScreens(QObject * parent);
|
||||
~DBusScreens();
|
||||
virtual QList<Screen *> screens();
|
||||
bool isValid();
|
||||
|
||||
private Q_SLOTS:
|
||||
void screenResizedSlot(int id);
|
||||
void screenMovedSlot(int id);
|
||||
void screenAddedSlot(int id);
|
||||
void screenRemovedSlot(int id);
|
||||
|
||||
private:
|
||||
QList<SimpleScreen *> m_screens;
|
||||
OrgKdeKephalScreensInterface * m_interface;
|
||||
bool m_valid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_DBUSSCREENS_H
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDBusInterface>
|
||||
|
||||
//#include "dbusscreens.h"
|
||||
//#include "dbusoutputs.h"
|
||||
//#include "dbusconfigurations.h"
|
||||
//include "noconfigurations.h"
|
||||
//#include "outputscreens.h"
|
||||
//include "desktopwidgetoutputs.h"
|
||||
#include "desktopwidgetscreens.h"
|
||||
|
||||
using namespace Kephal;
|
||||
|
||||
|
||||
/**
|
||||
* This factory-method is invoked the first time any of Screens::self(),
|
||||
* Outputs::self() or Configurations::self() is called.
|
||||
* It will create the singleton-instances and check for their validity.
|
||||
* If the dbus-based implementations are not valid a fallback to
|
||||
* QDesktopWidget will be used instead.
|
||||
*
|
||||
* The method is hooked into the ...::self()-methods with these lines
|
||||
* in the cmake-file:
|
||||
* ADD_DEFINITIONS (-DSCREENS_FACTORY=libkephal_factory)
|
||||
* ADD_DEFINITIONS (-DOUTPUTS_FACTORY=libkephal_factory)
|
||||
* ADD_DEFINITIONS (-DCONFIGURATIONS_FACTORY=libkephal_factory)
|
||||
*/
|
||||
void libkephal_factory() {
|
||||
//qDebug() << "trying to access kephald...";
|
||||
//QDBusInterface interface("org.kde.kded", "/modules/kephal");
|
||||
|
||||
//#DBusConfigurations * configurations = new DBusConfigurations(qApp);
|
||||
//DBusOutputs * outputs = new DBusOutputs(qApp);
|
||||
DesktopWidgetScreens * screens = new DesktopWidgetScreens(qApp);
|
||||
if (false/*(! screens->isValid()) || (! outputs->isValid()) || (! configurations->isValid())*/) {
|
||||
qWarning() << "could not access kephald, falling back to QDesktopWidget";
|
||||
|
||||
delete screens;
|
||||
//delete outputs;
|
||||
//delete configurations;
|
||||
|
||||
//new NoConfigurations(qApp);
|
||||
//new DesktopWidgetOutputs(qApp);
|
||||
//new OutputScreens(qApp);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "noconfigurations.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
SimpleConfiguration::SimpleConfiguration(NoConfigurations * parent)
|
||||
: Configuration(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString SimpleConfiguration::name() {
|
||||
return "simple";
|
||||
}
|
||||
|
||||
bool SimpleConfiguration::isModifiable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SimpleConfiguration::isActivated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
QMap<int, QPoint> SimpleConfiguration::layout() {
|
||||
return QMap<int, QPoint>();
|
||||
}
|
||||
|
||||
void SimpleConfiguration::activate() {
|
||||
}
|
||||
|
||||
int SimpleConfiguration::primaryScreen() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NoConfigurations::NoConfigurations(QObject * parent)
|
||||
: Configurations(parent)
|
||||
{
|
||||
m_config = new SimpleConfiguration(this);
|
||||
}
|
||||
|
||||
QMap<QString, Configuration *> NoConfigurations::configurations() {
|
||||
QMap<QString, Configuration *> result;
|
||||
result.insert(m_config->name(), m_config);
|
||||
return result;
|
||||
}
|
||||
|
||||
Configuration * NoConfigurations::findConfiguration() {
|
||||
return m_config;
|
||||
}
|
||||
|
||||
Configuration * NoConfigurations::activeConfiguration() {
|
||||
return m_config;
|
||||
}
|
||||
|
||||
QList<Configuration *> NoConfigurations::alternateConfigurations() {
|
||||
return QList<Configuration *>();
|
||||
}
|
||||
|
||||
QList<QPoint> NoConfigurations::possiblePositions(const Output * output) {
|
||||
Q_UNUSED(output)
|
||||
return QList<QPoint>();
|
||||
}
|
||||
|
||||
bool NoConfigurations::move(Output * output, const QPoint & position) {
|
||||
Q_UNUSED(output)
|
||||
Q_UNUSED(position)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NoConfigurations::resize(Output * output, const QSize & size) {
|
||||
Q_UNUSED(output)
|
||||
Q_UNUSED(size)
|
||||
return false;
|
||||
}
|
||||
|
||||
int NoConfigurations::screen(Output * output) {
|
||||
Q_UNUSED(output)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void NoConfigurations::applyOutputSettings() {
|
||||
}
|
||||
|
||||
bool NoConfigurations::rotate(Output * output, Rotation rotation) {
|
||||
Q_UNUSED(output)
|
||||
Q_UNUSED(rotation)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NoConfigurations::changeRate(Output * output, float rate) {
|
||||
Q_UNUSED(output)
|
||||
Q_UNUSED(rate)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NoConfigurations::reflectX(Output * output, bool reflect) {
|
||||
Q_UNUSED(output)
|
||||
Q_UNUSED(reflect)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NoConfigurations::reflectY(Output * output, bool reflect) {
|
||||
Q_UNUSED(output)
|
||||
Q_UNUSED(reflect)
|
||||
return false;
|
||||
}
|
||||
|
||||
void NoConfigurations::setPolling(bool polling) {
|
||||
Q_UNUSED(polling)
|
||||
}
|
||||
|
||||
bool NoConfigurations::polling() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void NoConfigurations::confirm() {
|
||||
}
|
||||
|
||||
void NoConfigurations::revert() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_NOCONFIGURATIONS_H
|
||||
#define KEPHAL_NOCONFIGURATIONS_H
|
||||
|
||||
#include "configurations.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class NoConfigurations;
|
||||
|
||||
/**
|
||||
* Dummy Configuration object for NoConfigurations to return
|
||||
*/
|
||||
class SimpleConfiguration : public Configuration {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SimpleConfiguration(NoConfigurations * parent);
|
||||
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
QString name() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
bool isModifiable() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
bool isActivated() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
QMap<int, QPoint> layout() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
int primaryScreen() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void activate();
|
||||
};
|
||||
|
||||
/**
|
||||
* Dummy Configurations to use when no real backend is available
|
||||
*/
|
||||
class NoConfigurations : public Configurations {
|
||||
Q_OBJECT
|
||||
public:
|
||||
NoConfigurations(QObject * parent);
|
||||
|
||||
QMap<QString, Configuration *> configurations();
|
||||
Configuration * findConfiguration();
|
||||
Configuration * activeConfiguration();
|
||||
QList<Configuration *> alternateConfigurations();
|
||||
QList<QPoint> possiblePositions(const Output * output);
|
||||
bool move(Output * output, const QPoint & position);
|
||||
bool resize(Output * output, const QSize & size);
|
||||
bool rotate(Output * output, Rotation rotation);
|
||||
bool changeRate(Output * output, float rate);
|
||||
bool reflectX(Output * output, bool reflect);
|
||||
bool reflectY(Output * output, bool reflect);
|
||||
int screen(Output * output);
|
||||
void applyOutputSettings();
|
||||
void setPolling(bool polling);
|
||||
bool polling() const;
|
||||
void confirm();
|
||||
void revert();
|
||||
|
||||
private:
|
||||
SimpleConfiguration * m_config;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KEPHAL_NOCONFIGURATIONS_H
|
||||
|
|
@ -1 +0,0 @@
|
|||
#cmakedefine HAS_RANDR_1_2 1
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "configurations.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QRegExp>
|
||||
|
||||
#ifdef CONFIGURATIONS_FACTORY
|
||||
void CONFIGURATIONS_FACTORY();
|
||||
#endif
|
||||
|
||||
#include "outputs.h"
|
||||
#include "screens.h"
|
||||
//#include "backend.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
Configurations * Configurations::self() {
|
||||
#ifdef CONFIGURATIONS_FACTORY
|
||||
if (Configurations::s_instance == 0) {
|
||||
CONFIGURATIONS_FACTORY();
|
||||
}
|
||||
#endif
|
||||
return Configurations::s_instance;
|
||||
}
|
||||
|
||||
Configurations::Configurations(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
Configurations::s_instance = this;
|
||||
}
|
||||
|
||||
Configurations::~Configurations()
|
||||
{
|
||||
Configurations::s_instance = 0;
|
||||
}
|
||||
|
||||
Configurations * Configurations::s_instance = 0;
|
||||
|
||||
Configuration * Configurations::configuration(QString name)
|
||||
{
|
||||
foreach (Configuration * config, configurations()) {
|
||||
if (config->name() == name) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Configurations::translateOrigin(QMap<int, QPoint> & layout)
|
||||
{
|
||||
QPoint origin;
|
||||
bool first = true;
|
||||
for (QMap<int, QPoint>::const_iterator i = layout.constBegin(); i != layout.constEnd(); ++i) {
|
||||
if (first || (i.value().x() < origin.x())) {
|
||||
origin.setX(i.value().x());
|
||||
}
|
||||
if (first || (i.value().y() < origin.y())) {
|
||||
origin.setY(i.value().y());
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
translateOrigin(layout, origin);
|
||||
}
|
||||
|
||||
void Configurations::translateOrigin(QMap<int, QPoint> & layout, QPoint origin) {
|
||||
for (QMap<int, QPoint>::iterator i = layout.begin(); i != layout.end(); ++i) {
|
||||
i.value() -= origin;
|
||||
}
|
||||
}
|
||||
|
||||
void Configurations::translateOrigin(QMap<int, QRect> & layout) {
|
||||
QPoint origin;
|
||||
bool first = true;
|
||||
for (QMap<int, QRect>::const_iterator i = layout.constBegin(); i != layout.constEnd(); ++i) {
|
||||
if (first || (i.value().x() < origin.x())) {
|
||||
origin.setX(i.value().x());
|
||||
}
|
||||
if (first || (i.value().y() < origin.y())) {
|
||||
origin.setY(i.value().y());
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
translateOrigin(layout, origin);
|
||||
}
|
||||
|
||||
void Configurations::translateOrigin(QMap<int, QRect> & layout, QPoint origin) {
|
||||
QPoint offset(0, 0);
|
||||
offset -= origin;
|
||||
for (QMap<int, QRect>::iterator i = layout.begin(); i != layout.end(); ++i) {
|
||||
i.value().translate(offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Configuration::Configuration(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_CONFIGURATIONS_H
|
||||
#define KEPHAL_CONFIGURATIONS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
#include "kephal.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class Output;
|
||||
|
||||
|
||||
/**
|
||||
* A Configuration allows to change settings that
|
||||
* control which Output belongs to which Screen or
|
||||
* is inactive.
|
||||
*/
|
||||
class Configuration : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Configuration(QObject * parent);
|
||||
virtual ~Configuration() {}
|
||||
|
||||
/**
|
||||
* The name of the Configuration.
|
||||
* This name uniquely identifies the
|
||||
* Configuration.
|
||||
*/
|
||||
virtual QString name() const = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this Configuration
|
||||
* can be modified.
|
||||
* This includes the layout and settings
|
||||
* like privacy-mode and primary Screen.
|
||||
*/
|
||||
virtual bool isModifiable() const = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this Configuration is
|
||||
* currently active.
|
||||
* Only 1 Configuration can be active at
|
||||
* any time.
|
||||
*/
|
||||
virtual bool isActivated() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the layout as Screens of size
|
||||
* 1x1.
|
||||
*/
|
||||
virtual QMap<int, QPoint> layout() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the id of the primary Screen for
|
||||
* this Configuration.
|
||||
*/
|
||||
virtual int primaryScreen() const = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Activate this Configuration.
|
||||
*/
|
||||
virtual void activate() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Configurations is the entrance-point to all
|
||||
* Configuration related operations.
|
||||
* Use: Configurations::self() to obtain the currently
|
||||
* active instance.
|
||||
*/
|
||||
class Configurations : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Returns the currently active
|
||||
* instance.
|
||||
*/
|
||||
static Configurations * self();
|
||||
|
||||
Configurations(QObject * parent);
|
||||
virtual ~Configurations();
|
||||
|
||||
/**
|
||||
* Returns a list of all known Configurations.
|
||||
*/
|
||||
virtual QMap<QString, Configuration *> configurations() = 0;
|
||||
|
||||
/**
|
||||
* Returns the currently active Configuration.
|
||||
*/
|
||||
virtual Configuration * activeConfiguration() = 0;
|
||||
|
||||
/**
|
||||
* Returns a list of all alternate Configuratios
|
||||
* for the currently connected Outputs.
|
||||
*/
|
||||
virtual QList<Configuration *> alternateConfigurations() = 0;
|
||||
|
||||
/**
|
||||
* Returns the list of all positions in pixels
|
||||
* for the Output output.
|
||||
* These are the only positions that can be
|
||||
* passed to move().
|
||||
*/
|
||||
virtual QList<QPoint> possiblePositions(Output * output) = 0;
|
||||
|
||||
/**
|
||||
* Find a Configuration by its name.
|
||||
* This returns 0 if the name is not known.
|
||||
*/
|
||||
virtual Configuration * configuration(QString name);
|
||||
|
||||
/**
|
||||
* Return the id of the Screen this Output should
|
||||
* belong to.
|
||||
*/
|
||||
virtual int screen(Output * output) = 0;
|
||||
|
||||
virtual void setPolling(bool polling) = 0;
|
||||
virtual bool polling() const = 0;
|
||||
|
||||
virtual void confirm() = 0;
|
||||
virtual void revert() = 0;
|
||||
|
||||
//virtual StatusMessage * status() = 0;
|
||||
|
||||
static void translateOrigin(QMap<int, QPoint> & layout);
|
||||
static void translateOrigin(QMap<int, QPoint> & layout, QPoint origin);
|
||||
static void translateOrigin(QMap<int, QRect> & layout);
|
||||
static void translateOrigin(QMap<int, QRect> & layout, QPoint origin);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when the active
|
||||
* Configuration is changed.
|
||||
*/
|
||||
void configurationActivated(Kephal::Configuration * configuration);
|
||||
|
||||
void pollingActivated();
|
||||
void pollingDeactivated();
|
||||
|
||||
void confirmTimeout(int seconds);
|
||||
void confirmed();
|
||||
void reverted();
|
||||
|
||||
protected:
|
||||
static Configurations * s_instance;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_CONFIGURATIONS_H
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "desktopwidgetoutputs.h"
|
||||
#include "simpleoutput.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
DesktopWidgetOutputs::DesktopWidgetOutputs(QObject * parent)
|
||||
: Outputs(parent)
|
||||
{
|
||||
QDesktopWidget * desktop = QApplication::desktop();
|
||||
for (int i = 0; i < desktop->numScreens(); i++) {
|
||||
/* This also looks wrong; all screens will receive id i*/
|
||||
/*
|
||||
if (! isVirtual) {
|
||||
i = desktop->primaryScreen();
|
||||
}
|
||||
*/
|
||||
|
||||
QRect geom = desktop->screenGeometry(i);
|
||||
qDebug() << "adding an output" << i << "with geom: " << geom;
|
||||
|
||||
SimpleOutput * output = new SimpleOutput(this,
|
||||
"SCREEN-" + QString::number(i),
|
||||
geom.size(),
|
||||
geom.topLeft(),
|
||||
true,
|
||||
true);
|
||||
m_outputs.append(output);
|
||||
|
||||
/* See above, this only ensures the loop exits with multiple screens*/
|
||||
/*
|
||||
if (! isVirtual) {
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
/* This is completely wrong, isVirtualDesktop() just returns true on x11 if Xinerama is in
|
||||
* use - adding 4 disconnected outputs here makes no sens
|
||||
*/
|
||||
/*
|
||||
if (isVirtual) {
|
||||
for (int i = desktop->numScreens(); i < 4; i++) {
|
||||
qDebug() << "adding a disconnected output" << i;
|
||||
|
||||
SimpleOutput * output = new SimpleOutput(this,
|
||||
"SCREEN-" + QString::number(i),
|
||||
QSize(0, 0),
|
||||
QPoint(0, 0),
|
||||
false,
|
||||
false);
|
||||
m_outputs.append(output);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
connect(desktop, SIGNAL(resized(int)), this, SLOT(screenChanged(int)));
|
||||
}
|
||||
|
||||
DesktopWidgetOutputs::~DesktopWidgetOutputs() {
|
||||
foreach(Output * output, m_outputs) {
|
||||
delete output;
|
||||
}
|
||||
m_outputs.clear();
|
||||
}
|
||||
|
||||
QList<Output *> DesktopWidgetOutputs::outputs()
|
||||
{
|
||||
QList<Output *> result;
|
||||
foreach(SimpleOutput * output, m_outputs) {
|
||||
result.append(output);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void DesktopWidgetOutputs::activateLayout(const QMap<Output *, QRect> & layout)
|
||||
{
|
||||
Q_UNUSED(layout)
|
||||
}
|
||||
|
||||
void DesktopWidgetOutputs::screenChanged(int screen)
|
||||
{
|
||||
Q_UNUSED(screen)
|
||||
|
||||
QDesktopWidget * desktop = QApplication::desktop();
|
||||
bool isVirtual = desktop->isVirtualDesktop();
|
||||
|
||||
if (isVirtual) {
|
||||
for(int i = m_outputs.size() - 1; i >= desktop->numScreens(); i--) {
|
||||
SimpleOutput * output = m_outputs.at(i);
|
||||
if (output->isConnected()) {
|
||||
qDebug() << "disconnecting output" << i;
|
||||
output->_setActivated(false);
|
||||
emit outputDeactivated(output);
|
||||
output->_setConnected(false);
|
||||
emit outputDisconnected(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < desktop->numScreens(); i++) {
|
||||
if (m_outputs.size() <= i) {
|
||||
m_outputs.append(new SimpleOutput(this,
|
||||
"SCREEN-" + QString::number(i),
|
||||
QSize(0, 0),
|
||||
QPoint(0, 0),
|
||||
false,
|
||||
false));
|
||||
}
|
||||
|
||||
SimpleOutput * output = m_outputs[i];
|
||||
if (! isVirtual) {
|
||||
i = desktop->primaryScreen();
|
||||
}
|
||||
|
||||
QRect geom = desktop->screenGeometry(i);
|
||||
if (! output->isConnected()) {
|
||||
output->_setConnected(true);
|
||||
output->_setActivated(true);
|
||||
output->_setPosition(geom.topLeft());
|
||||
output->_setSize(geom.size());
|
||||
|
||||
emit outputConnected(output);
|
||||
emit outputActivated(output);
|
||||
}
|
||||
if (output->position() != geom.topLeft()) {
|
||||
QPoint oldPos = output->position();
|
||||
QPoint newPos = geom.topLeft();
|
||||
qDebug() << "output" << i << "moved" << oldPos << "->" << newPos;
|
||||
|
||||
output->_setPosition(newPos);
|
||||
emit outputMoved(output, oldPos, newPos);
|
||||
}
|
||||
if (output->size() != geom.size()) {
|
||||
QSize oldSize = output->size();
|
||||
QSize newSize = geom.size();
|
||||
qDebug() << "output" << i << "resized" << oldSize << "->" << newSize;
|
||||
|
||||
output->_setSize(newSize);
|
||||
emit outputResized(output, oldSize, newSize);
|
||||
}
|
||||
|
||||
if (! isVirtual) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_DESKTOPWIDGETOUTPUTS_H
|
||||
#define KEPHAL_DESKTOPWIDGETOUTPUTS_H
|
||||
|
||||
#include "simpleoutput.h"
|
||||
|
||||
#include "kephal_export.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
/**
|
||||
* Fallback Outputs for when there is no XRandR
|
||||
* Although QDesktopWidget does not report outputs, this class
|
||||
* fakes them using the screens that QDesktopWidget reports
|
||||
*/
|
||||
class KEPHAL_EXPORT DesktopWidgetOutputs : public Outputs {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DesktopWidgetOutputs(QObject * parent);
|
||||
~DesktopWidgetOutputs();
|
||||
|
||||
QList<Output *> outputs();
|
||||
void activateLayout(const QMap<Output *, QRect> & layout);
|
||||
|
||||
private Q_SLOTS:
|
||||
void screenChanged(int screen);
|
||||
|
||||
private:
|
||||
QList<SimpleOutput *> m_outputs;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_DESKTOPWIDGETOUTPUTS_H
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
Copyright 2010 Will Stephenson <wstephenson@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) version 3 or any later version
|
||||
accepted by the membership of KDE e.V. (or its successor approved
|
||||
by the membership of KDE e.V.), which shall act as a proxy
|
||||
defined in Section 14 of version 3 of the license.
|
||||
|
||||
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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "desktopwidgetscreens.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
#include "simplescreen.h"
|
||||
|
||||
Kephal::DesktopWidgetScreens::DesktopWidgetScreens(QObject * parent)
|
||||
: Screens(parent)
|
||||
{
|
||||
QDesktopWidget * desktop = QApplication::desktop();
|
||||
connect(desktop, SIGNAL(screenCountChanged(int)), this, SLOT(handleScreenCountChanged(int)));
|
||||
connect(desktop, SIGNAL(resized(int)), this, SLOT(handleScreenResized(int)));
|
||||
|
||||
for (int i = 0; i < desktop->screenCount(); i++) {
|
||||
QRect geometry = desktop->screenGeometry(i);
|
||||
Kephal::SimpleScreen * screen =
|
||||
new Kephal::SimpleScreen(i, geometry.size(), geometry.topLeft(), false, this);
|
||||
m_screens.append(screen);
|
||||
}
|
||||
}
|
||||
|
||||
Kephal::DesktopWidgetScreens::~DesktopWidgetScreens()
|
||||
{
|
||||
foreach (Kephal::SimpleScreen * screen, m_screens) {
|
||||
int id = screen->id();
|
||||
delete screen;
|
||||
emit screenRemoved(id);
|
||||
}
|
||||
}
|
||||
|
||||
QList<Kephal::Screen*> Kephal::DesktopWidgetScreens::screens()
|
||||
{
|
||||
QList<Kephal::Screen*> list;
|
||||
foreach (Kephal::SimpleScreen * screen, m_screens) {
|
||||
list.append(screen);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void Kephal::DesktopWidgetScreens::handleScreenResized(int id)
|
||||
{
|
||||
Kephal::SimpleScreen * screen = m_screens.value(id);
|
||||
QSize oldSize = screen->size();
|
||||
QPoint oldPosition = screen->position();
|
||||
//FIXME: find a better way to restrict changing Screen to Screens - friend modifier class?
|
||||
screen->_setGeom(QApplication::desktop()->screenGeometry(id));
|
||||
if (oldSize != screen->size()) {
|
||||
emit screenResized(screen, oldSize, screen->size());
|
||||
}
|
||||
if (oldPosition != screen->position()) {
|
||||
emit screenMoved(screen, oldPosition, screen->position());
|
||||
}
|
||||
}
|
||||
|
||||
void Kephal::DesktopWidgetScreens::handleScreenCountChanged(int newCount)
|
||||
{
|
||||
// add new Screens
|
||||
for (int i = m_screens.count(); i < newCount; i++) {
|
||||
QRect geometry = QApplication::desktop()->screenGeometry(i);
|
||||
Kephal::SimpleScreen * screen =
|
||||
new Kephal::SimpleScreen(i, geometry.size(), geometry.topLeft(), false, this);
|
||||
m_screens.append(screen);
|
||||
emit screenAdded(screen);
|
||||
}
|
||||
|
||||
// remove no longer existing Screens
|
||||
while (m_screens.count() > newCount) {
|
||||
Kephal::SimpleScreen * screen = m_screens.takeLast();
|
||||
if (screen) {
|
||||
int id = screen->id();
|
||||
delete screen;
|
||||
emit screenRemoved(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim: sw=4 sts=4 et tw=100
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
Copyright 2010 Will Stephenson <wstephenson@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) version 3 or any later version
|
||||
accepted by the membership of KDE e.V. (or its successor approved
|
||||
by the membership of KDE e.V.), which shall act as a proxy
|
||||
defined in Section 14 of version 3 of the license.
|
||||
|
||||
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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DESKTOPWIDGETSCREENS_H
|
||||
#define DESKTOPWIDGETSCREENS_H
|
||||
|
||||
#include "screens.h"
|
||||
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace Kephal
|
||||
{
|
||||
|
||||
class SimpleScreen;
|
||||
|
||||
class DesktopWidgetScreens : public Screens
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DesktopWidgetScreens(QObject * parent = 0);
|
||||
virtual ~DesktopWidgetScreens();
|
||||
/**
|
||||
* @reimp Screens
|
||||
*/
|
||||
QList<Screen *> screens();
|
||||
protected Q_SLOTS:
|
||||
void handleScreenCountChanged(int);
|
||||
void handleScreenResized(int);
|
||||
private:
|
||||
QList<Kephal::SimpleScreen *> m_screens;
|
||||
};
|
||||
|
||||
} // namespace Kephal
|
||||
|
||||
#endif // DESKTOPWIDGETSCREENS_H
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_KEPHAL_H
|
||||
#define KEPHAL_KEPHAL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
|
||||
|
||||
#define CONFIRMATION_TIME 30
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
inline uint qHash(const QPoint & key) {
|
||||
return ((uint) (key.x() + 32767)) * 65536 + ((uint) (key.y() + 32767));
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
enum Position {
|
||||
RightOf,
|
||||
LeftOf,
|
||||
TopOf,
|
||||
BottomOf,
|
||||
SameAs
|
||||
};
|
||||
|
||||
enum Rotation {
|
||||
RotateNormal = 0, RotateRight = 90, RotateInverted = 180, RotateLeft = 270
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KEPHAL_KEPHAL_H
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2008 Laurent Montel <montel@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. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef KEPHAL_EXPORT_H
|
||||
#define KEPHAL_EXPORT_H
|
||||
|
||||
|
||||
/* needed for KDE_EXPORT and KDE_IMPORT macros */
|
||||
#include <kdemacros.h>
|
||||
|
||||
#ifndef KEPHAL_EXPORT
|
||||
# if defined(kded_kephal_EXPORTS) || defined(kephal_EXPORTS)
|
||||
/* We are building this library */
|
||||
# define KEPHAL_EXPORT KDE_EXPORT
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define KEPHAL_EXPORT KDE_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(kephal_NOT_EXPORTS)
|
||||
#undef KEPHAL_EXPORT
|
||||
#define KEPHAL_EXPORT
|
||||
#endif
|
||||
|
||||
# ifndef KEPHAL_EXPORT_DEPRECATED
|
||||
# define KEPHAL_EXPORT_DEPRECATED KDE_DEPRECATED KEPHAL_EXPORT
|
||||
# endif
|
||||
|
||||
#endif
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "outputs.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "screens.h"
|
||||
#include "configurations.h"
|
||||
|
||||
#ifdef OUTPUTS_FACTORY
|
||||
void OUTPUTS_FACTORY();
|
||||
#endif
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
Outputs * Outputs::self() {
|
||||
#ifdef OUTPUTS_FACTORY
|
||||
if (Outputs::s_instance == 0) {
|
||||
OUTPUTS_FACTORY();
|
||||
}
|
||||
#endif
|
||||
return Outputs::s_instance;
|
||||
}
|
||||
|
||||
Outputs::Outputs(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
Outputs::s_instance = this;
|
||||
}
|
||||
|
||||
Outputs::~Outputs() {
|
||||
Outputs::s_instance = 0;
|
||||
}
|
||||
|
||||
Output * Outputs::output(const QString & id) {
|
||||
foreach (Output * o, outputs()) {
|
||||
if (o->id() == id) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Outputs * Outputs::s_instance = 0;
|
||||
|
||||
|
||||
|
||||
Output::Output(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QRect Output::geom() const {
|
||||
return QRect(position(), size());
|
||||
}
|
||||
|
||||
// Outputs should not know about Screens
|
||||
Screen * Output::screen() const {
|
||||
if (! isActivated()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach (Screen * screen, Screens::self()->screens()) {
|
||||
Output * out = const_cast<Output*>(this);
|
||||
if (screen->outputs().contains(out)) {
|
||||
return screen;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
QList<QPoint> Output::availablePositions() {
|
||||
return QList<QPoint>();
|
||||
//return Configurations::self()->possiblePositions(this);
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Output::move(const QPoint & position) {
|
||||
return Configurations::self()->move(this, position);
|
||||
}
|
||||
|
||||
bool Output::resize(const QSize & size) {
|
||||
return Configurations::self()->resize(this, size);
|
||||
}
|
||||
|
||||
bool Output::rotate(Rotation rotation) {
|
||||
return Configurations::self()->rotate(this, rotation);
|
||||
}
|
||||
|
||||
bool Output::reflectX(bool reflect) {
|
||||
return Configurations::self()->reflectX(this, reflect);
|
||||
}
|
||||
|
||||
bool Output::reflectY(bool reflect) {
|
||||
return Configurations::self()->reflectY(this, reflect);
|
||||
}
|
||||
|
||||
bool Output::changeRate(double rate) {
|
||||
return Configurations::self()->changeRate(this, rate);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,283 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_OUTPUTS_H
|
||||
#define KEPHAL_OUTPUTS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
#include "kephal.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class Screen;
|
||||
|
||||
|
||||
/**
|
||||
* An Output is the actual connector and a
|
||||
* possibly connected monitor, such as
|
||||
* VGA, LVDS, TMDS-1.
|
||||
* This is most important for changing any
|
||||
* settings of the current setup.
|
||||
*/
|
||||
class Output : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Output(QObject * parent);
|
||||
|
||||
/**
|
||||
* Returns the id of the Output.
|
||||
*
|
||||
* In case of XRandR 1.2 these will
|
||||
* be the names such as: VGA, LVDS,
|
||||
* TMDS-1.
|
||||
*/
|
||||
virtual QString id() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the actual size in pixels
|
||||
* if the Output is active.
|
||||
*/
|
||||
virtual QSize size() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the actual position in
|
||||
* pixels if the Output is active.
|
||||
*/
|
||||
virtual QPoint position() const = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this Output is
|
||||
* currently connected to a
|
||||
* monitor.
|
||||
*/
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this Output is
|
||||
* currently activated and part
|
||||
* of a Screen.
|
||||
*/
|
||||
virtual bool isActivated() const = 0;
|
||||
|
||||
/**
|
||||
* Returns a list of sizes, which
|
||||
* are supported by this Output.
|
||||
* This depends on the connected
|
||||
* monitor.
|
||||
*/
|
||||
virtual QList<QSize> availableSizes() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the vendor-code as
|
||||
* it is part of the EDID-block.
|
||||
*/
|
||||
virtual QString vendor() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the product-id as
|
||||
* it is part of the EDID-block.
|
||||
*/
|
||||
virtual int productId() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the serial-number as
|
||||
* it is part of the EDID-block.
|
||||
*/
|
||||
virtual unsigned int serialNumber() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the preferred size of
|
||||
* this Output. This depends on
|
||||
* the connected monitor.
|
||||
*/
|
||||
virtual QSize preferredSize() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the current rotation of
|
||||
* this Output.
|
||||
*/
|
||||
virtual Rotation rotation() const = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this Output is
|
||||
* currently reflected over the
|
||||
* x-axis.
|
||||
*/
|
||||
virtual bool reflectX() const = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this Output is
|
||||
* currently reflected over the
|
||||
* y-axis.
|
||||
*/
|
||||
virtual bool reflectY() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the current refresh-rate
|
||||
* of this Output.
|
||||
*/
|
||||
virtual float rate() const = 0;
|
||||
|
||||
/**
|
||||
* Returns all possible refresh-rates
|
||||
* of this Output.
|
||||
* This depends on the connected
|
||||
* monitor.
|
||||
*/
|
||||
virtual QList<float> availableRates() const = 0;
|
||||
|
||||
/**
|
||||
* This is just a convenience
|
||||
* method for looking up the
|
||||
* Screen this Output belongs to.
|
||||
* Returns 0 if not active.
|
||||
* WILL Outputs should not know about Screens
|
||||
*/
|
||||
Screen * screen() const;
|
||||
|
||||
/**
|
||||
* This convenience method
|
||||
* returns size and position of
|
||||
* this Output if active.
|
||||
*/
|
||||
QRect geom() const;
|
||||
|
||||
/**
|
||||
* Returns all available
|
||||
* positions for this Output.
|
||||
* This depends on the
|
||||
* Configuration used and
|
||||
* the positions of the other
|
||||
* active Outputs.
|
||||
*/
|
||||
QList<QPoint> availablePositions();
|
||||
|
||||
virtual void resize(const QSize & size) = 0;
|
||||
|
||||
virtual void rotate(Rotation rotation) = 0;
|
||||
|
||||
virtual void setReflectX(bool reflect) = 0;
|
||||
|
||||
virtual void setReflectY(bool reflect) = 0;
|
||||
|
||||
virtual void changeRate(double rate) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Outputs is the entrance-point to all Output
|
||||
* related operations.
|
||||
* Use: Outputs::self() to obtain the currently
|
||||
* active instance.
|
||||
*/
|
||||
class Outputs : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Returns the currently active
|
||||
* instance.
|
||||
*/
|
||||
static Outputs * self();
|
||||
|
||||
Outputs(QObject * parent);
|
||||
virtual ~Outputs();
|
||||
|
||||
/**
|
||||
* Returns a list of all known Outputs,
|
||||
* even if they are inactive or
|
||||
* disconnected.
|
||||
*/
|
||||
virtual QList<Output *> outputs() = 0;
|
||||
|
||||
/**
|
||||
* Find an Output by its id.
|
||||
* Returns 0 if the id is not known.
|
||||
*/
|
||||
virtual Output * output(const QString & id);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when an Output
|
||||
* is connected.
|
||||
*/
|
||||
void outputConnected(Kephal::Output * o);
|
||||
|
||||
/**
|
||||
* This signal is emitted when an Output
|
||||
* is disconnected.
|
||||
*/
|
||||
void outputDisconnected(Kephal::Output * o);
|
||||
|
||||
/**
|
||||
* This signal is emitted when an Output
|
||||
* is activated.
|
||||
*/
|
||||
void outputActivated(Kephal::Output * o);
|
||||
|
||||
/**
|
||||
* This signal is emitted when an Output
|
||||
* is deactivated.
|
||||
*/
|
||||
void outputDeactivated(Kephal::Output * o);
|
||||
|
||||
/**
|
||||
* This signal is emitted when an Output
|
||||
* is resized from oldSize to newSize.
|
||||
*/
|
||||
void outputResized(Kephal::Output * o, QSize oldSize, QSize newSize);
|
||||
|
||||
/**
|
||||
* This signal is emitted when an Output
|
||||
* is moved on the framebuffer from
|
||||
* oldPosition to newPosition.
|
||||
*/
|
||||
void outputMoved(Kephal::Output * o, QPoint oldPosition, QPoint newPosition);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the refresh-rate
|
||||
* of Output o changes.
|
||||
*/
|
||||
void outputRateChanged(Kephal::Output * o, float oldRate, float newRate);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the rotation of
|
||||
* Output o changes.
|
||||
*/
|
||||
void outputRotated(Kephal::Output * o, Kephal::Rotation oldRotation, Kephal::Rotation newRotation);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the reflection
|
||||
* state of Output o is changed.
|
||||
*/
|
||||
void outputReflected(Kephal::Output * o, bool oldX, bool oldY, bool newX, bool newY);
|
||||
|
||||
protected:
|
||||
static Outputs * s_instance;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_OUTPUTS_H
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "screens.h"
|
||||
#include "configurations.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#ifdef SCREENS_FACTORY
|
||||
void SCREENS_FACTORY();
|
||||
#endif
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
Screens * Screens::self() {
|
||||
#ifdef SCREENS_FACTORY
|
||||
if (Screens::s_instance == 0) {
|
||||
SCREENS_FACTORY();
|
||||
}
|
||||
#endif
|
||||
return Screens::s_instance;
|
||||
}
|
||||
|
||||
Screens::Screens(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
Screens::s_instance = this;
|
||||
}
|
||||
|
||||
Screens::~Screens()
|
||||
{
|
||||
Screens::s_instance = 0;
|
||||
}
|
||||
|
||||
Screen * Screens::screen(int id) {
|
||||
foreach (Screen * screen, screens()) {
|
||||
if (screen->id() == id) {
|
||||
return screen;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Screen * Screens::primaryScreen()
|
||||
{
|
||||
#if 1
|
||||
return screen(QApplication::desktop()->primaryScreen());
|
||||
#else
|
||||
Configuration * config = Configurations::self()->activeConfiguration();
|
||||
if (! config) {
|
||||
return 0;
|
||||
}
|
||||
int id = config->primaryScreen();
|
||||
|
||||
return screen(id);
|
||||
#endif
|
||||
}
|
||||
|
||||
Screens * Screens::s_instance = 0;
|
||||
|
||||
|
||||
|
||||
Screen::Screen(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QRect Screen::geom() {
|
||||
return QRect(position(), size());
|
||||
}
|
||||
|
||||
bool Screen::isPrimary() const {
|
||||
return Screens::self()->primaryScreen() == this;
|
||||
}
|
||||
|
||||
int ScreenUtils::numScreens() {
|
||||
return Screens::self()->screens().size();
|
||||
}
|
||||
|
||||
QRect ScreenUtils::screenGeometry(int id) {
|
||||
if (id >= numScreens())
|
||||
return QRect();
|
||||
|
||||
if (id == -1)
|
||||
return QApplication::desktop()->screenGeometry();
|
||||
else
|
||||
return Screens::self()->screen(id)->geom();
|
||||
}
|
||||
|
||||
QSize ScreenUtils::screenSize(int id) {
|
||||
if (id >= numScreens())
|
||||
return QSize();
|
||||
|
||||
if (id == -1)
|
||||
return QApplication::desktop()->screenGeometry().size();
|
||||
else
|
||||
return Screens::self()->screen(id)->size();
|
||||
}
|
||||
|
||||
QRect ScreenUtils::desktopGeometry() {
|
||||
//QApplication::desktop()->geometry() was used before,
|
||||
//but returns the wrong size just after a screen has been added
|
||||
QRect desktopRect;
|
||||
for(int i = 0; i < numScreens(); i++){
|
||||
desktopRect |= screenGeometry(i);
|
||||
}
|
||||
|
||||
return desktopRect;
|
||||
}
|
||||
|
||||
int ScreenUtils::distance(const QRect & r, const QPoint & p) {
|
||||
if (! r.isValid()) {
|
||||
return p.manhattanLength();
|
||||
} else if (r.contains(p)) {
|
||||
return 0;
|
||||
} else if (p.x() >= r.left() && p.x() <= r.right()) {
|
||||
return p.y() < r.top() ? (r.top() - p.y()) : (p.y() - r.bottom());
|
||||
} else if (p.y() >= r.top() && p.y() <= r.bottom()) {
|
||||
return p.x() < r.left() ? (r.left() - p.x()) : (p.x() - r.right());
|
||||
} else if (p.x() < r.left()) {
|
||||
return ((p.y() < r.top() ? r.topLeft() : r.bottomLeft()) - p).manhattanLength();
|
||||
} else {
|
||||
return ((p.y() < r.top() ? r.topRight() : r.bottomRight()) - p).manhattanLength();
|
||||
}
|
||||
}
|
||||
|
||||
int ScreenUtils::screenId(QPoint p) {
|
||||
if (numScreens() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int minDist = distance(screenGeometry(0), p);
|
||||
int minScreen = 0;
|
||||
|
||||
for(int i = 1; i < numScreens() && minDist > 0; i++) {
|
||||
int dist = distance(screenGeometry(i), p);
|
||||
if (dist < minDist) {
|
||||
minDist = dist;
|
||||
minScreen = i;
|
||||
}
|
||||
}
|
||||
|
||||
return minScreen;
|
||||
}
|
||||
|
||||
int ScreenUtils::primaryScreenId() {
|
||||
if (!Screens::self()->primaryScreen()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Screens::self()->primaryScreen()->id();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_SCREENS_H
|
||||
#define KEPHAL_SCREENS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
#include "kephal_export.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class Output;
|
||||
|
||||
|
||||
/**
|
||||
* A Screen is the area that is significant for
|
||||
* displaying windows. or panels.
|
||||
* Every activated Output belongs to exactly one
|
||||
* Screen and is completely contained within that
|
||||
* Screen. No two Screens overlap each other.
|
||||
*
|
||||
* Hence:
|
||||
* 1 Output -> 1 Screen
|
||||
* 2 Non-overlapping Outputs -> 2 Screen
|
||||
* 2 Overlapping Outputs -> 1 Screen
|
||||
*/
|
||||
class KEPHAL_EXPORT Screen : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Screen(QObject * parent = 0);
|
||||
|
||||
/**
|
||||
* Returns the id of this Screen. The id
|
||||
* is part of the Configuration and will
|
||||
* be the same whenever the same Outputs
|
||||
* are used with the same Configuration.
|
||||
*/
|
||||
virtual int id() = 0;
|
||||
|
||||
/**
|
||||
* The actual size of the screen in pixels.
|
||||
* This is the smallest area possible, so
|
||||
* that all Outputs are completely
|
||||
* contained.
|
||||
*/
|
||||
virtual QSize size() = 0;
|
||||
|
||||
/**
|
||||
* The actual position on the framebuffer
|
||||
* in pixels.
|
||||
*/
|
||||
virtual QPoint position() = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this Screen is to be
|
||||
* considered in privacy-mode.
|
||||
* In this mode no content should be
|
||||
* displayed on that screen unless the
|
||||
* user forces this.
|
||||
*/
|
||||
virtual bool isPrivacyMode() = 0;
|
||||
|
||||
/**
|
||||
* Sets the state of the privacy-mode.
|
||||
*/
|
||||
virtual void setPrivacyMode(bool b) = 0;
|
||||
|
||||
/**
|
||||
* Return a list of Outputs that are
|
||||
* currently part of this Screen.
|
||||
*/
|
||||
virtual QList<Output *> outputs() = 0;
|
||||
|
||||
/**
|
||||
* Returns whether this screen is the
|
||||
* current primary screen.
|
||||
* This is just a convenience method,
|
||||
* since the real value is determined
|
||||
* by the configuration used.
|
||||
*/
|
||||
bool isPrimary() const;
|
||||
|
||||
/**
|
||||
* Make this Screen the primary one.
|
||||
* This just calls the appropriate
|
||||
* method in the Configuration.
|
||||
*/
|
||||
void setAsPrimary();
|
||||
|
||||
/**
|
||||
* Returns the position and size of the
|
||||
* Screen as QRect.
|
||||
* This is just a convenience method.
|
||||
*/
|
||||
QRect geom();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Screens is the entrance-point for all Screen-
|
||||
* related operations.
|
||||
* Use: Screens::self() for the currently
|
||||
* active instance.
|
||||
*/
|
||||
class KEPHAL_EXPORT Screens : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Returns the currently active instance.
|
||||
*/
|
||||
static Screens * self();
|
||||
|
||||
Screens(QObject * parent);
|
||||
virtual ~Screens();
|
||||
|
||||
/**
|
||||
* Returns the list of all current
|
||||
* Screens.
|
||||
* Every Screen has at least one Output
|
||||
* and a non-zero size.
|
||||
*/
|
||||
virtual QList<Screen *> screens() = 0;
|
||||
|
||||
/**
|
||||
* Find a Screen by its id.
|
||||
*/
|
||||
virtual Screen * screen(int id);
|
||||
|
||||
/**
|
||||
* Returns the current primary Screen.
|
||||
*/
|
||||
Screen * primaryScreen();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when a new
|
||||
* Screen appears, due to an Output
|
||||
* being activated or the Configuration
|
||||
* being changed.
|
||||
*/
|
||||
// QDW::screenCountChanged
|
||||
void screenAdded(Kephal::Screen * s);
|
||||
|
||||
/**
|
||||
* This signal is emitted when a
|
||||
* Screen disappears, due to an Output
|
||||
* being deactivated or the
|
||||
* Configuration being changed.
|
||||
*/
|
||||
// QDW::screenCountChanged
|
||||
void screenRemoved(int id);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the size
|
||||
* of the Screen changes.
|
||||
*/
|
||||
// QDW::resized
|
||||
// TODO: move to Screen and replace with no args version
|
||||
void screenResized(Kephal::Screen * s, QSize oldSize, QSize newSize);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the
|
||||
* position of the Screen changes.
|
||||
*/
|
||||
// QDW::resized emitted when position changes too - but not documented.
|
||||
// TODO: move to Screen and replace with no args version
|
||||
void screenMoved(Kephal::Screen * s, QPoint oldPosition, QPoint newPosition);
|
||||
|
||||
protected:
|
||||
static Screens * s_instance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines a handful help methods for common tasks
|
||||
*/
|
||||
class KEPHAL_EXPORT ScreenUtils {
|
||||
public:
|
||||
/** Returns the number of screens. */
|
||||
// PASSTHRU to QDW
|
||||
static int numScreens();
|
||||
|
||||
/** Returns the geometry of the given screen */
|
||||
// PASSTHRU to QDW
|
||||
static QRect screenGeometry(int id);
|
||||
|
||||
/** Returns the size of the given screen */
|
||||
// SYNTACTIC SUGAR around QDW
|
||||
static QSize screenSize(int id);
|
||||
|
||||
/** Returns the geometry of the whole desktop */
|
||||
// SYNTACTIC SUGAR around QApplication::desktop()->geometry()
|
||||
static QRect desktopGeometry();
|
||||
|
||||
/** Returns the id of the screen that contains the given point */
|
||||
// SYNTACTIC SUGAR around QDW::screenNumber()
|
||||
static int screenId(QPoint p);
|
||||
|
||||
/** Returns the id of the primary screen */
|
||||
// SYNTACTIC SUGAR around QDW::primaryScreen
|
||||
static int primaryScreenId();
|
||||
|
||||
private:
|
||||
static int distance(const QRect & r, const QPoint & p);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_SCREENS_H
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "simpleoutput.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
SimpleOutput::SimpleOutput(QObject * parent, QString id, QSize size, QPoint position, bool connected, bool activated)
|
||||
: Output(parent)
|
||||
{
|
||||
m_id = id;
|
||||
m_size = size;
|
||||
m_position = position;
|
||||
m_connected = connected;
|
||||
m_activated = activated;
|
||||
}
|
||||
|
||||
SimpleOutput::SimpleOutput(QObject * parent)
|
||||
: Output(parent),
|
||||
m_size(0, 0),
|
||||
m_position(0, 0),
|
||||
m_connected(false),
|
||||
m_activated(false)
|
||||
{
|
||||
}
|
||||
|
||||
SimpleOutput::SimpleOutput(QObject * parent, Output * output)
|
||||
: Output(parent)
|
||||
{
|
||||
m_id = output->id();
|
||||
m_size = output->size();
|
||||
m_position = output->position();
|
||||
m_connected = output->isConnected();
|
||||
m_activated = output->isActivated();
|
||||
}
|
||||
|
||||
|
||||
QString SimpleOutput::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QSize SimpleOutput::size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
QList<QSize> SimpleOutput::availableSizes() const {
|
||||
if (m_availableSizes.empty()) {
|
||||
QList<QSize> result;
|
||||
result.append(size());
|
||||
return result;
|
||||
}
|
||||
return m_availableSizes;
|
||||
}
|
||||
|
||||
QPoint SimpleOutput::position() const {
|
||||
return m_position;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void SimpleOutput::_setId(const QString & id) {
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setSize(const QSize & size) {
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setAvailableSizes(const QList<QSize> & sizes) {
|
||||
m_availableSizes = sizes;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setPosition(const QPoint & position) {
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setConnected(bool connected) {
|
||||
m_connected = connected;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setActivated(bool activated) {
|
||||
m_activated = activated;
|
||||
}
|
||||
|
||||
bool SimpleOutput::isConnected() {
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
bool SimpleOutput::isActivated() {
|
||||
return m_connected && m_activated;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setVendor(const QString & vendor) {
|
||||
m_vendor = vendor;
|
||||
}
|
||||
|
||||
QString SimpleOutput::vendor() {
|
||||
return m_vendor;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setProductId(int productId) {
|
||||
m_productId = productId;
|
||||
}
|
||||
|
||||
int SimpleOutput::productId() {
|
||||
return m_productId;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setSerialNumber(unsigned int serialNumber) {
|
||||
m_serialNumber = serialNumber;
|
||||
}
|
||||
|
||||
unsigned int SimpleOutput::serialNumber() {
|
||||
return m_serialNumber;
|
||||
}
|
||||
|
||||
QSize SimpleOutput::preferredSize() {
|
||||
return m_preferredSize;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setPreferredSize(const QSize & size) {
|
||||
m_preferredSize = size;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setRotation(Rotation rotation) {
|
||||
m_rotation = rotation;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setReflectX(bool reflect) {
|
||||
m_reflectX = reflect;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setReflectY(bool reflect) {
|
||||
m_reflectY = reflect;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setRate(float rate) {
|
||||
m_rate = rate;
|
||||
}
|
||||
|
||||
void SimpleOutput::_setAvailableRates(const QList<float> & rates) {
|
||||
m_rates = rates;
|
||||
}
|
||||
#endif
|
||||
Rotation SimpleOutput::rotation() const
|
||||
{
|
||||
return m_rotation;
|
||||
}
|
||||
|
||||
bool SimpleOutput::xReflected() const
|
||||
{
|
||||
return m_reflectX;
|
||||
}
|
||||
|
||||
bool SimpleOutput::yReflected() const
|
||||
{
|
||||
return m_reflectY;
|
||||
}
|
||||
|
||||
float SimpleOutput::rate() const
|
||||
{
|
||||
return m_rate;
|
||||
}
|
||||
|
||||
QList<float> SimpleOutput::availableRates() const
|
||||
{
|
||||
return m_rates;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_SIMPLEOUTPUT_H
|
||||
#define KEPHAL_SIMPLEOUTPUT_H
|
||||
|
||||
#include "outputs.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class SimpleOutput : public Output {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SimpleOutput(QObject * parent, QString id, QSize resolution, QPoint position, bool connected, bool activated);
|
||||
SimpleOutput(QObject * parent);
|
||||
SimpleOutput(QObject * parent, Output * output);
|
||||
|
||||
QString id() const;
|
||||
|
||||
QSize size() const;
|
||||
QSize preferredSize() const;
|
||||
QList<QSize> availableSizes() const;
|
||||
QPoint position() const;
|
||||
QString vendor() const;
|
||||
int productId() const;
|
||||
unsigned int serialNumber() const;
|
||||
|
||||
bool isConnected() const;
|
||||
bool isActivated() const;
|
||||
|
||||
Rotation rotation() const;
|
||||
bool xReflected() const;
|
||||
bool yReflected() const;
|
||||
float rate() const;
|
||||
|
||||
QList<float> availableRates() const;
|
||||
|
||||
#if 0
|
||||
void _setId(const QString & id);
|
||||
void _setSize(const QSize & size);
|
||||
void _setPreferredSize(const QSize & size);
|
||||
void _setAvailableSizes(const QList<QSize> & sizes);
|
||||
void _setPosition(const QPoint & position);
|
||||
void _setActivated(bool activated);
|
||||
void _setConnected(bool connected);
|
||||
void _setVendor(const QString & vendor);
|
||||
void _setProductId(int productId);
|
||||
void _setSerialNumber(unsigned int serialNumber);
|
||||
void _setRotation(Rotation rotation);
|
||||
void _setReflectX(bool reflect);
|
||||
void _setReflectY(bool reflect);
|
||||
void _setRate(float rate);
|
||||
void _setAvailableRates(const QList<float> & rates);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
QSize m_size;
|
||||
QSize m_preferredSize;
|
||||
QList<QSize> m_availableSizes;
|
||||
QPoint m_position;
|
||||
bool m_connected;
|
||||
bool m_activated;
|
||||
QString m_vendor;
|
||||
int m_productId;
|
||||
unsigned int m_serialNumber;
|
||||
Rotation m_rotation;
|
||||
bool m_reflectX;
|
||||
bool m_reflectY;
|
||||
float m_rate;
|
||||
QList<float> m_rates;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_SIMPLESCREEN_H
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "simplescreen.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
SimpleScreen::SimpleScreen(int id, const QSize & size, const QPoint & position, bool privacy, QObject * parent)
|
||||
: Screen(parent)
|
||||
{
|
||||
m_id = id;
|
||||
m_size = size;
|
||||
m_position = position;
|
||||
m_privacy = privacy;
|
||||
}
|
||||
|
||||
SimpleScreen::SimpleScreen(QObject * parent)
|
||||
: Screen(parent),
|
||||
m_id(-1),
|
||||
m_size(0, 0),
|
||||
m_position(0, 0),
|
||||
m_privacy(false)
|
||||
{
|
||||
}
|
||||
|
||||
SimpleScreen::~SimpleScreen()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int SimpleScreen::id()
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QSize SimpleScreen::size() {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
QPoint SimpleScreen::position() {
|
||||
return m_position;
|
||||
}
|
||||
|
||||
bool SimpleScreen::isPrivacyMode()
|
||||
{
|
||||
return m_privacy;
|
||||
}
|
||||
|
||||
void SimpleScreen::setPrivacyMode(bool privacy)
|
||||
{
|
||||
emit privacyModeChangeRequested(this, privacy);
|
||||
}
|
||||
|
||||
void SimpleScreen::_setId(int id) {
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
void SimpleScreen::_setSize(const QSize & size) {
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
void SimpleScreen::_setPosition(const QPoint & position)
|
||||
{
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
void SimpleScreen::_setGeom(const QRect & geom)
|
||||
{
|
||||
_setPosition(geom.topLeft());
|
||||
_setSize(geom.size());
|
||||
}
|
||||
|
||||
QList<Output *> SimpleScreen::outputs() {
|
||||
return m_outputs;
|
||||
}
|
||||
|
||||
QList<Output *> & SimpleScreen::_outputs() {
|
||||
return m_outputs;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_SIMPLESCREEN_H
|
||||
#define KEPHAL_SIMPLESCREEN_H
|
||||
|
||||
#include "screens.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class SimpleScreen : public Screen {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SimpleScreen(int id, const QSize & resolution, const QPoint & position, bool privacy, QObject * parent = 0);
|
||||
SimpleScreen(QObject * parent = 0);
|
||||
virtual ~SimpleScreen();
|
||||
virtual int id();
|
||||
|
||||
virtual QSize size();
|
||||
virtual QPoint position();
|
||||
|
||||
virtual bool isPrivacyMode();
|
||||
virtual void setPrivacyMode(bool b);
|
||||
|
||||
QList<Output *> outputs();
|
||||
|
||||
void _setId(int id);
|
||||
void _setSize(const QSize & size);
|
||||
void _setPosition(const QPoint & position);
|
||||
void _setGeom(const QRect & geom);
|
||||
QList<Output *> & _outputs();
|
||||
|
||||
Q_SIGNALS:
|
||||
void privacyModeChangeRequested(SimpleScreen * screen, bool privacy);
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
QSize m_size;
|
||||
QPoint m_position;
|
||||
bool m_privacy;
|
||||
QList<Output *> m_outputs;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_SIMPLESCREEN_H
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
include_directories(${kephal_SOURCE_DIR}/kephal)
|
||||
|
||||
configure_file (../kephal/config-kephal.h.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config-kephal.h)
|
||||
|
||||
set(kephalshared_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/outputs.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/screens.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/simplescreen.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/configurations.cpp
|
||||
)
|
||||
set(unused_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/simpleoutput.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../kephal/desktopwidgetoutputs.cpp
|
||||
)
|
||||
|
||||
set(kephal_service_SRCS
|
||||
${kephalshared_SRCS}
|
||||
kephalservice.cpp
|
||||
backendoutputs.cpp
|
||||
externalconfiguration.cpp
|
||||
xml/xmltype.cpp
|
||||
xml/configurations_xml.cpp
|
||||
xml/xmlnodehandler.cpp
|
||||
backendconfigurations.cpp
|
||||
xmlconfiguration.cpp
|
||||
xmlconfigurations.cpp
|
||||
)
|
||||
set(unused_SRCS
|
||||
configurationscreens.cpp
|
||||
outputscreens.cpp
|
||||
dbus/dbusapi_screens.cpp
|
||||
dbus/dbusapi_outputs.cpp
|
||||
dbus/dbusapi_configurations.cpp
|
||||
)
|
||||
|
||||
if(Q_WS_X11 AND XRANDR_1_2_FOUND)
|
||||
set(kephal_service_SRCS ${kephal_service_SRCS}
|
||||
xrandr12/randr.cpp
|
||||
xrandr12/randrscreen.cpp
|
||||
xrandr12/randroutput.cpp
|
||||
xrandr12/randrcrtc.cpp
|
||||
xrandr12/randrmode.cpp
|
||||
xrandr12/randrdisplay.cpp
|
||||
xrandroutputs.cpp
|
||||
)
|
||||
endif(Q_WS_X11 AND XRANDR_1_2_FOUND)
|
||||
|
||||
#QT4_GENERATE_DBUS_INTERFACE(dbus/dbusapi_screens.h org.kde.Kephal.Screens.xml)
|
||||
#QT4_GENERATE_DBUS_INTERFACE(dbus/dbusapi_outputs.h org.kde.Kephal.Outputs.xml)
|
||||
#QT4_GENERATE_DBUS_INTERFACE(dbus/dbusapi_configurations.h org.kde.Kephal.Configurations.xml)
|
||||
|
||||
#QT4_ADD_DBUS_ADAPTOR (kephal_service_SRCS
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Kephal.Screens.xml
|
||||
# dbus/dbusapi_screens.h DBusAPIScreens)
|
||||
#QT4_ADD_DBUS_ADAPTOR (kephal_service_SRCS
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Kephal.Outputs.xml
|
||||
# dbus/dbusapi_outputs.h DBusAPIOutputs)
|
||||
#QT4_ADD_DBUS_ADAPTOR (kephal_service_SRCS
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Kephal.Configurations.xml
|
||||
# dbus/dbusapi_configurations.h DBusAPIConfigurations)
|
||||
|
||||
set(kded_kephal_SRCS
|
||||
${kephal_service_SRCS}
|
||||
kephald.cpp
|
||||
)
|
||||
|
||||
set(service_libs ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY})
|
||||
if(Q_WS_X11 AND XRANDR_1_2_FOUND)
|
||||
set(service_libs ${service_libs} ${X11_Xrandr_LIB} ${X11_LIBRARIES})
|
||||
endif()
|
||||
|
||||
KDE4_ADD_PLUGIN(kded_kephal ${kded_kephal_SRCS})
|
||||
target_link_libraries(kded_kephal ${service_libs})
|
||||
|
||||
install(TARGETS kded_kephal DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
||||
|
||||
install(FILES kephal.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR}/kded)
|
|
@ -1,5 +0,0 @@
|
|||
This directory contains the Kephal service components.
|
||||
|
||||
The main component is a KDED module providing a DBUS interface to the Kephal Screens, Configurations and Outputs interfaces.
|
||||
|
||||
The same code is also built standalone as a an application for testing purposes. The resulting 'kephald' is not installed.
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_BACKEND_H
|
||||
#define KEPHAL_BACKEND_H
|
||||
|
||||
#define PROPERTY(type, name, setter) \
|
||||
private:\
|
||||
type m_##name;\
|
||||
public:\
|
||||
void setter(type name) { m_##name = name; }\
|
||||
type name() { return m_##name; }
|
||||
|
||||
|
||||
#define INVALID_CONFIGURATION(desc) kDebug() << "INVALID CONFIGURATION:" << desc;
|
||||
|
||||
#define CONFIGURATION_NOT_FOUND(name) kDebug() << "CONFIGURATION NOT FOUND:" << name;
|
||||
|
||||
#define FIX_ME(desc) kDebug() << "FIXME:" << desc;
|
||||
|
||||
#define OPERATION_FAILED(desc) kDebug() << "OPERATION FAILED:" << desc;
|
||||
|
||||
#endif // KEPHAL_BACKEND_H
|
|
@ -1,271 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "backendconfigurations.h"
|
||||
|
||||
#include "outputs.h"
|
||||
#include "backend.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
BackendConfigurations * BackendConfigurations::self() {
|
||||
return BackendConfigurations::s_instance;
|
||||
}
|
||||
|
||||
BackendConfigurations::BackendConfigurations(QObject * parent)
|
||||
: Configurations(parent)/*,
|
||||
m_status(new StatusMessage(this))*/
|
||||
{
|
||||
BackendConfigurations::s_instance = this;
|
||||
}
|
||||
|
||||
BackendConfigurations::~BackendConfigurations()
|
||||
{
|
||||
BackendConfigurations::s_instance = 0;
|
||||
}
|
||||
|
||||
BackendConfigurations * BackendConfigurations::s_instance = 0;
|
||||
|
||||
BackendConfiguration * BackendConfigurations::activeBackendConfiguration() {
|
||||
return (BackendConfiguration *) activeConfiguration();
|
||||
}
|
||||
|
||||
|
||||
|
||||
BackendConfiguration::BackendConfiguration(QObject * parent)
|
||||
: Configuration(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QMap<int, QRect> BackendConfiguration::realLayout() {
|
||||
QMap<Output *, int> outputScreens;
|
||||
foreach (Output * output, Outputs::self()->outputs()) {
|
||||
int screen = Configurations::self()->screen(output);
|
||||
outputScreens.insert(output, screen);
|
||||
}
|
||||
return realLayout(outputScreens);
|
||||
}
|
||||
|
||||
QMap<int, QRect> BackendConfiguration::realLayout(const QMap<Output *, int> & outputScreens) {
|
||||
QMap<int, QPoint> simpleLayout = layout();
|
||||
return realLayout(simpleLayout, outputScreens);
|
||||
}
|
||||
|
||||
QMap<int, QRect> BackendConfiguration::realLayout(const QMap<int, QPoint> & sLayout, const QMap<Output *, int> & outputScreens) {
|
||||
QMap<Output *, QSize> outputSizes;
|
||||
foreach (Output * output, outputScreens.keys()) {
|
||||
outputSizes.insert(output, output->isActivated() ? output->size() : output->preferredSize());
|
||||
}
|
||||
return realLayout(sLayout, outputScreens, outputSizes);
|
||||
}
|
||||
|
||||
QMap<int, QRect> BackendConfiguration::realLayout(const QMap<int, QPoint> & sLayout, const QMap<Output *, int> & outputScreens, const QMap<Output *, QSize> & outputSizes) {
|
||||
//kDebug() << "calculating real layout for:" << sLayout << outputScreens;
|
||||
|
||||
QMap<int, QRect> screens;
|
||||
QMap<int, QPoint> simpleLayout = sLayout;
|
||||
|
||||
QMap<int, QSize> screenSizes;
|
||||
foreach (int screen, simpleLayout.keys()) {
|
||||
screenSizes.insert(screen, QSize());
|
||||
}
|
||||
|
||||
foreach (Output * output, outputScreens.keys()) {
|
||||
if (outputScreens[output] < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! screenSizes.contains(outputScreens[output])) {
|
||||
INVALID_CONFIGURATION("outputs and configuration don't match");
|
||||
return screens;
|
||||
}
|
||||
screenSizes[outputScreens[output]] = screenSizes[outputScreens[output]].expandedTo(outputSizes[output]);
|
||||
}
|
||||
|
||||
int begin = simpleLayout.begin().key();
|
||||
screens.insert(begin, QRect(QPoint(0, 0), screenSizes[begin]));
|
||||
simpleToReal(simpleLayout, screenSizes, begin, screens);
|
||||
Configurations::translateOrigin(screens);
|
||||
|
||||
for (QMap<int, QRect>::const_iterator i = screens.constBegin(); i != screens.constEnd(); ++i) {
|
||||
for (QMap<int, QRect>::const_iterator j = (i + 1); j != screens.constEnd(); ++j) {
|
||||
if (i.value().intersects(j.value())) {
|
||||
INVALID_CONFIGURATION("overlapping screens");
|
||||
screens.clear();
|
||||
return screens;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return screens;
|
||||
}
|
||||
|
||||
void BackendConfiguration::simpleToReal(QMap<int, QPoint> & simpleLayout, const QMap<int, QSize> & screenSizes, int index, QMap<int, QRect> & screens) const {
|
||||
QPoint pos = simpleLayout.take(index);
|
||||
|
||||
// to the right
|
||||
QPoint nextPos(pos.x() + 1, pos.y());
|
||||
int nextIndex = simpleLayout.key(nextPos, -1);
|
||||
if (nextIndex >= 0) {
|
||||
screens.insert(nextIndex, QRect(screens[index].topRight() + QPoint(1, 0), screenSizes[nextIndex]));
|
||||
simpleToReal(simpleLayout, screenSizes, nextIndex, screens);
|
||||
}
|
||||
|
||||
// to the left
|
||||
nextPos = QPoint(pos.x() - 1, pos.y());
|
||||
nextIndex = simpleLayout.key(nextPos, -1);
|
||||
if (nextIndex >= 0) {
|
||||
QSize screenSize = screenSizes[nextIndex];
|
||||
screens.insert(nextIndex, QRect(screens[index].topLeft() - QPoint(screenSize.width(), 0), screenSize));
|
||||
simpleToReal(simpleLayout, screenSizes, nextIndex, screens);
|
||||
}
|
||||
|
||||
// to the bottom
|
||||
nextPos = QPoint(pos.x(), pos.y() + 1);
|
||||
nextIndex = simpleLayout.key(nextPos, -1);
|
||||
if (nextIndex >= 0) {
|
||||
screens.insert(nextIndex, QRect(screens[index].bottomLeft() + QPoint(0, 1), screenSizes[nextIndex]));
|
||||
simpleToReal(simpleLayout, screenSizes, nextIndex, screens);
|
||||
}
|
||||
|
||||
// to the top
|
||||
nextPos = QPoint(pos.x(), pos.y() - 1);
|
||||
nextIndex = simpleLayout.key(nextPos, -1);
|
||||
if (nextIndex >= 0) {
|
||||
QSize screenSize = screenSizes[nextIndex];
|
||||
screens.insert(nextIndex, QRect(screens[index].topLeft() - QPoint(0, screenSize.height()), screenSize));
|
||||
simpleToReal(simpleLayout, screenSizes, nextIndex, screens);
|
||||
}
|
||||
}
|
||||
|
||||
QMap<int, QPoint> BackendConfiguration::cloneLayout(int screen) {
|
||||
QSet<QPoint> positions = clonePositions(screen);
|
||||
QMap<int, QPoint> layout;
|
||||
int i = 0;
|
||||
foreach (const QPoint& p, positions) {
|
||||
layout.insert(i, p);
|
||||
++i;
|
||||
}
|
||||
|
||||
Configurations::translateOrigin(layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
QSet<QPoint> BackendConfiguration::clonePositions(int screen) {
|
||||
QList<QSet<QPoint> > partitions = partition(screen);
|
||||
if (partitions.size() == 1) {
|
||||
return partitions[0];
|
||||
}
|
||||
return QSet<QPoint>();
|
||||
}
|
||||
|
||||
QSet<QPoint> BackendConfiguration::positions() {
|
||||
QSet<QPoint> result;
|
||||
foreach (const QPoint& p, layout()) {
|
||||
result << p;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QSet<QPoint> BackendConfiguration::possiblePositions(int screen) const {
|
||||
QList<QSet<QPoint> > partitions = partition(screen);
|
||||
QSet<QPoint> result = border(partitions[0]);
|
||||
foreach (const QSet<QPoint> &partition, partitions) {
|
||||
result.intersect(border(partition));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*WILL: used by clonePositions and possiblePositions*/
|
||||
QList<QSet<QPoint> > BackendConfiguration::partition(int screen) const {
|
||||
QHash<QPoint, QSet<QPoint> * > partitions;
|
||||
QMap<int, QPoint> layout = this->layout();
|
||||
bool exclude = layout.contains(screen);
|
||||
QPoint excludePoint;
|
||||
if (exclude) {
|
||||
excludePoint = layout[screen];
|
||||
}
|
||||
foreach (const QPoint& p, layout) {
|
||||
if (exclude && (p == excludePoint)) {
|
||||
continue;
|
||||
}
|
||||
partitions.insert(p, new QSet<QPoint>());
|
||||
partitions[p]->insert(p);
|
||||
}
|
||||
|
||||
foreach (const QPoint& p, layout) {
|
||||
if (exclude && (p == excludePoint)) {
|
||||
continue;
|
||||
}
|
||||
QList<QPoint> connected;
|
||||
if (partitions.contains(p + QPoint(1, 0))) {
|
||||
connected.append(p + QPoint(1, 0));
|
||||
}
|
||||
if (partitions.contains(p + QPoint(0, 1))) {
|
||||
connected.append(p + QPoint(0, 1));
|
||||
}
|
||||
foreach (const QPoint& c, connected) {
|
||||
if (partitions[p] == partitions[c]) {
|
||||
continue;
|
||||
}
|
||||
partitions[p]->unite(* (partitions[c]));
|
||||
delete partitions[c];
|
||||
partitions[c] = partitions[p];
|
||||
}
|
||||
}
|
||||
|
||||
QSet<QSet<QPoint> * > unique;
|
||||
foreach (QSet<QPoint> * partition, partitions) {
|
||||
unique.insert(partition);
|
||||
}
|
||||
|
||||
QList<QSet<QPoint> > result;
|
||||
foreach (QSet<QPoint> * partition, unique) {
|
||||
result.append(* partition);
|
||||
delete partition;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QSet<QPoint> BackendConfiguration::border(QSet<QPoint> screens) const {
|
||||
QSet<QPoint> result;
|
||||
QList<QPoint> borders;
|
||||
borders << QPoint(1, 0) << QPoint(0, 1) << QPoint(-1, 0) << QPoint(0, -1);
|
||||
foreach (const QPoint& p, screens) {
|
||||
foreach (const QPoint& border, borders) {
|
||||
if (! screens.contains(p + border)) {
|
||||
result.insert(p + border);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef NO_KDE
|
||||
#include "moc_backendconfigurations.cpp"
|
||||
#endif
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_BACKENDCONFIGURATIONS_H
|
||||
#define KEPHAL_BACKENDCONFIGURATIONS_H
|
||||
|
||||
|
||||
#include <QMap>
|
||||
#include <QPoint>
|
||||
#include <QRect>
|
||||
|
||||
#include "configurations.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
/**
|
||||
* A configuration forming part of the backend (Kephal service)
|
||||
*/
|
||||
class BackendConfiguration : public Configuration {
|
||||
Q_OBJECT
|
||||
public:
|
||||
BackendConfiguration(QObject * parent);
|
||||
|
||||
/**
|
||||
* Returns the real layout, with screen-sizes
|
||||
* taken from the actual Outputs.
|
||||
*
|
||||
* @param simpleLayout The layout as returned
|
||||
* from layout().
|
||||
* @param outputScreens A mapping of Outputs
|
||||
* to Screens.
|
||||
* @param outputSizes The sizes to use for the
|
||||
* Outputs instead of the current ones.
|
||||
* WILL: used by XMLConf::resizeLayout()
|
||||
*/
|
||||
QMap<int, QRect> realLayout(const QMap<int, QPoint> & simpleLayout, const QMap<Output *, int> & outputScreens, const QMap<Output *, QSize> & outputSizes);
|
||||
|
||||
/**
|
||||
* Returns the real layout, with screen-sizes
|
||||
* taken from the actual Outputs.
|
||||
*
|
||||
* @param simpleLayout The layout as returned
|
||||
* from layout().
|
||||
* @param outputScreens A mapping of Outputs
|
||||
* to Screens.
|
||||
*/
|
||||
QMap<int, QRect> realLayout(const QMap<int, QPoint> & simpleLayout, const QMap<Output *, int> & outputScreens);
|
||||
|
||||
/**
|
||||
* Returns the real layout, with screen-sizes
|
||||
* taken from the actual Outputs.
|
||||
* This will calculate the layout by calling
|
||||
* layout().
|
||||
*
|
||||
* @param outputScreens A mapping of Outputs
|
||||
* to Screens.
|
||||
* WILL used by XMLConfiguration::activate(Configuration*)
|
||||
* WILL used by XMLConfiguration::calcMatchingLayout()
|
||||
* WILL used by XMLConfiguration::simpleConfigurationsPositions()
|
||||
*/
|
||||
QMap<int, QRect> realLayout(const QMap<Output *, int> & outputScreens);
|
||||
|
||||
/**
|
||||
* Returns the real layout, with screen-sizes
|
||||
* taken from the actual Outputs.
|
||||
* This will calculate the layout by calling
|
||||
* layout() and use the Output to Screen
|
||||
* mapping as currently active if possible.
|
||||
*/
|
||||
QMap<int, QRect> realLayout();
|
||||
|
||||
/**
|
||||
* Returns a set of points covered in the
|
||||
* layout returned by layout().
|
||||
*/
|
||||
QSet<QPoint> positions();
|
||||
|
||||
/**
|
||||
* Returns the positions as in positions
|
||||
* to which the Screen can be cloned.
|
||||
*/
|
||||
QSet<QPoint> clonePositions(int screen);
|
||||
|
||||
/**
|
||||
* Returns the layout if the Screen screen
|
||||
* was to be cloned to any of the other
|
||||
* Screens.
|
||||
*/
|
||||
QMap<int, QPoint> cloneLayout(int screen);
|
||||
|
||||
/**
|
||||
* Returns the possible positions as in
|
||||
* positions() to move the Screen screen
|
||||
* to.
|
||||
*/
|
||||
QSet<QPoint> possiblePositions(int screen) const;
|
||||
|
||||
private:
|
||||
void simpleToReal(QMap<int, QPoint> & simpleLayout, const QMap<int, QSize> & screenSizes, int index, QMap<int, QRect> & screens) const;
|
||||
QList<QSet<QPoint> > partition(int screen) const;
|
||||
QSet<QPoint> border(QSet<QPoint> screens) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A manager of configurations, on the backend
|
||||
*/
|
||||
class BackendConfigurations : public Configurations {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static BackendConfigurations * self();
|
||||
|
||||
BackendConfigurations(QObject * parent);
|
||||
virtual ~BackendConfigurations();
|
||||
|
||||
/**
|
||||
* Find the Configuration for the currently
|
||||
* connected Outputs.
|
||||
*/
|
||||
virtual Configuration * findConfiguration() = 0;
|
||||
|
||||
/**
|
||||
* Apply Output-specific settings such as size,
|
||||
* refresh-rate and rotation.
|
||||
*/
|
||||
virtual void applyOutputSettings() = 0;
|
||||
|
||||
virtual BackendConfiguration * activeBackendConfiguration();
|
||||
|
||||
private:
|
||||
static BackendConfigurations * s_instance;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_BACKENDCONFIGURATIONS_H
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "backendoutputs.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
BackendOutput::BackendOutput(QObject * parent)
|
||||
: Output(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void BackendOutput::mark() {
|
||||
m_markedActive = isActivated();
|
||||
if (m_markedActive) {
|
||||
m_markedGeom = geom();
|
||||
m_markedRate = rate();
|
||||
m_markedRotation = rotation();
|
||||
m_markedReflectX = reflectX();
|
||||
m_markedReflectY = reflectY();
|
||||
}
|
||||
}
|
||||
|
||||
void BackendOutput::revert() {
|
||||
if (m_markedActive) {
|
||||
applyGeom(m_markedGeom, m_markedRate);
|
||||
applyOrientation(m_markedRotation, m_markedReflectX, m_markedReflectY);
|
||||
} else {
|
||||
deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BackendOutputs * BackendOutputs::s_instance = 0;
|
||||
|
||||
BackendOutputs * BackendOutputs::self() {
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
BackendOutputs::BackendOutputs(QObject * parent)
|
||||
: Outputs(parent)
|
||||
{
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
BackendOutputs::~BackendOutputs()
|
||||
{
|
||||
s_instance = 0;
|
||||
}
|
||||
|
||||
QList<BackendOutput *> BackendOutputs::backendOutputs() {
|
||||
QList<BackendOutput *> result;
|
||||
foreach (Output * output, outputs()) {
|
||||
result << (BackendOutput *) output;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
BackendOutput * BackendOutputs::backendOutput(const QString & id) {
|
||||
foreach (BackendOutput * output, backendOutputs()) {
|
||||
if (output->id() == id) {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BackendOutputs::activateLayout(const QMap<Output *, QRect> & layout) {
|
||||
kDebug() << "activate layout:" << layout;
|
||||
|
||||
QList<BackendOutput *> outputs = backendOutputs();
|
||||
foreach (BackendOutput * output, outputs) {
|
||||
//output->mark();
|
||||
if (! layout.contains(output)) {
|
||||
kDebug() << "deactivating output:" << output->id();
|
||||
output->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
for (QMap<Output *, QRect>::const_iterator i = layout.constBegin(); i != layout.constEnd(); ++i) {
|
||||
BackendOutput * output = (BackendOutput *) i.key();
|
||||
kDebug() << "setting output" << output->id() << "to" << i.value();
|
||||
|
||||
if (! output->applyGeom(i.value(), 0)) {
|
||||
kDebug() << "setting" << output->id() << "to" << i.value() << "failed!!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_BACKENDOUTPUTS_H
|
||||
#define KEPHAL_BACKENDOUTPUTS_H
|
||||
|
||||
#include "outputs.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class BackendOutput : public Output {
|
||||
Q_OBJECT
|
||||
public:
|
||||
BackendOutput(QObject * parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual bool applyGeom(const QRect & geom, float rate) = 0;
|
||||
virtual bool applyOrientation(Rotation rotation, bool reflectX, bool reflectY) = 0;
|
||||
virtual void deactivate() = 0;
|
||||
|
||||
virtual void revert();
|
||||
virtual void mark();
|
||||
|
||||
private:
|
||||
bool m_markedActive;
|
||||
QRect m_markedGeom;
|
||||
double m_markedRate;
|
||||
Rotation m_markedRotation;
|
||||
bool m_markedReflectX;
|
||||
bool m_markedReflectY;
|
||||
};
|
||||
|
||||
class BackendOutputs : public Outputs {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static BackendOutputs * self();
|
||||
|
||||
BackendOutputs(QObject * parent);
|
||||
virtual ~BackendOutputs();
|
||||
|
||||
/**
|
||||
* Deactivates any Outputs not in the layout and applies the geometry in the layout to
|
||||
* those that are in
|
||||
*/
|
||||
virtual bool activateLayout(const QMap<Output *, QRect> & layout);
|
||||
virtual QList<BackendOutput *> backendOutputs();
|
||||
virtual BackendOutput * backendOutput(const QString & id);
|
||||
|
||||
private:
|
||||
static BackendOutputs * s_instance;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KEPHAL_BACKENDOUTPUTS_H
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "configurationscreens.h"
|
||||
|
||||
#include "configurations.h"
|
||||
#include "backendconfigurations.h"
|
||||
|
||||
#include "KDebug"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
ConfigurationScreens::ConfigurationScreens(QObject * parent)
|
||||
: OutputScreens(parent)
|
||||
{
|
||||
connect(Configurations::self(), SIGNAL(configurationActivated(Kephal::Configuration*)), this, SLOT(configurationActivated(Kephal::Configuration*)));
|
||||
}
|
||||
|
||||
void ConfigurationScreens::configurationActivated(Configuration * configuration) {
|
||||
Q_UNUSED(configuration)
|
||||
kDebug();
|
||||
triggerRebuildScreens();
|
||||
}
|
||||
|
||||
void ConfigurationScreens::prepareScreens(QMap<int, OutputScreen *> & screens) {
|
||||
BackendConfiguration * config = BackendConfigurations::self()->activeBackendConfiguration();
|
||||
if (! config) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (config->name() == "external") {
|
||||
screens.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
QMap<int, QRect> layout = config->realLayout();
|
||||
for (QMap<int, QRect>::const_iterator i = layout.constBegin(); i != layout.constEnd(); ++i) {
|
||||
if (screens.contains(i.key())) {
|
||||
screens[i.key()]->_setGeom(i.value());
|
||||
} else {
|
||||
OutputScreen * screen = new OutputScreen(this);
|
||||
screen->_setId(i.key());
|
||||
screen->_setGeom(i.value());
|
||||
screens.insert(screen->id(), screen);
|
||||
}
|
||||
}
|
||||
|
||||
for (QMap<int, OutputScreen *>::iterator i = screens.begin(); i != screens.end();) {
|
||||
if (! layout.contains(i.key())) {
|
||||
i = screens.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_CONFIGURATIONSCREENS_H
|
||||
#define KEPHAL_CONFIGURATIONSCREENS_H
|
||||
|
||||
|
||||
#include "outputscreens.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class Configuration;
|
||||
|
||||
/**
|
||||
* updates the geometries of Screen objects using active Configuration
|
||||
* Has a special case for the 'external' configuration. Why?
|
||||
*/
|
||||
class ConfigurationScreens : public OutputScreens {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigurationScreens(QObject * parent);
|
||||
|
||||
protected:
|
||||
void prepareScreens(QMap<int, OutputScreen *> & screens);
|
||||
|
||||
private Q_SLOTS:
|
||||
void configurationActivated(Kephal::Configuration * configuration);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KEPHAL_CONFIGURATIONSCREENS_H
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "dbusapi_configurations.h"
|
||||
#include "configurations.h"
|
||||
#include "configurationsadaptor.h"
|
||||
#include "outputs.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
using namespace Kephal;
|
||||
|
||||
DBusAPIConfigurations::DBusAPIConfigurations(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
new ConfigurationsAdaptor(this);
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
|
||||
const bool result = dbus.registerObject("/modules/kephal/Configurations", this);
|
||||
kDebug() << "configurations registered on the bus:" << result;
|
||||
|
||||
connect(Configurations::self(), SIGNAL(configurationActivated(Kephal::Configuration*)), this, SLOT(configurationActivatedSlot(Kephal::Configuration*)));
|
||||
connect(Configurations::self(), SIGNAL(confirmed()), this, SIGNAL(confirmed()));
|
||||
connect(Configurations::self(), SIGNAL(reverted()), this, SIGNAL(reverted()));
|
||||
connect(Configurations::self(), SIGNAL(confirmTimeout(int)), this, SIGNAL(confirmTimeout(int)));
|
||||
}
|
||||
|
||||
QStringList DBusAPIConfigurations::configurations() {
|
||||
QStringList result;
|
||||
foreach (const QString& name, Configurations::self()->configurations().keys()) {
|
||||
result << name;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int DBusAPIConfigurations::numAvailablePositions(QString output) {
|
||||
Output * o = Outputs::self()->output(output);
|
||||
if (o) {
|
||||
m_outputAvailablePositions.insert(output, o->availablePositions());
|
||||
return m_outputAvailablePositions[output].size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QPoint DBusAPIConfigurations::availablePosition(QString output, int index) {
|
||||
if (m_outputAvailablePositions.contains(output)) {
|
||||
return m_outputAvailablePositions[output][index];
|
||||
}
|
||||
return QPoint();
|
||||
}
|
||||
|
||||
QStringList DBusAPIConfigurations::alternateConfigurations() {
|
||||
QStringList result;
|
||||
foreach (Configuration * config, Configurations::self()->alternateConfigurations()) {
|
||||
result << config->name();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString DBusAPIConfigurations::activeConfiguration() {
|
||||
Configuration * config = Configurations::self()->activeConfiguration();
|
||||
if (config) {
|
||||
return config->name();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Not needed. If Configurations provides access to configurations, it should not also provide ways
|
||||
// to temporarily modify the current configuration. This should be done by a config UI.
|
||||
#if 0
|
||||
bool DBusAPIConfigurations::move(QString output, QPoint position) {
|
||||
Output * o = Outputs::self()->output(output);
|
||||
if (o) {
|
||||
return Configurations::self()->move(o, position);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIConfigurations::resize(QString output, QSize size) {
|
||||
Output * o = Outputs::self()->output(output);
|
||||
if (o) {
|
||||
return Configurations::self()->resize(o, size);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIConfigurations::rotate(QString output, int rotation) {
|
||||
Output * o = Outputs::self()->output(output);
|
||||
if (o) {
|
||||
return Configurations::self()->rotate(o, (Rotation) rotation);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIConfigurations::changeRate(QString output, double rate) {
|
||||
Output * o = Outputs::self()->output(output);
|
||||
if (o) {
|
||||
return Configurations::self()->changeRate(o, static_cast<float>(rate));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIConfigurations::reflectX(QString output, bool reflect) {
|
||||
Output * o = Outputs::self()->output(output);
|
||||
if (o) {
|
||||
return Configurations::self()->reflectX(o, reflect);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIConfigurations::reflectY(QString output, bool reflect) {
|
||||
Output * o = Outputs::self()->output(output);
|
||||
if (o) {
|
||||
return Configurations::self()->reflectY(o, reflect);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
bool DBusAPIConfigurations::isModifiable(QString config) {
|
||||
Configuration * c = Configurations::self()->configuration(config);
|
||||
if (c) {
|
||||
return c->isModifiable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIConfigurations::isActivated(QString config) {
|
||||
Configuration * c = Configurations::self()->configuration(config);
|
||||
if (c) {
|
||||
return c->isActivated();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DBusAPIConfigurations::activate(QString config) {
|
||||
Configuration * c = Configurations::self()->configuration(config);
|
||||
if (c) {
|
||||
c->activate();
|
||||
}
|
||||
}
|
||||
|
||||
int DBusAPIConfigurations::primaryScreen(QString config) {
|
||||
Configuration * c = Configurations::self()->configuration(config);
|
||||
if (c) {
|
||||
return c->primaryScreen();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DBusAPIConfigurations::screen(QString outputId) {
|
||||
Output * output = Outputs::self()->output(outputId);
|
||||
if (output) {
|
||||
return Configurations::self()->screen(output);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DBusAPIConfigurations::setPolling(bool polling) {
|
||||
Configurations::self()->setPolling(polling);
|
||||
}
|
||||
|
||||
bool DBusAPIConfigurations::polling() {
|
||||
return Configurations::self()->polling();
|
||||
}
|
||||
|
||||
void DBusAPIConfigurations::configurationActivatedSlot(Kephal::Configuration * configuration) {
|
||||
emit configurationActivated(configuration->name());
|
||||
}
|
||||
|
||||
void DBusAPIConfigurations::confirm() {
|
||||
Configurations::self()->confirm();
|
||||
}
|
||||
|
||||
void DBusAPIConfigurations::revert() {
|
||||
Configurations::self()->revert();
|
||||
}
|
||||
|
||||
#ifndef NO_KDE
|
||||
#include "moc_dbusapi_configurations.cpp"
|
||||
#endif
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DBUSAPI_CONFIGURATIONS_H
|
||||
#define DBUSAPI_CONFIGURATIONS_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QPoint>
|
||||
#include <QSize>
|
||||
#include <QMap>
|
||||
|
||||
namespace Kephal {
|
||||
class Configuration;
|
||||
}
|
||||
|
||||
|
||||
class DBusAPIConfigurations : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.Kephal.Configurations")
|
||||
|
||||
public:
|
||||
DBusAPIConfigurations(QObject * parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
QStringList configurations();
|
||||
QStringList alternateConfigurations();
|
||||
QString activeConfiguration();
|
||||
|
||||
int numAvailablePositions(QString output);
|
||||
QPoint availablePosition(QString output, int index);
|
||||
//bool move(QString output, QPoint position);
|
||||
//bool resize(QString output, QSize size);
|
||||
//bool rotate(QString output, int rotation);
|
||||
//bool changeRate(QString output, double rate);
|
||||
//bool reflectX(QString output, bool reflect);
|
||||
//bool reflectY(QString output, bool reflect);
|
||||
int screen(QString output);
|
||||
|
||||
bool isModifiable(QString config);
|
||||
bool isActivated(QString config);
|
||||
void activate(QString config);
|
||||
int primaryScreen(QString config);
|
||||
|
||||
void setPolling(bool polling);
|
||||
bool polling();
|
||||
|
||||
void confirm();
|
||||
void revert();
|
||||
|
||||
Q_SIGNALS:
|
||||
void configurationActivated(QString name);
|
||||
void confirmTimeout(int seconds);
|
||||
void confirmed();
|
||||
void reverted();
|
||||
|
||||
private Q_SLOTS:
|
||||
void configurationActivatedSlot(Kephal::Configuration * configuration);
|
||||
|
||||
private:
|
||||
QMap<QString, QList<QPoint> > m_outputAvailablePositions;
|
||||
};
|
||||
|
||||
|
||||
#endif // DBUSAPI_CONFIGURATIONS_H
|
||||
|
|
@ -1,223 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "dbusapi_outputs.h"
|
||||
#include "outputs.h"
|
||||
#include "outputsadaptor.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
using namespace Kephal;
|
||||
|
||||
DBusAPIOutputs::DBusAPIOutputs(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
new OutputsAdaptor(this);
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
|
||||
const bool result = dbus.registerObject("/modules/kephal/Outputs", this);
|
||||
kDebug() << "outputs registered on the bus:" << result;
|
||||
|
||||
connect(Outputs::self(), SIGNAL(outputConnected(Kephal::Output*)), this, SLOT(outputConnectedSlot(Kephal::Output*)));
|
||||
connect(Outputs::self(), SIGNAL(outputDisconnected(Kephal::Output*)), this, SLOT(outputDisconnectedSlot(Kephal::Output*)));
|
||||
connect(Outputs::self(), SIGNAL(outputActivated(Kephal::Output*)), this, SLOT(outputActivatedSlot(Kephal::Output*)));
|
||||
connect(Outputs::self(), SIGNAL(outputDeactivated(Kephal::Output*)), this, SLOT(outputDeactivatedSlot(Kephal::Output*)));
|
||||
connect(Outputs::self(), SIGNAL(outputResized(Kephal::Output*,QSize,QSize)), this, SLOT(outputResizedSlot(Kephal::Output*,QSize,QSize)));
|
||||
connect(Outputs::self(), SIGNAL(outputMoved(Kephal::Output*,QPoint,QPoint)), this, SLOT(outputMovedSlot(Kephal::Output*,QPoint,QPoint)));
|
||||
connect(Outputs::self(), SIGNAL(outputRotated(Kephal::Output*,Kephal::Rotation,Kephal::Rotation)), this, SLOT(outputRotatedSlot(Kephal::Output*,Kephal::Rotation,Kephal::Rotation)));
|
||||
connect(Outputs::self(), SIGNAL(outputRateChanged(Kephal::Output*,float,float)), this, SLOT(outputRateChangedSlot(Kephal::Output*,float,float)));
|
||||
connect(Outputs::self(), SIGNAL(outputReflected(Kephal::Output*,bool,bool,bool,bool)), this, SLOT(outputReflectedSlot(Kephal::Output*,bool,bool,bool,bool)));
|
||||
}
|
||||
|
||||
QSize DBusAPIOutputs::size(QString id)
|
||||
{
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
return output->size();
|
||||
}
|
||||
return QSize(0,0);
|
||||
}
|
||||
|
||||
int DBusAPIOutputs::numAvailableSizes(QString id)
|
||||
{
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
m_sizes.insert(id, output->availableSizes());
|
||||
return m_sizes[id].size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QSize DBusAPIOutputs::availableSize(QString id, int i)
|
||||
{
|
||||
if (! m_sizes.contains(id)) {
|
||||
numAvailableSizes(id);
|
||||
}
|
||||
if (m_sizes.contains(id) && (m_sizes[id].size() > i)) {
|
||||
return m_sizes[id][i];
|
||||
}
|
||||
return QSize(-1, -1);
|
||||
}
|
||||
|
||||
QPoint DBusAPIOutputs::position(QString id)
|
||||
{
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
return output->position();
|
||||
}
|
||||
return QPoint(0,0);
|
||||
}
|
||||
|
||||
QStringList DBusAPIOutputs::outputIds()
|
||||
{
|
||||
QList<Output *> outputs = Outputs::self()->outputs();
|
||||
QStringList result;
|
||||
//kDebug() << "output-ids requested!!";
|
||||
foreach (Output * output, outputs) {
|
||||
//kDebug() << "appending output-id:" << output->id();
|
||||
result.append(output->id());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DBusAPIOutputs::isConnected(QString id)
|
||||
{
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isConnected()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIOutputs::isActivated(QString id)
|
||||
{
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int DBusAPIOutputs::numAvailableRates(QString id)
|
||||
{
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
m_rates.insert(id, output->availableRates());
|
||||
return m_rates[id].size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DBusAPIOutputs::availableRate(QString id, int i)
|
||||
{
|
||||
if (! m_rates.contains(id)) {
|
||||
numAvailableRates(id);
|
||||
}
|
||||
if (m_rates.contains(id) && (m_rates[id].size() > i)) {
|
||||
return m_rates[id][i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DBusAPIOutputs::rotation(QString id) {
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
return output->rotation();
|
||||
}
|
||||
return RotateNormal;
|
||||
}
|
||||
|
||||
double DBusAPIOutputs::rate(QString id) {
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
return output->rate();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DBusAPIOutputs::reflectX(QString id) {
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
return output->reflectX();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DBusAPIOutputs::reflectY(QString id) {
|
||||
Output * output = Outputs::self()->output(id);
|
||||
if (output && output->isActivated()) {
|
||||
return output->reflectY();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputConnectedSlot(Kephal::Output * o) {
|
||||
emit outputConnected(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputDisconnectedSlot(Kephal::Output * o) {
|
||||
emit outputDisconnected(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputActivatedSlot(Kephal::Output * o) {
|
||||
emit outputActivated(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputDeactivatedSlot(Kephal::Output * o) {
|
||||
emit outputDeactivated(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputResizedSlot(Kephal::Output * o, QSize oldSize, QSize newSize) {
|
||||
Q_UNUSED(oldSize)
|
||||
Q_UNUSED(newSize)
|
||||
emit outputResized(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputMovedSlot(Kephal::Output * o, QPoint oldPosition, QPoint newPosition) {
|
||||
Q_UNUSED(oldPosition)
|
||||
Q_UNUSED(newPosition)
|
||||
emit outputMoved(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputRateChangedSlot(Kephal::Output * o, float oldRate, float newRate) {
|
||||
Q_UNUSED(oldRate)
|
||||
Q_UNUSED(newRate)
|
||||
emit outputRateChanged(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputRotatedSlot(Kephal::Output * o, Rotation oldRotation, Rotation newRotation) {
|
||||
Q_UNUSED(oldRotation)
|
||||
Q_UNUSED(newRotation)
|
||||
emit outputRotated(o->id());
|
||||
}
|
||||
|
||||
void DBusAPIOutputs::outputReflectedSlot(Kephal::Output * o, bool oldX, bool oldY, bool newX, bool newY) {
|
||||
Q_UNUSED(oldX)
|
||||
Q_UNUSED(oldY)
|
||||
Q_UNUSED(newX)
|
||||
Q_UNUSED(newY)
|
||||
emit outputReflected(o->id());
|
||||
}
|
||||
|
||||
#ifndef NO_KDE
|
||||
#include "moc_dbusapi_outputs.cpp"
|
||||
#endif
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DBUSAPI_OUTPUTS_H
|
||||
#define DBUSAPI_OUTPUTS_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "kephal.h"
|
||||
|
||||
#include <QSize>
|
||||
#include <QPoint>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
|
||||
namespace Kephal {
|
||||
class Output;
|
||||
}
|
||||
|
||||
class DBusAPIOutputs : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.Kephal.Outputs")
|
||||
|
||||
public:
|
||||
DBusAPIOutputs(QObject * parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
QStringList outputIds();
|
||||
QSize size(QString id);
|
||||
int numAvailableSizes(QString id);
|
||||
QSize availableSize(QString id, int index);
|
||||
QPoint position(QString id);
|
||||
bool isConnected(QString id);
|
||||
bool isActivated(QString id);
|
||||
int rotation(QString id);
|
||||
double rate(QString id);
|
||||
bool reflectX(QString id);
|
||||
bool reflectY(QString id);
|
||||
int numAvailableRates(QString id);
|
||||
double availableRate(QString id, int index);
|
||||
|
||||
Q_SIGNALS:
|
||||
void outputConnected(QString id);
|
||||
void outputDisconnected(QString id);
|
||||
void outputActivated(QString id);
|
||||
void outputDeactivated(QString id);
|
||||
void outputResized(QString id);
|
||||
void outputMoved(QString id);
|
||||
void outputRateChanged(QString id);
|
||||
void outputRotated(QString id);
|
||||
void outputReflected(QString id);
|
||||
|
||||
private Q_SLOTS:
|
||||
void outputConnectedSlot(Kephal::Output * o);
|
||||
void outputDisconnectedSlot(Kephal::Output * o);
|
||||
void outputActivatedSlot(Kephal::Output * o);
|
||||
void outputDeactivatedSlot(Kephal::Output * o);
|
||||
void outputResizedSlot(Kephal::Output * o, QSize oldSize, QSize newSize);
|
||||
void outputMovedSlot(Kephal::Output * o, QPoint oldPosition, QPoint newPosition);
|
||||
void outputRateChangedSlot(Kephal::Output * o, float oldRate, float newRate);
|
||||
void outputRotatedSlot(Kephal::Output * o, Kephal::Rotation oldRotation, Kephal::Rotation newRotation);
|
||||
void outputReflectedSlot(Kephal::Output * o, bool oldX, bool oldY, bool newX, bool newY);
|
||||
|
||||
private:
|
||||
QMap<QString, QList<QSize> > m_sizes;
|
||||
QMap<QString, QList<float> > m_rates;
|
||||
};
|
||||
|
||||
|
||||
#endif // DBUSAPI_OUTPUTS_H
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "dbusapi_screens.h"
|
||||
#include "screens.h"
|
||||
#include "outputs.h"
|
||||
#include "screensadaptor.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
|
||||
using namespace Kephal;
|
||||
|
||||
DBusAPIScreens::DBusAPIScreens(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
new ScreensAdaptor(this);
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
|
||||
const bool result = dbus.registerObject("/modules/kephal/Screens", this);
|
||||
kDebug() << "screens registered on the bus:" << result;
|
||||
|
||||
connect(Screens::self(), SIGNAL(screenResized(Kephal::Screen*,QSize,QSize)), this, SLOT(screenResized(Kephal::Screen*,QSize,QSize)));
|
||||
connect(Screens::self(), SIGNAL(screenMoved(Kephal::Screen*,QPoint,QPoint)), this, SLOT(screenMoved(Kephal::Screen*,QPoint,QPoint)));
|
||||
connect(Screens::self(), SIGNAL(screenAdded(Kephal::Screen*)), this, SLOT(screenAdded(Kephal::Screen*)));
|
||||
connect(Screens::self(), SIGNAL(screenRemoved(int)), this, SLOT(screenRemovedSlot(int)));
|
||||
}
|
||||
|
||||
void DBusAPIScreens::screenResized(Kephal::Screen * s, QSize oldSize, QSize newSize) {
|
||||
Q_UNUSED(oldSize)
|
||||
Q_UNUSED(newSize)
|
||||
emit screenResized(s->id());
|
||||
}
|
||||
|
||||
void DBusAPIScreens::screenMoved(Kephal::Screen * s, QPoint oldPosition, QPoint newPosition) {
|
||||
Q_UNUSED(oldPosition)
|
||||
Q_UNUSED(newPosition)
|
||||
emit screenMoved(s->id());
|
||||
}
|
||||
|
||||
void DBusAPIScreens::screenAdded(Kephal::Screen * s) {
|
||||
emit screenAdded(s->id());
|
||||
}
|
||||
|
||||
void DBusAPIScreens::screenRemovedSlot(int id) {
|
||||
emit screenRemoved(id);
|
||||
}
|
||||
|
||||
QSize DBusAPIScreens::size(int id)
|
||||
{
|
||||
Screen * s = Screens::self()->screen(id);
|
||||
return s ? s->size() : QSize(0,0);
|
||||
}
|
||||
|
||||
QPoint DBusAPIScreens::position(int id)
|
||||
{
|
||||
Screen * s = Screens::self()->screen(id);
|
||||
return s ? s->position() : QPoint(0,0);
|
||||
}
|
||||
|
||||
int DBusAPIScreens::numScreens()
|
||||
{
|
||||
QList<Screen *> screens = Screens::self()->screens();
|
||||
return screens.size();
|
||||
}
|
||||
|
||||
int DBusAPIScreens::id(int index)
|
||||
{
|
||||
QList<Screen *> screens = Screens::self()->screens();
|
||||
if (index < screens.size()) {
|
||||
return screens[index]->id();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int DBusAPIScreens::primaryScreen()
|
||||
{
|
||||
Screen * s = Screens::self()->primaryScreen();
|
||||
return s ? s->id() : 0;
|
||||
}
|
||||
|
||||
QStringList DBusAPIScreens::outputs(int id) {
|
||||
Screen * s = Screens::self()->screen(id);
|
||||
QStringList result;
|
||||
if (s) {
|
||||
foreach (Output * output, s->outputs()) {
|
||||
result << output->id();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef NO_KDE
|
||||
#include "moc_dbusapi_screens.cpp"
|
||||
#endif
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DBUSAPI_SCREENS_H
|
||||
#define DBUSAPI_SCREENS_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QSize>
|
||||
#include <QStringList>
|
||||
|
||||
namespace Kephal {
|
||||
class Screen;
|
||||
}
|
||||
|
||||
class DBusAPIScreens : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.Kephal.Screens")
|
||||
|
||||
public:
|
||||
DBusAPIScreens(QObject * parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
int numScreens();
|
||||
int id(int index);
|
||||
QSize size(int id);
|
||||
QPoint position(int id);
|
||||
int primaryScreen();
|
||||
QStringList outputs(int id);
|
||||
|
||||
private Q_SLOTS:
|
||||
void screenResized(Kephal::Screen * s, QSize oldSize, QSize newSize);
|
||||
void screenMoved(Kephal::Screen * s, QPoint oldPosition, QPoint newPosition);
|
||||
void screenAdded(Kephal::Screen * s);
|
||||
void screenRemovedSlot(int id);
|
||||
|
||||
Q_SIGNALS:
|
||||
void screenResized(int screen);
|
||||
void screenMoved(int screen);
|
||||
void screenAdded(int screen);
|
||||
void screenRemoved(int screen);
|
||||
};
|
||||
|
||||
|
||||
#endif // DBUSAPI_SCREENS_H
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_EDID_H
|
||||
#define KEPHAL_EDID_H
|
||||
|
||||
#define EDID_HEADER "\x00\xff\xff\xff\xff\xff\xff\x00"
|
||||
#define EDID_HEADER_SIZE 8
|
||||
#define EDID_TEST_HEADER(x) (memcmp(x, EDID_HEADER, EDID_HEADER_SIZE) == 0)
|
||||
|
||||
#define EDID_VENDOR_START 8
|
||||
#define EDID_VENDOR_1(x) ('@' + ((x[EDID_VENDOR_START] & 0x7c) >> 2))
|
||||
#define EDID_VENDOR_2(x) ('@' + ((x[EDID_VENDOR_START] & 0x03) << 3) + ((x[EDID_VENDOR_START + 1] & 0xe0) >> 5))
|
||||
#define EDID_VENDOR_3(x) ('@' + (x[EDID_VENDOR_START + 1] & 0x1f))
|
||||
|
||||
#define EDID_PRODUCT_ID_START (EDID_VENDOR_START + 2)
|
||||
#define EDID_PRODUCT_ID(x) (x[EDID_PRODUCT_ID_START] | (x[EDID_PRODUCT_ID_START + 1] << 8))
|
||||
|
||||
#define EDID_SERIAL_NUMBER_START (EDID_PRODUCT_ID_START + 2)
|
||||
#define EDID_SERIAL_NUMBER(x) (x[EDID_SERIAL_NUMBER_START] | (x[EDID_SERIAL_NUMBER_START + 1] << 8) | (x[EDID_SERIAL_NUMBER_START + 2] << 16) | (x[EDID_SERIAL_NUMBER_START + 3] << 24))
|
||||
|
||||
#endif // KEPHAL_EDID_H
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "externalconfiguration.h"
|
||||
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
ExternalConfiguration::ExternalConfiguration(BackendConfigurations * parent)
|
||||
: BackendConfiguration(parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
QString ExternalConfiguration::name() const {
|
||||
return QString("external");
|
||||
}
|
||||
|
||||
bool ExternalConfiguration::isModifiable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExternalConfiguration::isActivated() const {
|
||||
return m_parent->activeBackendConfiguration() == this;
|
||||
}
|
||||
|
||||
QMap<int, QPoint> ExternalConfiguration::layout() const {
|
||||
return QMap<int, QPoint>();
|
||||
}
|
||||
|
||||
int ExternalConfiguration::primaryScreen() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ExternalConfiguration::activate() {
|
||||
emit activateExternal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef NO_KDE
|
||||
#include "moc_externalconfiguration.cpp"
|
||||
#endif
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_EXTERNALCONFIGURATION_H
|
||||
#define KEPHAL_EXTERNALCONFIGURATION_H
|
||||
|
||||
#include "backendconfigurations.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
/**
|
||||
* Configuration which is hardwired to name 'external'.
|
||||
* Is this a hardwired permanent configuration object? If so where is 'single'?
|
||||
*/
|
||||
class ExternalConfiguration : public BackendConfiguration {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ExternalConfiguration(BackendConfigurations * parent);
|
||||
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
QString name() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
bool isModifiable() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
bool isActivated() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
QMap<int, QPoint> layout() const;
|
||||
/**
|
||||
* @reimp Kephal::Configuration
|
||||
*/
|
||||
int primaryScreen() const;
|
||||
public Q_SLOTS:
|
||||
void activate();
|
||||
Q_SIGNALS:
|
||||
void activateExternal();
|
||||
private:
|
||||
BackendConfigurations * m_parent;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
|
||||
X-KDE-ServiceTypes=KDEDModule
|
||||
X-KDE-Library=kephal
|
||||
X-KDE-DBus-ModuleName=kephal
|
||||
X-KDE-Kded-autoload=false
|
||||
X-KDE-Kded-load-on-demand=true
|
||||
|
||||
Name=Display Management
|
||||
Name[ar]=إدارة العرض
|
||||
Name[ast]=Xestión de pantalla
|
||||
Name[bg]=Управление на екрана
|
||||
Name[bs]=Upravljanje prikazom
|
||||
Name[ca]=Gestió de la pantalla
|
||||
Name[ca@valencia]=Gestió de la pantalla
|
||||
Name[cs]=Správa zobrazení
|
||||
Name[da]=Håndtering af skærme
|
||||
Name[de]=Bildschirmverwaltung
|
||||
Name[el]=Εμφάνιση διαχείρισης
|
||||
Name[en_GB]=Display Management
|
||||
Name[es]=Gestión de pantalla
|
||||
Name[et]=Kuvahaldus
|
||||
Name[eu]=Bistaratze-kudeaketa
|
||||
Name[fi]=Näytönhallinta
|
||||
Name[fr]=Gestion de l'affichage
|
||||
Name[ga]=Bainisteoireacht Scáileán
|
||||
Name[gl]=Xestión do monitor
|
||||
Name[he]=ניהול צגים
|
||||
Name[hi]=डिस्पले प्रबंधन
|
||||
Name[hr]=Upravitelj zaslona
|
||||
Name[hu]=Képernyőkezelő
|
||||
Name[ia]=Gestion de monstrator
|
||||
Name[id]=Manajemen Tampilan
|
||||
Name[is]=Skjáastjórnun
|
||||
Name[ja]=ディスプレイ管理
|
||||
Name[kk]=Дисплейді басқару
|
||||
Name[km]=បង្ហាញការគ្រប់គ្រង
|
||||
Name[kn]=ಪ್ರದರ್ಶನ ವ್ಯವಸ್ಥಾಪಕ
|
||||
Name[ko]=디스플레이 관리
|
||||
Name[lt]=Ekrano valdymas
|
||||
Name[lv]=Ekrāna pārvaldība
|
||||
Name[mr]=डिस्प्ले व्यवस्थापन
|
||||
Name[nb]=Skjermstyring
|
||||
Name[nds]=Schirmpleeg
|
||||
Name[nl]=Schermbeheer
|
||||
Name[pa]=ਡਿਸਪਲੇਅ ਮੈਨੇਜਮੈਂਟ
|
||||
Name[pl]=Zarządzanie wyświetlaczem
|
||||
Name[pt]=Gestão do Ecrã
|
||||
Name[pt_BR]=Gerenciamento de tela
|
||||
Name[ro]=Gestiune afișaj
|
||||
Name[ru]=Управление экраном
|
||||
Name[si]=ප්රදර්ශන කළමනාකරනය
|
||||
Name[sk]=Správa obrazovky
|
||||
Name[sl]=Upravljanje z zasloni
|
||||
Name[sr]=Управљање приказом
|
||||
Name[sr@ijekavian]=Управљање приказом
|
||||
Name[sr@ijekavianlatin]=Upravljanje prikazom
|
||||
Name[sr@latin]=Upravljanje prikazom
|
||||
Name[sv]=Skärmhantering
|
||||
Name[tg]=Идоракунии экран
|
||||
Name[th]=การจัดการระบบแสดงผล
|
||||
Name[tr]=Ekran Yönetimi
|
||||
Name[ug]=باشقۇرۇشنى كۆرسەت
|
||||
Name[uk]=Керування дисплеєм
|
||||
Name[vi]=Quản lý hiển thị
|
||||
Name[wa]=Manaedjmint do håynaedje
|
||||
Name[x-test]=xxDisplay Managementxx
|
||||
Name[zh_CN]=显示管理
|
||||
Name[zh_TW]=顯示管理員
|
||||
Comment=Manages displays and video outputs
|
||||
Comment[ar]=أدر الشاشات ومخارج الفيديو
|
||||
Comment[ast]=Xestiona pantalles y salides de videu
|
||||
Comment[bg]=Управление на екрана и изходите за видео
|
||||
Comment[bs]=Upravlja prikazima i video izlazima
|
||||
Comment[ca]=Gestiona les pantalles i les sortides de vídeo
|
||||
Comment[ca@valencia]=Gestiona les pantalles i les eixides de vídeo
|
||||
Comment[cs]=Spravuje displeje a výstupy obrazu
|
||||
Comment[da]=Håndterer skærme og video-output
|
||||
Comment[de]=Bildschirme und Grafikkarten verwalten
|
||||
Comment[el]=Διαχείριση εμφάνισης και εξόδων βίντεο
|
||||
Comment[en_GB]=Manages displays and video outputs
|
||||
Comment[es]=Gestiona pantallas y salidas de vídeo
|
||||
Comment[et]=Monitoride ja videoväljundite haldamine
|
||||
Comment[eu]=Bistaratzeak eta bideo-irteerak kudeatzen ditu
|
||||
Comment[fi]=Hallitsee näyttöjä ja videoulostuloja
|
||||
Comment[fr]=Gère les affichages et les sorties vidéo
|
||||
Comment[ga]=Bainistigh scáileáin agus aschuir fhíse
|
||||
Comment[gl]=Xestiona as pantallas e as saídas de vídeo
|
||||
Comment[he]=מנהל תצוגות ופלטי וידאו
|
||||
Comment[hr]=Upravlja zaslonskim i video izlazima
|
||||
Comment[hu]=Képernyők és videokimenetek kezelése
|
||||
Comment[ia]=Il gere egressos de video e monstratores
|
||||
Comment[id]=Atur keluaran tampilan dan video
|
||||
Comment[is]=Sýslar með skjái og vídeóúttök
|
||||
Comment[ja]=ディスプレイとビデオ出力を管理
|
||||
Comment[kk]=Дисплейді және видео көрсетуін басқару
|
||||
Comment[km]=គ្រប់គ្រងការបង្ហាញ និងលទ្ធផលវីដេអូ
|
||||
Comment[ko]=디스플레이와 비디오 출력을 관리합니다
|
||||
Comment[lt]=Ekrano ir video išėjimų valdymas
|
||||
Comment[lv]=Pārvalda ekrānus un video izvadus
|
||||
Comment[mr]=दृश्य व व्हिडीओ आउटपुट्स व्यवस्थापीत करतो
|
||||
Comment[nb]=Håndterer skjermer og videoutganger
|
||||
Comment[nds]=Schirmen un Videoutgäng plegen
|
||||
Comment[nl]=Beheert schermen en video-invoer
|
||||
Comment[pa]=ਡਿਸਪਲੇਅ ਅਤੇ ਵਿਡੀਓ ਆਉਟਪੁੱਟ ਪਰਬੰਧ
|
||||
Comment[pl]=Zarządzanie wyświetlaczami i wyjściami wideo
|
||||
Comment[pt]=Faz a gestão dos ecrãs e das saídas de vídeo
|
||||
Comment[pt_BR]=Gerencia as telas e as saídas de vídeo
|
||||
Comment[ro]=Gestionează afișajele și ieșirile video
|
||||
Comment[ru]=Управляет экранами и видеовыходами
|
||||
Comment[si]=ප්රදර්ශන සහ වීඩියෝ ප්රතිදාන කළමනාකරනය කරයි
|
||||
Comment[sk]=Spravuje obrazovky a video výstupy
|
||||
Comment[sl]=Upravlja z zasloni in izhodi za video
|
||||
Comment[sr]=Управља приказима и видео излазима
|
||||
Comment[sr@ijekavian]=Управља приказима и видео излазима
|
||||
Comment[sr@ijekavianlatin]=Upravlja prikazima i video izlazima
|
||||
Comment[sr@latin]=Upravlja prikazima i video izlazima
|
||||
Comment[sv]=Hanterar skärmar och videoutgångar
|
||||
Comment[tg]=Барориши экран ва видеоро идора мекунад
|
||||
Comment[th]=จัดการการแสดงผลและการส่งออกวีดิโอต่าง ๆ
|
||||
Comment[tr]=Ekranları ve video çıkışlarını yönetir
|
||||
Comment[ug]=باشقۇرۇش كۆرسىتىلىپ سىنغا چىقىرىلىدۇ
|
||||
Comment[uk]=Керує дисплеями та виводом відеоданих
|
||||
Comment[vi]=Quản lý hiển thị và xuất hình ảnh
|
||||
Comment[wa]=Manaedje les waitroûles eyet les rexhowes videyo
|
||||
Comment[x-test]=xxManages displays and video outputsxx
|
||||
Comment[zh_CN]=管理显示和视频输出
|
||||
Comment[zh_TW]=管理顯示與影片輸出
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "kephald.h"
|
||||
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
|
||||
#include "kephalservice.h"
|
||||
|
||||
K_PLUGIN_FACTORY(KephalDFactory,
|
||||
registerPlugin<KephalD>();
|
||||
)
|
||||
K_EXPORT_PLUGIN(KephalDFactory("kephal"))
|
||||
|
||||
KephalD::KephalD(QObject* parent, const QList<QVariant>&)
|
||||
: KDEDModule(parent)
|
||||
{
|
||||
new KephalService(parent);
|
||||
}
|
||||
|
||||
KephalD::~KephalD()
|
||||
{
|
||||
}
|
||||
|
||||
#include "moc_kephald.cpp"
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHALD_H
|
||||
#define KEPHALD_H
|
||||
|
||||
#include <kdedmodule.h>
|
||||
|
||||
class KephalD : public KDEDModule
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KephalD(QObject* parent, const QList<QVariant>&);
|
||||
virtual ~KephalD();
|
||||
};
|
||||
|
||||
#endif //KEPHALD_H
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
#include "kephalservice.h"
|
||||
|
||||
#include "config-kephal.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QApplication>
|
||||
#include <QTimer>
|
||||
|
||||
#include <KApplication>
|
||||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
#ifdef HAS_RANDR_1_2
|
||||
#include "xrandr12/randrdisplay.h"
|
||||
#include "xrandr12/randrscreen.h"
|
||||
#include "xrandroutputs.h"
|
||||
#endif
|
||||
|
||||
#include "desktopwidgetoutputs.h"
|
||||
#include "configurationscreens.h"
|
||||
|
||||
#include "dbus/dbusapi_screens.h"
|
||||
#include "dbus/dbusapi_outputs.h"
|
||||
#include "dbus/dbusapi_configurations.h"
|
||||
#include "xmlconfigurations.h"
|
||||
|
||||
using namespace Kephal;
|
||||
|
||||
X11EventFilter::X11EventFilter(Kephal::XRandROutputs * outputs)
|
||||
: m_outputs(outputs)
|
||||
{}
|
||||
|
||||
X11EventFilter::~X11EventFilter()
|
||||
{}
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
bool X11EventFilter::x11Event(XEvent * e) {
|
||||
#ifdef HAS_RANDR_1_2
|
||||
if (m_outputs && m_outputs->display()->canHandle(e)) {
|
||||
m_outputs->display()->handleEvent(e);
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
KephalService::KephalService(QObject * parent)
|
||||
: QObject(parent),
|
||||
m_noXRandR(false)
|
||||
{
|
||||
kDebug() << "kephald starting up";
|
||||
init();
|
||||
}
|
||||
|
||||
KephalService::~KephalService()
|
||||
{
|
||||
delete m_eventFilter;
|
||||
}
|
||||
|
||||
void KephalService::init()
|
||||
{ KConfig config("kephalrc");
|
||||
KConfigGroup general(&config, "General");
|
||||
m_noXRandR = general.readEntry("NoXRandR", false);
|
||||
|
||||
m_outputs = 0;
|
||||
#ifdef HAS_RANDR_1_2
|
||||
RandRDisplay *display = 0;
|
||||
if (! m_noXRandR) {
|
||||
display = new RandRDisplay();
|
||||
}
|
||||
|
||||
if ((! m_noXRandR) && display && display->isValid()) {
|
||||
m_outputs = new XRandROutputs(this, display);
|
||||
if (m_outputs->outputs().size() <= 1) {
|
||||
delete m_outputs;
|
||||
m_outputs = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (! m_outputs) {
|
||||
//new DesktopWidgetOutputs(this);
|
||||
|
||||
}
|
||||
|
||||
foreach (Output * output, Outputs::self()->outputs()) {
|
||||
kDebug() << "output:" << output->id() << output->geom() << output->rotation() << output->reflectX() << output->reflectY();
|
||||
}
|
||||
|
||||
new XMLConfigurations(this);
|
||||
//new ConfigurationScreens(this);
|
||||
|
||||
//X foreach (Kephal::Screen * screen, Screens::self()->screens()) {
|
||||
//X kDebug() << "screen:" << screen->id() << screen->geom();
|
||||
//X }
|
||||
//X
|
||||
activateConfiguration();
|
||||
connect(Outputs::self(), SIGNAL(outputDisconnected(Kephal::Output*)), this, SLOT(outputDisconnected(Kephal::Output*)));
|
||||
connect(Outputs::self(), SIGNAL(outputConnected(Kephal::Output*)), this, SLOT(outputConnected(Kephal::Output*)));
|
||||
|
||||
//X kDebug() << "will check for possible positions...";
|
||||
//X foreach (Output * output, Outputs::self()->outputs()) {
|
||||
//X kDebug() << "possible positions for:" << output->id() << Configurations::self()->possiblePositions(output);
|
||||
//X }
|
||||
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
bool result = dbus.registerService("org.kde.Kephal");
|
||||
kDebug() << "registered the service:" << result;
|
||||
|
||||
//new DBusAPIScreens(this);
|
||||
//new DBusAPIOutputs(this);
|
||||
//new DBusAPIConfigurations(this);
|
||||
|
||||
if (m_outputs) {
|
||||
m_eventFilter = new X11EventFilter(m_outputs);
|
||||
kapp->installX11EventFilter(m_eventFilter);
|
||||
|
||||
m_pollTimer = new QTimer(this);
|
||||
connect(m_pollTimer, SIGNAL(timeout()), this, SLOT(poll()));
|
||||
//X if (Configurations::self()->polling()) {
|
||||
//X m_pollTimer->start(10000);
|
||||
//X }
|
||||
} else {
|
||||
m_pollTimer = 0;
|
||||
m_eventFilter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void KephalService::pollingActivated()
|
||||
{
|
||||
if (m_pollTimer && m_outputs) {
|
||||
m_pollTimer->start(10000);
|
||||
}
|
||||
}
|
||||
|
||||
void KephalService::pollingDeactivated()
|
||||
{
|
||||
if (m_pollTimer && m_outputs) {
|
||||
m_pollTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void KephalService::poll()
|
||||
{
|
||||
#ifdef HAS_RANDR_1_2
|
||||
if (m_outputs) {
|
||||
m_outputs->display()->screen(0)->pollState();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void KephalService::activateConfiguration()
|
||||
{
|
||||
//X BackendConfigurations * configs = BackendConfigurations::self();
|
||||
//X Configuration * config = configs->findConfiguration();
|
||||
//X configs->applyOutputSettings();
|
||||
//X if (config) {
|
||||
//X config->activate();
|
||||
//X } else {
|
||||
//X kDebug() << "couldnt find matching configuration!!";
|
||||
//X }
|
||||
}
|
||||
|
||||
void KephalService::outputDisconnected(Output * output)
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
// activateConfiguration();
|
||||
}
|
||||
|
||||
void KephalService::outputConnected(Output * output)
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
// activateConfiguration();
|
||||
}
|
||||
|
||||
#include "moc_kephalservice.cpp"
|
||||
|
||||
// vim: sw=4 sts=4 et tw=100
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
#ifndef KEPHALSERVICE_H
|
||||
#define KEPHALSERVICE_H
|
||||
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
namespace Kephal { class Output;
|
||||
class XRandROutputs;
|
||||
}
|
||||
|
||||
class X11EventFilter : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
X11EventFilter(Kephal::XRandROutputs * outputs);
|
||||
virtual ~X11EventFilter();
|
||||
|
||||
protected:
|
||||
#ifdef Q_WS_X11
|
||||
bool x11Event(XEvent * event);
|
||||
#endif
|
||||
private:
|
||||
Kephal::XRandROutputs * m_outputs;
|
||||
};
|
||||
|
||||
|
||||
class KephalService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KephalService(QObject * parent);
|
||||
virtual ~KephalService();
|
||||
private Q_SLOTS:
|
||||
void outputDisconnected(Kephal::Output * output);
|
||||
void outputConnected(Kephal::Output * output);
|
||||
void poll();
|
||||
void pollingActivated();
|
||||
void pollingDeactivated();
|
||||
|
||||
private:
|
||||
void init();
|
||||
void activateConfiguration();
|
||||
|
||||
bool m_noXRandR;
|
||||
Kephal::XRandROutputs * m_outputs;
|
||||
QTimer * m_pollTimer;
|
||||
X11EventFilter * m_eventFilter;
|
||||
};
|
||||
|
||||
#endif // KEPHALSERVICE_H
|
|
@ -1,270 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "outputscreens.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
OutputScreens::OutputScreens(QObject * parent)
|
||||
: Screens(parent),
|
||||
m_rebuildTimer(new QTimer(this))
|
||||
{
|
||||
m_rebuildTimer->setSingleShot(true);
|
||||
connect(m_rebuildTimer, SIGNAL(timeout()), this, SLOT(rebuildTimeout()));
|
||||
init();
|
||||
}
|
||||
|
||||
QList<Screen *> OutputScreens::screens() {
|
||||
QList<Screen *> result;
|
||||
foreach(OutputScreen * screen, m_screens) {
|
||||
result.append(screen);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int OutputScreens::findId() {
|
||||
for (int i = 0; i < m_screens.size(); ++i) {
|
||||
if (! m_screens.contains(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return m_screens.size();
|
||||
}
|
||||
|
||||
void OutputScreens::init() {
|
||||
buildScreens();
|
||||
|
||||
connect(Outputs::self(), SIGNAL(outputResized(Kephal::Output*,QSize,QSize)), this, SLOT(outputResized(Kephal::Output*,QSize,QSize)));
|
||||
connect(Outputs::self(), SIGNAL(outputMoved(Kephal::Output*,QPoint,QPoint)), this, SLOT(outputMoved(Kephal::Output*,QPoint,QPoint)));
|
||||
connect(Outputs::self(), SIGNAL(outputActivated(Kephal::Output*)), this, SLOT(outputActivated(Kephal::Output*)));
|
||||
connect(Outputs::self(), SIGNAL(outputDeactivated(Kephal::Output*)), this, SLOT(outputDeactivated(Kephal::Output*)));
|
||||
}
|
||||
|
||||
void OutputScreens::outputActivated(Kephal::Output * o) {
|
||||
Q_UNUSED(o)
|
||||
kDebug();
|
||||
triggerRebuildScreens();
|
||||
}
|
||||
|
||||
void OutputScreens::outputDeactivated(Kephal::Output * o) {
|
||||
Q_UNUSED(o)
|
||||
kDebug();
|
||||
triggerRebuildScreens();
|
||||
}
|
||||
|
||||
void OutputScreens::outputMoved(Kephal::Output * o, QPoint oldPosition, QPoint newPosition) {
|
||||
Q_UNUSED(o)
|
||||
Q_UNUSED(oldPosition)
|
||||
Q_UNUSED(newPosition)
|
||||
kDebug();
|
||||
triggerRebuildScreens();
|
||||
}
|
||||
|
||||
void OutputScreens::outputResized(Kephal::Output * o, QSize oldSize, QSize newSize) {
|
||||
Q_UNUSED(o)
|
||||
Q_UNUSED(oldSize)
|
||||
Q_UNUSED(newSize)
|
||||
kDebug();
|
||||
triggerRebuildScreens();
|
||||
}
|
||||
|
||||
void OutputScreens::buildScreens() {
|
||||
foreach (Output * output, Outputs::self()->outputs()) {
|
||||
// for each connected and active output,
|
||||
if (! output->isConnected() || ! output->isActivated()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// look for any screen which intersects this output, and add it to the screen
|
||||
bool found = false;
|
||||
foreach (OutputScreen * screen, m_screens) {
|
||||
if (screen->geom().intersects(output->geom())) {
|
||||
screen->add(output);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if the output did not intersect, add it to the first empty screen found
|
||||
if (! found) {
|
||||
foreach (OutputScreen * screen, m_screens) {
|
||||
if (screen->outputs().empty()) {
|
||||
screen->add(output);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if no empty screen found, generate one and add this output to it.
|
||||
if (! found) {
|
||||
OutputScreen * screen = new OutputScreen(this);
|
||||
screen->_setId(findId());
|
||||
screen->add(output);
|
||||
m_screens.insert(screen->id(), screen);
|
||||
}
|
||||
}
|
||||
|
||||
// remove any remaining empty screens
|
||||
for (QMap<int, OutputScreen *>::iterator i = m_screens.begin(); i != m_screens.end();) {
|
||||
if (i.value()->outputs().empty()) {
|
||||
i = m_screens.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// remove any intersecting Screens and add removed Screens' Outputs to the intersected Screen
|
||||
bool changed;
|
||||
do {
|
||||
changed = false;
|
||||
for (QMap<int, OutputScreen *>::iterator i = m_screens.begin(); i != m_screens.end(); ++i) {
|
||||
bool deleted = false;
|
||||
for (QMap<int, OutputScreen *>::iterator j = i + 1; j != m_screens.end(); ++j) {
|
||||
if (i.value()->geom().intersects(j.value()->geom())) {
|
||||
OutputScreen * to = i.value();
|
||||
OutputScreen * from = j.value();
|
||||
|
||||
foreach (Output * output, from->outputs()) {
|
||||
to->add(output);
|
||||
}
|
||||
|
||||
changed = true;
|
||||
deleted = true;
|
||||
m_screens.erase(j);
|
||||
delete from;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (deleted) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (changed);
|
||||
|
||||
// I think this tries to renumber m_screens from 0, removing any gaps due to removed
|
||||
// intersecting screens
|
||||
for (int i = 0; i < m_screens.size(); ++i) {
|
||||
if (! m_screens.contains(i)) {
|
||||
// get the lowest numbered screen in m_screens
|
||||
int min = -1;
|
||||
for (QMap<int, OutputScreen *>::iterator it = m_screens.begin(); it != m_screens.end(); ++it) {
|
||||
if ((min == -1) || (it.key() < min)) {
|
||||
min = it.key();
|
||||
}
|
||||
}
|
||||
OutputScreen * screen = m_screens.take(min);
|
||||
screen->_setId(i);
|
||||
m_screens.insert(i, screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OutputScreens::triggerRebuildScreens() {
|
||||
kDebug();
|
||||
m_rebuildTimer->start(200);
|
||||
}
|
||||
|
||||
void OutputScreens::rebuildTimeout() {
|
||||
rebuildScreens();
|
||||
}
|
||||
|
||||
void OutputScreens::rebuildScreens() {
|
||||
kDebug();
|
||||
|
||||
QMap<int, QRect> geoms;
|
||||
for (QMap<int, OutputScreen *>::const_iterator i = m_screens.constBegin(); i != m_screens.constEnd(); ++i) {
|
||||
geoms.insert(i.key(), i.value()->geom());
|
||||
i.value()->clearOutputs();
|
||||
}
|
||||
|
||||
prepareScreens(m_screens);
|
||||
buildScreens();
|
||||
|
||||
for (QMap<int, OutputScreen *>::const_iterator i = m_screens.constBegin(); i != m_screens.constEnd(); ++i) {
|
||||
if (! geoms.contains(i.key())) {
|
||||
emit screenAdded(i.value());
|
||||
kDebug() << "emitted screenAdded " << i.key();
|
||||
} else if (geoms[i.key()] != i.value()->geom()) {
|
||||
if (geoms[i.key()].topLeft() != i.value()->geom().topLeft()) {
|
||||
emit screenMoved(i.value(), geoms[i.key()].topLeft(), i.value()->geom().topLeft());
|
||||
kDebug() << "emitted screenMoved " << i.key() << " - old " << geoms[i.key()] << " - new " << i.value()->geom();
|
||||
}
|
||||
if (geoms[i.key()].size() != i.value()->geom().size()) {
|
||||
emit screenResized(i.value(), geoms[i.key()].size(), i.value()->geom().size());
|
||||
kDebug() << "emitted screenResized " << i.key() << " - old " << geoms[i.key()] << " - new " << i.value()->geom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (QMap<int, QRect>::const_iterator i = geoms.constBegin(); i != geoms.constEnd(); ++i) {
|
||||
if (! m_screens.contains(i.key())) {
|
||||
emit screenRemoved(i.key());
|
||||
kDebug() << "emitted screenRemoved " << i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OutputScreens::prepareScreens(QMap<int, OutputScreen *> & screens) {
|
||||
Q_UNUSED(screens)
|
||||
}
|
||||
|
||||
|
||||
|
||||
OutputScreen::OutputScreen(QObject * parent)
|
||||
: SimpleScreen(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void OutputScreen::add(Output * output) {
|
||||
m_outputs.append(output);
|
||||
|
||||
QRect geom = this->geom();
|
||||
if (geom.isEmpty()) {
|
||||
geom = output->geom();
|
||||
} else {
|
||||
geom = geom.unite(output->geom());
|
||||
}
|
||||
|
||||
_setSize(geom.size());
|
||||
_setPosition(geom.topLeft());
|
||||
}
|
||||
|
||||
QList<Output *> OutputScreen::outputs() {
|
||||
return m_outputs;
|
||||
}
|
||||
|
||||
void OutputScreen::remove(Output * output) {
|
||||
m_outputs.removeAll(output);
|
||||
}
|
||||
|
||||
void OutputScreen::clearOutputs() {
|
||||
m_outputs.clear();
|
||||
_setSize(QSize(0, 0));
|
||||
_setPosition(QPoint(0, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef NO_KDE
|
||||
#include "moc_outputscreens.cpp"
|
||||
#endif
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_OUTPUTSCREENS_H
|
||||
#define KEPHAL_OUTPUTSCREENS_H
|
||||
|
||||
#include "screens.h"
|
||||
#include "simplescreen.h"
|
||||
#include "outputs.h"
|
||||
|
||||
|
||||
#include <QTimer>
|
||||
namespace Kephal {
|
||||
|
||||
/**
|
||||
* Maps outputs to a single Screen
|
||||
*/
|
||||
class OutputScreen : public SimpleScreen {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OutputScreen(QObject * parent);
|
||||
|
||||
void add(Output * output);
|
||||
void remove(Output * output);
|
||||
void clearOutputs();
|
||||
QList<Output *> outputs();
|
||||
|
||||
private:
|
||||
QList<Output *> m_outputs;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Screens object containing output signalling and mapping between Outputs and Screens
|
||||
*/
|
||||
class OutputScreens : public Screens {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OutputScreens(QObject * parent);
|
||||
virtual QList<Screen *> screens();
|
||||
|
||||
protected:
|
||||
//cannot be pure virtual because libkephal.cpp instantates an OutputScreens
|
||||
virtual void prepareScreens(QMap<int, OutputScreen *> & screens);
|
||||
void rebuildScreens();
|
||||
void triggerRebuildScreens(); // Triggers a rebuild aftera short delay; requests are coalesced.
|
||||
|
||||
private Q_SLOTS:
|
||||
void outputActivated(Kephal::Output * o);
|
||||
void outputDeactivated(Kephal::Output * o);
|
||||
void outputResized(Kephal::Output * o, QSize oldSize, QSize newSize);
|
||||
void outputMoved(Kephal::Output * o, QPoint oldPosition, QPoint newPosition);
|
||||
void rebuildTimeout();
|
||||
|
||||
private:
|
||||
void init();
|
||||
void buildScreens();
|
||||
int findId();
|
||||
|
||||
QMap<int, OutputScreen *> m_screens;
|
||||
|
||||
QTimer * m_rebuildTimer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_OUTPUTSCREENS_H
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
These classes allow a simple type of xml-data-binding. I'll add some
|
||||
docs to this once i find some time, currently these are only for
|
||||
internal use in Kephal.
|
||||
|
||||
configurations_xml.[h|cpp] has the actual xml-classes for Kephals
|
||||
xml-file.
|
||||
|
||||
all other files just offer the basics for schema-definition, loading
|
||||
and saving of xml.
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "configurations_xml.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include "xmlnodehandler.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class ScreenXMLFactory : public XMLFactory {
|
||||
protected:
|
||||
virtual XMLType * newInstance() { return new ScreenXML(); }
|
||||
virtual void schema() {
|
||||
INT_ATTRIBUTE("id", ScreenXML, id, setId);
|
||||
BOOL_ELEMENT("privacy", ScreenXML, privacy, setPrivacy);
|
||||
INT_ELEMENT("right-of", ScreenXML, rightOf, setRightOf);
|
||||
INT_ELEMENT("bottom-of", ScreenXML, bottomOf, setBottomOf);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ConfigurationXMLFactory : public XMLFactory {
|
||||
protected:
|
||||
virtual XMLType * newInstance() { return new ConfigurationXML(); }
|
||||
virtual void schema() {
|
||||
STRING_ATTRIBUTE("name", ConfigurationXML, name, setName);
|
||||
INT_ATTRIBUTE("primary", ConfigurationXML, primaryScreen, setPrimaryScreen);
|
||||
BOOL_ATTRIBUTE("modifiable", ConfigurationXML, modifiable, setModifiable);
|
||||
COMPLEX_ELEMENT_LIST("screen", ConfigurationXML, screens, new ScreenXMLFactory(), ScreenXML);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class OutputXMLFactory : public XMLFactory {
|
||||
protected:
|
||||
virtual XMLType * newInstance() { return new OutputXML(); }
|
||||
virtual void schema() {
|
||||
STRING_ATTRIBUTE("name", OutputXML, name, setName);
|
||||
INT_ATTRIBUTE("screen", OutputXML, screen, setScreen);
|
||||
STRING_ELEMENT("vendor", OutputXML, vendor, setVendor);
|
||||
INT_ELEMENT("product", OutputXML, product, setProduct);
|
||||
UINT_ELEMENT("serial", OutputXML, serial, setSerial);
|
||||
INT_ELEMENT("width", OutputXML, width, setWidth);
|
||||
INT_ELEMENT("height", OutputXML, height, setHeight);
|
||||
INT_ELEMENT("rotation", OutputXML, rotation, setRotation);
|
||||
BOOL_ELEMENT("reflect-x", OutputXML, reflectX, setReflectX);
|
||||
BOOL_ELEMENT("reflect-y", OutputXML, reflectY, setReflectY);
|
||||
DOUBLE_ELEMENT("refresh-rate", OutputXML, rate, setRate);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class OutputsXMLFactory : public XMLFactory {
|
||||
protected:
|
||||
virtual XMLType * newInstance() { return new OutputsXML(); }
|
||||
virtual void schema() {
|
||||
STRING_ATTRIBUTE("configuration", OutputsXML, configuration, setConfiguration);
|
||||
COMPLEX_ELEMENT_LIST("output", OutputsXML, outputs, new OutputXMLFactory(), OutputXML);
|
||||
}
|
||||
};
|
||||
|
||||
ScreenXML::ScreenXML(QObject * parent)
|
||||
: XMLType(parent), m_rightOf(-1), m_bottomOf(-1)
|
||||
{
|
||||
}
|
||||
|
||||
ScreenXML::~ScreenXML()
|
||||
{
|
||||
}
|
||||
|
||||
OutputXML::OutputXML(QObject * parent)
|
||||
: XMLType(parent), m_screen(-1), m_product(-1), m_serial(0),
|
||||
m_width(-1), m_height(-1), m_rotation(0),
|
||||
m_reflectX(false), m_reflectY(false), m_rate(0)
|
||||
{ }
|
||||
|
||||
OutputXML::~OutputXML()
|
||||
{}
|
||||
|
||||
ConfigurationXML::ConfigurationXML(QObject * parent)
|
||||
: XMLType(parent), m_modifiable(true), m_primaryScreen(0)
|
||||
{ }
|
||||
|
||||
ConfigurationXML::~ConfigurationXML()
|
||||
{
|
||||
}
|
||||
|
||||
OutputsXML::OutputsXML(QObject * parent)
|
||||
: XMLType(parent)
|
||||
{
|
||||
|
||||
}
|
||||
OutputsXML::~OutputsXML()
|
||||
{
|
||||
}
|
||||
|
||||
QList<ScreenXML *> & ConfigurationXML::screens() { return m_screens; }
|
||||
|
||||
ConfigurationsXML::ConfigurationsXML(QObject * parent)
|
||||
: XMLType(parent), m_polling(false)
|
||||
{
|
||||
}
|
||||
|
||||
ConfigurationsXML::~ConfigurationsXML()
|
||||
{
|
||||
}
|
||||
|
||||
QList<ConfigurationXML *> & ConfigurationsXML::configurations() { return m_configurations; }
|
||||
QList<OutputsXML *> & ConfigurationsXML::outputs() { return m_outputs; }
|
||||
|
||||
ConfigurationsXMLFactory::ConfigurationsXMLFactory() : XMLRootFactory("configurations") {
|
||||
}
|
||||
ConfigurationsXMLFactory::~ConfigurationsXMLFactory()
|
||||
{
|
||||
}
|
||||
|
||||
XMLType * ConfigurationsXMLFactory::newInstance() {
|
||||
return new ConfigurationsXML();
|
||||
}
|
||||
|
||||
void ConfigurationsXMLFactory::schema() {
|
||||
BOOL_ELEMENT("polling", ConfigurationsXML, polling, setPolling);
|
||||
COMPLEX_ELEMENT_LIST("configuration", ConfigurationsXML, configurations, new ConfigurationXMLFactory(), ConfigurationXML);
|
||||
COMPLEX_ELEMENT_LIST("outputs", ConfigurationsXML, outputs, new OutputsXMLFactory(), OutputsXML);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_CONFIGURATIONSXML_H
|
||||
#define KEPHAL_CONFIGURATIONSXML_H
|
||||
|
||||
#include "xmltype.h"
|
||||
#include "kephal.h"
|
||||
#include "backend.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class ScreenXML : public XMLType {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScreenXML(QObject * parent = 0);
|
||||
~ScreenXML();
|
||||
|
||||
|
||||
PROPERTY(int, id, setId)
|
||||
PROPERTY(int, rightOf, setRightOf)
|
||||
PROPERTY(int, bottomOf, setBottomOf)
|
||||
PROPERTY(bool, privacy, setPrivacy)
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ConfigurationXML : public XMLType {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigurationXML(QObject * parent = 0);
|
||||
~ConfigurationXML();
|
||||
|
||||
QList<ScreenXML *> & screens();
|
||||
|
||||
|
||||
PROPERTY(QString, name, setName)
|
||||
PROPERTY(bool, modifiable, setModifiable)
|
||||
PROPERTY(int, primaryScreen, setPrimaryScreen)
|
||||
|
||||
private:
|
||||
QList<ScreenXML *> m_screens;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class OutputXML : public XMLType {
|
||||
Q_OBJECT
|
||||
|
||||
PROPERTY(QString, name, setName)
|
||||
PROPERTY(int, screen, setScreen)
|
||||
PROPERTY(QString, vendor, setVendor)
|
||||
PROPERTY(int, product, setProduct)
|
||||
PROPERTY(unsigned int, serial, setSerial)
|
||||
PROPERTY(int, width, setWidth)
|
||||
PROPERTY(int, height, setHeight)
|
||||
PROPERTY(int, rotation, setRotation)
|
||||
PROPERTY(bool, reflectX, setReflectX)
|
||||
PROPERTY(bool, reflectY, setReflectY)
|
||||
PROPERTY(double, rate, setRate)
|
||||
PROPERTY(QString, actualOutput, setActualOutput)
|
||||
|
||||
public:
|
||||
OutputXML(QObject * parent = 0);
|
||||
~OutputXML();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class OutputsXML : public XMLType {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OutputsXML(QObject * parent = 0);
|
||||
~OutputsXML();
|
||||
|
||||
PROPERTY(QString, configuration, setConfiguration)
|
||||
|
||||
public:
|
||||
QList<OutputXML *> & outputs() { return m_outputs; }
|
||||
private:
|
||||
QList<OutputXML *> m_outputs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ConfigurationsXML : public XMLType {
|
||||
Q_OBJECT
|
||||
|
||||
PROPERTY(bool, polling, setPolling)
|
||||
|
||||
public:
|
||||
ConfigurationsXML(QObject * parent = 0);
|
||||
virtual ~ConfigurationsXML();
|
||||
|
||||
QList<ConfigurationXML *> & configurations();
|
||||
QList<OutputsXML *> & outputs();
|
||||
|
||||
private:
|
||||
QList<ConfigurationXML *> m_configurations;
|
||||
QList<OutputsXML *> m_outputs;
|
||||
};
|
||||
|
||||
class ConfigurationsXMLFactory : public XMLRootFactory {
|
||||
public:
|
||||
ConfigurationsXMLFactory();
|
||||
~ConfigurationsXMLFactory();
|
||||
|
||||
protected:
|
||||
virtual XMLType * newInstance();
|
||||
virtual void schema();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KEPHAL_CONFIGURATIONSXML_H
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "xmlnodehandler.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
}
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_XMLNODEHANDLER_H
|
||||
#define KEPHAL_XMLNODEHANDLER_H
|
||||
|
||||
|
||||
#include "xmltype.h"
|
||||
|
||||
#include <QtXml/qdom.h>
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class XMLType;
|
||||
class XMLFactory;
|
||||
|
||||
|
||||
class XMLNodeHandler {
|
||||
public:
|
||||
virtual ~XMLNodeHandler() {}
|
||||
|
||||
virtual void beginSave(XMLType * element) = 0;
|
||||
virtual void beginLoad(XMLType * element) = 0;
|
||||
virtual bool hasMore(XMLType * element) = 0;
|
||||
virtual void setNode(XMLType * element, QDomNode node) = 0;
|
||||
virtual QDomNode node(XMLType * element, QDomDocument doc, QString name) = 0;
|
||||
virtual QString str(XMLType * element) = 0;
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
class XMLSimpleNodeHandler : public XMLNodeHandler {
|
||||
public:
|
||||
typedef void (ElementType::*Setter)(SimpleType);
|
||||
typedef SimpleType (ElementType::*Getter)();
|
||||
|
||||
XMLSimpleNodeHandler(Getter getter, Setter setter);
|
||||
|
||||
virtual void beginSave(XMLType * element);
|
||||
virtual void beginLoad(XMLType * element);
|
||||
virtual bool hasMore(XMLType * element);
|
||||
virtual void setNode(XMLType * element, QDomNode node);
|
||||
virtual QDomNode node(XMLType * element, QDomDocument doc, QString name);
|
||||
virtual QString str(XMLType * element);
|
||||
|
||||
protected:
|
||||
virtual SimpleType toValue(QString str) = 0;
|
||||
virtual QString toString(SimpleType value) = 0;
|
||||
|
||||
private:
|
||||
Getter m_getter;
|
||||
Setter m_setter;
|
||||
bool m_saved;
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
class XMLStringNodeHandler : public XMLSimpleNodeHandler<ElementType, QString> {
|
||||
public:
|
||||
typedef void (ElementType::*Setter)(QString);
|
||||
typedef QString (ElementType::*Getter)();
|
||||
|
||||
XMLStringNodeHandler(Getter getter, Setter setter);
|
||||
|
||||
protected:
|
||||
virtual QString toValue(QString str);
|
||||
virtual QString toString(QString value);
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
class XMLIntNodeHandler : public XMLSimpleNodeHandler<ElementType, int> {
|
||||
public:
|
||||
typedef void (ElementType::*Setter)(int);
|
||||
typedef int (ElementType::*Getter)();
|
||||
|
||||
XMLIntNodeHandler(Getter getter, Setter setter);
|
||||
|
||||
protected:
|
||||
virtual int toValue(QString str);
|
||||
virtual QString toString(int value);
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
class XMLUIntNodeHandler : public XMLSimpleNodeHandler<ElementType, unsigned int> {
|
||||
public:
|
||||
typedef void (ElementType::*Setter)(unsigned int);
|
||||
typedef unsigned int (ElementType::*Getter)();
|
||||
|
||||
XMLUIntNodeHandler(Getter getter, Setter setter);
|
||||
|
||||
protected:
|
||||
virtual unsigned int toValue(QString str);
|
||||
virtual QString toString(unsigned int value);
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
class XMLDoubleNodeHandler : public XMLSimpleNodeHandler<ElementType, double> {
|
||||
public:
|
||||
typedef void (ElementType::*Setter)(double);
|
||||
typedef double (ElementType::*Getter)();
|
||||
|
||||
XMLDoubleNodeHandler(Getter getter, Setter setter);
|
||||
|
||||
protected:
|
||||
virtual double toValue(QString str);
|
||||
virtual QString toString(double value);
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
class XMLBoolNodeHandler : public XMLSimpleNodeHandler<ElementType, bool> {
|
||||
public:
|
||||
typedef void (ElementType::*Setter)(bool);
|
||||
typedef bool (ElementType::*Getter)();
|
||||
|
||||
XMLBoolNodeHandler(Getter getter, Setter setter);
|
||||
|
||||
protected:
|
||||
virtual bool toValue(QString str);
|
||||
virtual QString toString(bool value);
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType, class ComplexType>
|
||||
class XMLComplexNodeHandler : public XMLNodeHandler {
|
||||
public:
|
||||
typedef void (ElementType::*Setter)(ComplexType *);
|
||||
|
||||
XMLComplexNodeHandler(XMLFactory * factory, Setter setter);
|
||||
|
||||
virtual void beginSave(XMLType * element);
|
||||
virtual void beginLoad(XMLType * element);
|
||||
virtual bool hasMore(XMLType * element);
|
||||
virtual void setNode(XMLType * element, QDomNode node);
|
||||
virtual QDomNode node(XMLType * element, QDomDocument doc, QString name);
|
||||
virtual QString str(XMLType * element);
|
||||
|
||||
private:
|
||||
XMLFactory * m_factory;
|
||||
Setter m_setter;
|
||||
bool m_saved;
|
||||
};
|
||||
|
||||
|
||||
template <class ElementType, class ComplexType>
|
||||
class XMLComplexListNodeHandler : public XMLNodeHandler {
|
||||
public:
|
||||
typedef QList<ComplexType *> & (ElementType::*ListGetter)();
|
||||
|
||||
XMLComplexListNodeHandler(XMLFactory * factory, ListGetter listGetter);
|
||||
|
||||
virtual void beginSave(XMLType * element);
|
||||
virtual void beginLoad(XMLType * element);
|
||||
virtual bool hasMore(XMLType * element);
|
||||
virtual void setNode(XMLType * element, QDomNode node);
|
||||
virtual QDomNode node(XMLType * element, QDomDocument doc, QString name);
|
||||
virtual QString str(XMLType * element);
|
||||
|
||||
private:
|
||||
XMLFactory * m_factory;
|
||||
ListGetter m_listGetter;
|
||||
int m_pos;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include "xmlnodehandler.h.cpp"
|
||||
|
||||
|
||||
#define STRING_ATTRIBUTE(name, class, getter, setter) attribute(name, new XMLStringNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define INT_ATTRIBUTE(name, class, getter, setter) attribute(name, new XMLIntNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define UINT_ATTRIBUTE(name, class, getter, setter) attribute(name, new XMLUIntNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define DOUBLE_ATTRIBUTE(name, class, getter, setter) attribute(name, new XMLDoubleNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define BOOL_ATTRIBUTE(name, class, getter, setter) attribute(name, new XMLBoolNodeHandler<class>(&class::getter, &class::setter))
|
||||
|
||||
#define STRING_ELEMENT(name, class, getter, setter) element(name, new XMLStringNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define INT_ELEMENT(name, class, getter, setter) element(name, new XMLIntNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define UINT_ELEMENT(name, class, getter, setter) element(name, new XMLUIntNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define DOUBLE_ELEMENT(name, class, getter, setter) element(name, new XMLDoubleNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define BOOL_ELEMENT(name, class, getter, setter) element(name, new XMLBoolNodeHandler<class>(&class::getter, &class::setter))
|
||||
#define COMPLEX_ELEMENT(name, class, setter, factory, complex) element(name, new XMLComplexNodeHandler<class, complex>(factory, &class::setter))
|
||||
#define COMPLEX_ELEMENT_LIST(name, class, listGetter, factory, complex) element(name, new XMLComplexListNodeHandler<class, complex>(factory, &class::listGetter))
|
||||
|
||||
|
||||
#endif // KEPHAL_XMLNODEHANDLER_H
|
||||
|
|
@ -1,237 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
XMLSimpleNodeHandler<ElementType, SimpleType>::XMLSimpleNodeHandler(Getter getter, Setter setter) {
|
||||
m_setter = setter;
|
||||
m_getter = getter;
|
||||
}
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
void XMLSimpleNodeHandler<ElementType, SimpleType>::beginSave(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
m_saved = false;
|
||||
}
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
void XMLSimpleNodeHandler<ElementType, SimpleType>::beginLoad(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
}
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
bool XMLSimpleNodeHandler<ElementType, SimpleType>::hasMore(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
return ! m_saved;
|
||||
}
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
void XMLSimpleNodeHandler<ElementType, SimpleType>::setNode(XMLType * element, QDomNode node) {
|
||||
QDomNode child = node.firstChild();
|
||||
if (! child.isNull()) {
|
||||
((ElementType *)element->*m_setter)(toValue(child.nodeValue()));
|
||||
}
|
||||
}
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
QDomNode XMLSimpleNodeHandler<ElementType, SimpleType>::node(XMLType * element, QDomDocument doc, QString name) {
|
||||
m_saved = true;
|
||||
QDomNode node = doc.createElement(name);
|
||||
node.appendChild(doc.createTextNode(toString(((ElementType *)element->*m_getter)())));
|
||||
return node;
|
||||
}
|
||||
|
||||
template <class ElementType, typename SimpleType>
|
||||
QString XMLSimpleNodeHandler<ElementType, SimpleType>::str(XMLType * element) {
|
||||
return toString(((ElementType *)element->*m_getter)());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
XMLStringNodeHandler<ElementType>::XMLStringNodeHandler(Getter getter, Setter setter) : XMLSimpleNodeHandler<ElementType, QString>(getter, setter) {
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
QString XMLStringNodeHandler<ElementType>::toValue(QString str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
QString XMLStringNodeHandler<ElementType>::toString(QString str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
XMLIntNodeHandler<ElementType>::XMLIntNodeHandler(Getter getter, Setter setter) : XMLSimpleNodeHandler<ElementType, int>(getter, setter) {
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
int XMLIntNodeHandler<ElementType>::toValue(QString str) {
|
||||
return str.toInt();
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
QString XMLIntNodeHandler<ElementType>::toString(int i) {
|
||||
return QString::number(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
XMLUIntNodeHandler<ElementType>::XMLUIntNodeHandler(Getter getter, Setter setter) : XMLSimpleNodeHandler<ElementType, unsigned int>(getter, setter) {
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
unsigned int XMLUIntNodeHandler<ElementType>::toValue(QString str) {
|
||||
return str.toUInt();
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
QString XMLUIntNodeHandler<ElementType>::toString(unsigned int i) {
|
||||
return QString::number(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
XMLDoubleNodeHandler<ElementType>::XMLDoubleNodeHandler(Getter getter, Setter setter) : XMLSimpleNodeHandler<ElementType, double>(getter, setter) {
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
double XMLDoubleNodeHandler<ElementType>::toValue(QString str) {
|
||||
return str.toDouble();
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
QString XMLDoubleNodeHandler<ElementType>::toString(double i) {
|
||||
return QString::number(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ElementType>
|
||||
XMLBoolNodeHandler<ElementType>::XMLBoolNodeHandler(Getter getter, Setter setter) : XMLSimpleNodeHandler<ElementType, bool>(getter, setter) {
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
bool XMLBoolNodeHandler<ElementType>::toValue(QString str) {
|
||||
return str == "true" || str == "t" || str == "on" || str == "1";
|
||||
}
|
||||
|
||||
template <class ElementType>
|
||||
QString XMLBoolNodeHandler<ElementType>::toString(bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ElementType, class ComplexType>
|
||||
XMLComplexNodeHandler<ElementType, ComplexType>::XMLComplexNodeHandler(XMLFactory * factory, Setter setter) {
|
||||
m_factory = factory;
|
||||
m_setter = setter;
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
void XMLComplexNodeHandler<ElementType, ComplexType>::beginSave(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
m_saved = false;
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
void XMLComplexNodeHandler<ElementType, ComplexType>::beginLoad(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
bool XMLComplexNodeHandler<ElementType, ComplexType>::hasMore(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
return ! m_saved;
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
void XMLComplexNodeHandler<ElementType, ComplexType>::setNode(XMLType * element, QDomNode node) {
|
||||
ComplexType * complex = (ComplexType *) m_factory->load(node);
|
||||
((ElementType *)element->*m_setter)(complex);
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
QDomNode XMLComplexNodeHandler<ElementType, ComplexType>::node(XMLType * element, QDomDocument doc, QString name) {
|
||||
Q_UNUSED(element)
|
||||
m_saved = true;
|
||||
QDomNode node;
|
||||
return node;
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
QString XMLComplexNodeHandler<ElementType, ComplexType>::str(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class ElementType, class ComplexType>
|
||||
XMLComplexListNodeHandler<ElementType, ComplexType>::XMLComplexListNodeHandler(XMLFactory * factory, ListGetter listGetter) {
|
||||
m_factory = factory;
|
||||
m_listGetter = listGetter;
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
bool XMLComplexListNodeHandler<ElementType, ComplexType>::hasMore(XMLType * element) {
|
||||
return m_pos < ((ElementType *)element->*m_listGetter)().size();
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
void XMLComplexListNodeHandler<ElementType, ComplexType>::setNode(XMLType * element, QDomNode node) {
|
||||
ComplexType * complex = (ComplexType *) m_factory->load(node);
|
||||
((ElementType *)element->*m_listGetter)().append(complex);
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
QDomNode XMLComplexListNodeHandler<ElementType, ComplexType>::node(XMLType * element, QDomDocument doc, QString name) {
|
||||
ComplexType * complex = ((ElementType *)element->*m_listGetter)().at(m_pos);
|
||||
++m_pos;
|
||||
return m_factory->save(complex, doc, name);
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
void XMLComplexListNodeHandler<ElementType, ComplexType>::beginSave(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
void XMLComplexListNodeHandler<ElementType, ComplexType>::beginLoad(XMLType * element) {
|
||||
((ElementType *)element->*m_listGetter)().clear();
|
||||
}
|
||||
|
||||
template <class ElementType, typename ComplexType>
|
||||
QString XMLComplexListNodeHandler<ElementType, ComplexType>::str(XMLType * element) {
|
||||
Q_UNUSED(element)
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "xmltype.h"
|
||||
#include "xmlnodehandler.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
XMLType::XMLType(QObject * parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
XMLType::~XMLType()
|
||||
{
|
||||
}
|
||||
|
||||
XMLFactory::XMLFactory() {
|
||||
m_schema = false;
|
||||
}
|
||||
|
||||
XMLFactory::~XMLFactory() {
|
||||
qDeleteAll(m_attributes);
|
||||
qDeleteAll(m_elements);
|
||||
}
|
||||
|
||||
XMLType * XMLRootFactory::load(QString fileName) {
|
||||
QFile file(fileName);
|
||||
if (! file.open(QIODevice::ReadOnly)) {
|
||||
//kDebug() << "couldnt open file" << fileName;
|
||||
if (! fileName.endsWith('~')) {
|
||||
return load(fileName + '~');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QDomDocument dom;
|
||||
if (! dom.setContent(&file)) {
|
||||
//kDebug() << "couldnt parse xml!!";
|
||||
file.close();
|
||||
if (! fileName.endsWith('~')) {
|
||||
return load(fileName + '~');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
file.close();
|
||||
|
||||
QDomElement root = dom.documentElement();
|
||||
if (root.nodeName() == m_name) {
|
||||
return XMLFactory::load(root);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
XMLType * XMLFactory::load(QDomNode root) {
|
||||
if (! m_schema) {
|
||||
schema();
|
||||
m_schema = true;
|
||||
}
|
||||
|
||||
//kDebug() << "root:" << root.isElement() << root.nodeName();
|
||||
if (! root.isElement()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
XMLType * result = newInstance();
|
||||
if (! result) {
|
||||
//kDebug() << "newInstance() returned 0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach (XMLNodeHandler * n, m_attributes) {
|
||||
n->beginLoad(result);
|
||||
}
|
||||
foreach (XMLNodeHandler * n, m_elements) {
|
||||
n->beginLoad(result);
|
||||
}
|
||||
|
||||
QDomNamedNodeMap attrs = root.attributes();
|
||||
for (int i = 0; i < attrs.size(); ++i) {
|
||||
QDomNode attr = attrs.item(i);
|
||||
//kDebug() << "attr:" << attr.isElement() << attr.nodeName();
|
||||
|
||||
QString name = attr.nodeName();
|
||||
if (m_attributes.contains(name)) {
|
||||
//kDebug() << "is known attribute...";
|
||||
XMLNodeHandler * xmlNode = m_attributes.value(name);
|
||||
xmlNode->setNode(result, attr);
|
||||
//kDebug() << "value has been set!!";
|
||||
}
|
||||
}
|
||||
|
||||
QDomNode node = root.firstChild();
|
||||
while (! node.isNull()) {
|
||||
//kDebug() << "node:" << node.isElement() << node.nodeName();
|
||||
if (! node.isElement()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString name = node.nodeName();
|
||||
if (m_elements.contains(name)) {
|
||||
//kDebug() << "is known element...";
|
||||
XMLNodeHandler * xmlNode = m_elements.value(name);
|
||||
xmlNode->setNode(result, node);
|
||||
//kDebug() << "value has been set!!";
|
||||
}
|
||||
|
||||
node = node.nextSibling();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool XMLRootFactory::save(XMLType * data, QString fileName) {
|
||||
QDomDocument doc;
|
||||
QDomProcessingInstruction header = doc.createProcessingInstruction("xml", "version=\"1.0\"");
|
||||
doc.appendChild(header);
|
||||
QDomNode node = XMLFactory::save(data, doc, m_name);
|
||||
if (! node.isNull()) {
|
||||
doc.appendChild(node);
|
||||
}
|
||||
QString content = doc.toString();
|
||||
|
||||
QFile file(fileName);
|
||||
QFile backup(fileName + '~');
|
||||
if (file.exists()) {
|
||||
if (backup.exists()) {
|
||||
if (! backup.remove()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (! file.rename(backup.fileName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||
QTextStream out(&file);
|
||||
out << content;
|
||||
file.close();
|
||||
|
||||
if (file.error() != QFile::NoError) {
|
||||
return false;
|
||||
}
|
||||
|
||||
backup.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomNode XMLFactory::save(XMLType * data, QDomDocument doc, QString name) {
|
||||
if (! m_schema) {
|
||||
schema();
|
||||
m_schema = true;
|
||||
}
|
||||
|
||||
QDomElement node = doc.createElement(name);
|
||||
for (QMap<QString, XMLNodeHandler *>::const_iterator i = m_attributes.constBegin(); i != m_attributes.constEnd(); ++i) {
|
||||
//kDebug() << "save attribute:" << i.key();
|
||||
QString value = i.value()->str(data);
|
||||
if (! value.isNull()) {
|
||||
node.setAttribute(i.key(), value);
|
||||
}
|
||||
}
|
||||
for (QMap<QString, XMLNodeHandler *>::const_iterator i = m_elements.constBegin(); i != m_elements.constEnd(); ++i) {
|
||||
//kDebug() << "save element:" << i.key();
|
||||
i.value()->beginSave(data);
|
||||
while (i.value()->hasMore(data)) {
|
||||
//kDebug() << "-> instance";
|
||||
QDomNode child = i.value()->node(data, doc, i.key());
|
||||
if (! child.isNull()) {
|
||||
node.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
void XMLFactory::element(QString name, XMLNodeHandler * element) {
|
||||
m_elements.insert(name, element);
|
||||
}
|
||||
|
||||
void XMLFactory::attribute(QString name, XMLNodeHandler * attribute) {
|
||||
m_attributes.insert(name, attribute);
|
||||
}
|
||||
|
||||
XMLRootFactory::XMLRootFactory(QString name) {
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_XMLTYPE_H
|
||||
#define KEPHAL_XMLTYPE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtXml/qdom.h>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class XMLNodeHandler;
|
||||
|
||||
|
||||
class XMLType : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
XMLType(QObject * parent = 0);
|
||||
virtual ~XMLType();
|
||||
};
|
||||
|
||||
|
||||
class XMLFactory {
|
||||
public:
|
||||
XMLFactory();
|
||||
virtual ~XMLFactory();
|
||||
|
||||
QDomNode save(XMLType * data, QDomDocument doc, QString name);
|
||||
XMLType * load(QDomNode node);
|
||||
|
||||
protected:
|
||||
void element(QString name, XMLNodeHandler * element);
|
||||
void attribute(QString name, XMLNodeHandler * attribute);
|
||||
|
||||
virtual XMLType * newInstance() = 0;
|
||||
virtual void schema() = 0;
|
||||
|
||||
private:
|
||||
QMap<QString, XMLNodeHandler *> m_elements;
|
||||
QMap<QString, XMLNodeHandler *> m_attributes;
|
||||
|
||||
bool m_schema;
|
||||
};
|
||||
|
||||
class XMLRootFactory : public XMLFactory {
|
||||
public:
|
||||
XMLRootFactory(QString name);
|
||||
virtual ~XMLRootFactory() {}
|
||||
bool save(XMLType * data, QString fileName);
|
||||
XMLType * load(QString fileName);
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_XMLTYPE_H
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
#include "xmlconfiguration.h"
|
||||
|
||||
#include <QSet>
|
||||
#include <KDebug>
|
||||
|
||||
#include "xmlconfigurations.h"
|
||||
#include "xml/configurations_xml.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
/* The layout initialisation code in the ctor came from XMLConfiguration::layout()
|
||||
* It tries to describe the relative screen layout of this Configuration
|
||||
* where each screen is a point in 2d space.
|
||||
* Used by BackendConfigurations::partition() and
|
||||
* XMLConfigurations::alternateConfigurations()
|
||||
* Broken because it only works if screens are laid out relative to one another, not
|
||||
* absolutely.
|
||||
*/
|
||||
XMLConfiguration::XMLConfiguration(XMLConfigurations * parent, ConfigurationXML * config)
|
||||
: BackendConfiguration(parent),
|
||||
m_configuration(config)
|
||||
{
|
||||
// set up remaining screens list, add all ScreenXMLs
|
||||
QMap<int, ScreenXML *> remaining;
|
||||
foreach (ScreenXML * screen, m_configuration->screens()) {
|
||||
remaining.insert(screen->id(), screen);
|
||||
}
|
||||
|
||||
QMap<int, QPoint> layout;
|
||||
bool changed;
|
||||
do {
|
||||
changed = false;
|
||||
QSet<ScreenXML *> added;
|
||||
// find the next remaining ScreenXML with known location relative to
|
||||
// an already known ScreenXML
|
||||
// starting with the first ScreenXML found at 0,0
|
||||
foreach (ScreenXML * screen, remaining) {
|
||||
QPoint pos;
|
||||
bool found = false;
|
||||
if (layout.empty()) {
|
||||
pos = QPoint(0, 0);
|
||||
found = true;
|
||||
} else if (layout.contains(screen->rightOf())) {
|
||||
pos = layout[screen->rightOf()];
|
||||
pos.rx()++;
|
||||
found = true;
|
||||
} else if (layout.contains(screen->bottomOf())) {
|
||||
pos = layout[screen->bottomOf()];
|
||||
pos.ry()++;
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
layout.insert(screen->id(), pos);
|
||||
changed = true;
|
||||
remaining.remove(screen->id());
|
||||
added.insert(screen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// for each added screenXml, move all of its left and above neighbours
|
||||
// to layout
|
||||
// left neighbours are placed 1 unit left of added
|
||||
// above neighbours are placed 1 unit above added
|
||||
//
|
||||
// note that added is changed inside this loop, so it probably moves all remaining
|
||||
// screenXmls out from remaining to layout, since the inner loop doesn't exit if they
|
||||
// are not neighbours.
|
||||
while (! added.empty()) {
|
||||
QSet<ScreenXML *>::iterator i = added.begin();
|
||||
|
||||
while (i != added.end()) {
|
||||
// locate its left neighbour
|
||||
ScreenXML * s = *i;
|
||||
if (remaining.contains(s->rightOf()) &&
|
||||
/* this seems like the wrong place to perform the following
|
||||
consistency check since screenxmls are always removed from
|
||||
remaining when added to layout */
|
||||
! layout.contains(s->rightOf())) {
|
||||
ScreenXML * toAdd = remaining[s->rightOf()];
|
||||
QPoint pos = QPoint(layout[s->id()]);
|
||||
pos.rx()--;
|
||||
|
||||
layout.insert(toAdd->id(), pos);
|
||||
added.insert(toAdd);
|
||||
remaining.remove(toAdd->id());
|
||||
break;
|
||||
}
|
||||
// locate its above neighbour
|
||||
if (remaining.contains(s->bottomOf()) &&
|
||||
/* as above */
|
||||
! layout.contains(s->bottomOf())) {
|
||||
ScreenXML * toAdd = remaining[s->bottomOf()];
|
||||
QPoint pos = QPoint(layout[s->id()]);
|
||||
pos.ry()--;
|
||||
|
||||
layout.insert(toAdd->id(), pos);
|
||||
added.insert(toAdd);
|
||||
remaining.remove(toAdd->id());
|
||||
break;
|
||||
}
|
||||
i = added.erase(i);
|
||||
// WILL well this is fucked... only exits if remaining contains a rightOf or
|
||||
// bottomOf relative screen. what if screens are not contiguous or relatively
|
||||
// located.
|
||||
//++i;
|
||||
}
|
||||
}
|
||||
} while (changed);
|
||||
|
||||
if (! remaining.empty()) {
|
||||
//kDebug() << "invalid configuration (remaining):" << name() << remaining;
|
||||
INVALID_CONFIGURATION("remaining screens")
|
||||
layout.clear();
|
||||
}
|
||||
|
||||
Configurations::translateOrigin(layout);
|
||||
m_layout = layout;
|
||||
}
|
||||
|
||||
ConfigurationXML * XMLConfiguration::configuration() const
|
||||
{
|
||||
return m_configuration;
|
||||
}
|
||||
|
||||
QString XMLConfiguration::name() const
|
||||
{
|
||||
return m_configuration->name();
|
||||
}
|
||||
|
||||
bool XMLConfiguration::isModifiable() const
|
||||
{
|
||||
return m_configuration->modifiable();
|
||||
}
|
||||
|
||||
bool XMLConfiguration::isActivated() const
|
||||
{
|
||||
return this == m_parent->activeConfiguration();
|
||||
}
|
||||
|
||||
void XMLConfiguration::activate()
|
||||
{
|
||||
emit configurationActivated(this);
|
||||
}
|
||||
|
||||
void XMLConfiguration::setLayout(const QMap<int, QPoint> & layout) {
|
||||
m_layout = layout;
|
||||
}
|
||||
|
||||
int XMLConfiguration::primaryScreen() const
|
||||
{
|
||||
return m_configuration->primaryScreen();
|
||||
}
|
||||
|
||||
QMap<int, QPoint> XMLConfiguration::layout() const
|
||||
{
|
||||
return m_layout;
|
||||
}
|
||||
|
||||
} // namespace Kephal
|
||||
// vim: sw=4 sts=4 et tw=100
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XML_CONFIGURATION_H
|
||||
#define XML_CONFIGURATION_H
|
||||
|
||||
#include "backendconfigurations.h"
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class XMLConfigurations;
|
||||
class ConfigurationsXML;
|
||||
class ConfigurationXML;
|
||||
|
||||
class XMLConfiguration : public BackendConfiguration {
|
||||
Q_OBJECT
|
||||
public:
|
||||
XMLConfiguration(XMLConfigurations * parent, ConfigurationXML * configuration);
|
||||
|
||||
QString name() const;
|
||||
bool isModifiable() const;
|
||||
bool isActivated() const;
|
||||
void activate();
|
||||
QMap<int, QPoint> layout() const;
|
||||
int primaryScreen() const;
|
||||
|
||||
ConfigurationXML * configuration() const;
|
||||
void setLayout(const QMap<int, QPoint> & layout);
|
||||
|
||||
Q_SIGNALS:
|
||||
void configurationActivated(XMLConfiguration * configuration);
|
||||
|
||||
private:
|
||||
ConfigurationXML * m_configuration;
|
||||
XMLConfigurations * m_parent;
|
||||
QMap<int, QPoint> m_layout;
|
||||
};
|
||||
}
|
||||
#endif // XMLCONFIGURATION_H
|
File diff suppressed because it is too large
Load diff
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_XMLCONFIGURATIONS_H
|
||||
#define KEPHAL_XMLCONFIGURATIONS_H
|
||||
|
||||
#include "configurations.h"
|
||||
|
||||
#include "backendconfigurations.h"
|
||||
#include "externalconfiguration.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class XMLConfigurations;
|
||||
class ConfigurationsXML;
|
||||
class ConfigurationXML;
|
||||
class OutputsXML;
|
||||
class OutputXML;
|
||||
|
||||
class XMLConfiguration;
|
||||
|
||||
class XMLConfigurations : public BackendConfigurations {
|
||||
Q_OBJECT
|
||||
public:
|
||||
XMLConfigurations(QObject * parent);
|
||||
|
||||
QMap<QString, Configuration *> configurations();
|
||||
/**
|
||||
* Calculates the most appropriate configuration for the current hardware configuration
|
||||
* This Configuration can then be activate()d to set up the screens as configured
|
||||
* Changes state so can't be const
|
||||
*/
|
||||
Configuration * findConfiguration();
|
||||
Configuration * activeConfiguration();
|
||||
QList<Configuration *> alternateConfigurations();
|
||||
QList<QPoint> possiblePositions(Output * output);
|
||||
|
||||
//X bool move(Output * output, const QPoint & position);
|
||||
//X bool resize(Output * output, const QSize & size);
|
||||
//X bool rotate(Output * output, Rotation rotation);
|
||||
//X bool changeRate(Output * output, float rate);
|
||||
//X bool reflectX(Output * output, bool reflect);
|
||||
//X bool reflectY(Output * output, bool reflect);
|
||||
|
||||
int screen(Output * output);
|
||||
void applyOutputSettings();
|
||||
void setPolling(bool polling);
|
||||
bool polling() const;
|
||||
void confirm();
|
||||
void revert();
|
||||
|
||||
private Q_SLOTS:
|
||||
void confirmTimerTimeout();
|
||||
bool activate(XMLConfiguration * configuration);
|
||||
void activateExternal();
|
||||
|
||||
private:
|
||||
void init();
|
||||
/** populates m_currentOutputs using first findKnownOutputs then falls back to
|
||||
* findBestOutputs
|
||||
*/
|
||||
void findOutputs();
|
||||
/**
|
||||
* looks for an exact match between configured sets of outputs and the current sets of
|
||||
* outputs.
|
||||
*/
|
||||
OutputsXML * findKnownOutputs();
|
||||
/**
|
||||
* looks for the closest match out of configured outputs and current outputs, using a
|
||||
* scoring mechanism
|
||||
* The default hardcoded outputs should be sufficiently broad to always assure
|
||||
* some match.
|
||||
*/
|
||||
OutputsXML * findBestOutputs();
|
||||
qreal match(QString known, QString current);
|
||||
qreal match(int known, int current);
|
||||
QMap<int, int> matchLayouts(const QMap<int, QPoint> & currentLayout, const QMap<int, QPoint> & layout) const;
|
||||
QMap<int, QRect> calcMatchingLayout(const QMap<int, QPoint> & currentLayout, XMLConfiguration * configuration, QMap<int, QPoint> layout, Output * output = 0, int * outputScreen = 0);
|
||||
void translateToOther(QMap<int, QRect> & layout, Output * base, QMap<int, int> match = (QMap<int, int>()));
|
||||
QList<XMLConfiguration *> equivalentConfigurations(int numScreens);
|
||||
QMap<XMLConfiguration *, QPoint> equivalentConfigurationsPositions(Output * output);
|
||||
QMap<XMLConfiguration *, QPoint> simpleConfigurationsPositions(Output * output, bool sameCount);
|
||||
QMap<XMLConfiguration *, QPoint> sameConfigurationsPositions(Output * output, bool sameCount);
|
||||
QMap<XMLConfiguration *, QMap<int, QPoint> > matchingConfigurationsLayouts(const QMap<int, QPoint> & currentLayout, int removedOutputs);
|
||||
XMLConfiguration * simpleConfiguration(int numScreens);
|
||||
void saveXml();
|
||||
void loadXml();
|
||||
/**
|
||||
* Start the layout activation process.
|
||||
*
|
||||
* @param layout absolute layout geometries
|
||||
* @param outputScreens current output->screen id mapping
|
||||
*/
|
||||
bool activateLayout(const QMap<int, QRect> & layout, const QMap<Output *, int> & outputScreens);
|
||||
/**
|
||||
* Second stage of activation applying the outputs' current sizes to stored
|
||||
* configuration
|
||||
*
|
||||
* @param layout absolute layout geometries
|
||||
* @param outputScreens current output->screen id mapping
|
||||
* @param outputSizes current outputs' sizes
|
||||
*/
|
||||
bool activateLayout(const QMap<int, QRect> & layout, const QMap<Output *, int> & outputScreens, const QMap<Output *, QSize> & outputSizes);
|
||||
/**
|
||||
* Obtain the current mapping from Outputs to Screens
|
||||
*/
|
||||
QMap<Output *, int> currentOutputScreens();
|
||||
void matchOutputScreens(const QMap<int, QPoint> & layout);
|
||||
OutputXML * outputXml(const QString & id);
|
||||
/**
|
||||
* Helper method for resize and rotate dbus api methods;
|
||||
* adapts the layout when an output is resized or rotated.
|
||||
*/
|
||||
QMap<int, QRect> resizeLayout(Output * output, const QSize & size, QMap<Output *, int> & outputScreens, QMap<Output *, QSize> & outputSizes);
|
||||
|
||||
void requireConfirm();
|
||||
|
||||
QMap<QString, XMLConfiguration *> m_configurations;
|
||||
XMLConfiguration * m_activeConfiguration;
|
||||
XMLConfiguration * m_markedConfiguration;
|
||||
ExternalConfiguration * m_externalConfiguration;
|
||||
ConfigurationsXML * m_configXml;
|
||||
QString m_configPath;
|
||||
OutputsXML * m_currentOutputs;
|
||||
bool m_currentOutputsKnown;
|
||||
QTimer * m_confirmTimer;
|
||||
int m_confirmLeft;
|
||||
bool m_awaitingConfirm;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_XMLCONFIGURATIONS_H
|
|
@ -1,2 +0,0 @@
|
|||
These are the classes providing the actual XRandR 1.2 support.
|
||||
They have been taken from krandr and were only slightly modified.
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
* Copyright (c) 2002,2003 Hamish Rodda <rodda@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.
|
||||
*/
|
||||
|
||||
#include "randr.h"
|
||||
|
||||
Time RandR::timestamp = 0;
|
||||
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007,2008 Harry Bock <hbock@providence.edu>
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
* Copyright (c) 2002,2003 Hamish Rodda <rodda@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.
|
||||
*/
|
||||
|
||||
#ifndef __RANDR_H__
|
||||
#define __RANDR_H__
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QSize>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <X11/Xlib.h>
|
||||
#define INT8 _X11INT8
|
||||
#define INT32 _X11INT32
|
||||
#include <X11/Xproto.h>
|
||||
#undef INT8
|
||||
#undef INT32
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <fixx11h.h>
|
||||
}
|
||||
|
||||
class RandRScreen;
|
||||
class RandRCrtc;
|
||||
class RandROutput;
|
||||
class RandRMode;
|
||||
|
||||
// maps
|
||||
typedef QMap<RRCrtc,RandRCrtc*> CrtcMap;
|
||||
typedef QMap<RROutput,RandROutput*> OutputMap;
|
||||
typedef QMap<RRMode,RandRMode> ModeMap;
|
||||
|
||||
//lists
|
||||
typedef QList<RandRScreen*> ScreenList;
|
||||
typedef QList<RROutput> OutputList;
|
||||
typedef QList<RRCrtc> CrtcList;
|
||||
typedef QList<RRMode> ModeList;
|
||||
|
||||
typedef QList<float> RateList;
|
||||
typedef QList<QSize> SizeList;
|
||||
|
||||
//class LegacyRandRScreen;
|
||||
//typedef QList<LegacyRandRScreen*> LegacyScreenList;
|
||||
|
||||
class RandR
|
||||
{
|
||||
public:
|
||||
//static bool has_1_2;
|
||||
static Time timestamp;
|
||||
|
||||
static const int OrientationCount = 6;
|
||||
static const int RotationCount = 4;
|
||||
|
||||
enum Orientations {
|
||||
Rotate0 = RR_Rotate_0,
|
||||
Rotate90 = RR_Rotate_90,
|
||||
Rotate180 = RR_Rotate_180,
|
||||
Rotate270 = RR_Rotate_270,
|
||||
RotateMask = (RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270),
|
||||
ReflectX = RR_Reflect_X,
|
||||
ReflectY = RR_Reflect_Y,
|
||||
ReflectMask = (RR_Reflect_X | RR_Reflect_Y),
|
||||
OrientationMask = (RotateMask | ReflectMask)
|
||||
};
|
||||
|
||||
enum Changes {
|
||||
ChangeCrtc = 0x01,
|
||||
ChangeOutputs = 0x02,
|
||||
ChangeMode = 0x04,
|
||||
ChangeRotation = 0x08,
|
||||
ChangeConnection = 0x10,
|
||||
ChangeRect = 0x20,
|
||||
ChangeRate = 0x40
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,476 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "randrcrtc.h"
|
||||
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
#include <KDebug>
|
||||
|
||||
#include "randrscreen.h"
|
||||
#include "randroutput.h"
|
||||
#include "randrmode.h"
|
||||
|
||||
RandRCrtc::RandRCrtc(RandRScreen *parent, RRCrtc id)
|
||||
: QObject(parent),
|
||||
m_currentRect(0, 0, 0, 0),
|
||||
m_originalRect(m_currentRect),
|
||||
m_proposedRect(m_originalRect)
|
||||
{
|
||||
m_screen = parent;
|
||||
Q_ASSERT(m_screen);
|
||||
|
||||
m_currentRotation = m_originalRotation = m_proposedRotation = RandR::Rotate0;
|
||||
m_currentRate = m_originalRate = m_proposedRate = 0;
|
||||
m_currentMode = 0;
|
||||
m_rotations = RandR::Rotate0;
|
||||
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
RandRCrtc::~RandRCrtc()
|
||||
{
|
||||
// do nothing for now
|
||||
}
|
||||
|
||||
RRCrtc RandRCrtc::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
int RandRCrtc::rotations() const
|
||||
{
|
||||
return m_rotations;
|
||||
}
|
||||
|
||||
int RandRCrtc::rotation() const
|
||||
{
|
||||
return m_currentRotation;
|
||||
}
|
||||
|
||||
bool RandRCrtc::isValid(void) const
|
||||
{
|
||||
return m_id != None;
|
||||
}
|
||||
|
||||
void RandRCrtc::loadSettings(bool notify)
|
||||
{
|
||||
if(m_id == None)
|
||||
return;
|
||||
|
||||
int changes = 0;
|
||||
XRRCrtcInfo *info = XRRGetCrtcInfo(QX11Info::display(), m_screen->resources(), m_id);
|
||||
Q_ASSERT(info);
|
||||
|
||||
if (RandR::timestamp != info->timestamp)
|
||||
RandR::timestamp = info->timestamp;
|
||||
|
||||
QRect rect = QRect(info->x, info->y, info->width, info->height);
|
||||
if (rect != m_currentRect)
|
||||
{
|
||||
m_currentRect = rect;
|
||||
changes |= RandR::ChangeRect;
|
||||
}
|
||||
|
||||
// get all connected outputs
|
||||
// and create a list of modes that are available in all connected outputs
|
||||
OutputList outputs;
|
||||
|
||||
for (int i = 0; i < info->noutput; ++i)
|
||||
outputs.append(info->outputs[i]);
|
||||
|
||||
// check if the list changed from the original one
|
||||
if (outputs != m_connectedOutputs)
|
||||
{
|
||||
changes |= RandR::ChangeOutputs;
|
||||
m_connectedOutputs = outputs;
|
||||
}
|
||||
|
||||
// get all outputs this crtc can be connected to
|
||||
outputs.clear();
|
||||
for (int i = 0; i < info->npossible; ++i)
|
||||
outputs.append(info->possible[i]);
|
||||
|
||||
if (outputs != m_possibleOutputs)
|
||||
{
|
||||
changes |= RandR::ChangeOutputs;
|
||||
m_possibleOutputs = outputs;
|
||||
}
|
||||
//kDebug() << "loaded possible outputs:" << m_id << m_possibleOutputs;
|
||||
|
||||
// get all rotations
|
||||
m_rotations = info->rotations;
|
||||
if (m_currentRotation != info->rotation)
|
||||
{
|
||||
m_currentRotation = info->rotation;
|
||||
changes |= RandR::ChangeRotation;
|
||||
}
|
||||
|
||||
// check if the current mode has changed
|
||||
if (m_currentMode != info->mode)
|
||||
{
|
||||
m_currentMode = info->mode;
|
||||
changes |= RandR::ChangeMode;
|
||||
}
|
||||
|
||||
RandRMode m = m_screen->mode(m_currentMode);
|
||||
if (m_currentRate != m.refreshRate())
|
||||
{
|
||||
m_currentRate = m.refreshRate();
|
||||
changes |= RandR::ChangeRate;
|
||||
}
|
||||
|
||||
// just to make sure it gets initialized
|
||||
m_proposedRect = m_currentRect;
|
||||
m_proposedRotation = m_currentRotation;
|
||||
m_proposedRate = m_currentRate;
|
||||
|
||||
// free the info
|
||||
XRRFreeCrtcInfo(info);
|
||||
|
||||
if (changes && notify)
|
||||
emit crtcChanged(m_id, changes);
|
||||
}
|
||||
|
||||
void RandRCrtc::handleEvent(XRRCrtcChangeNotifyEvent *event)
|
||||
{
|
||||
kDebug() << "[CRTC" << m_id << "] Event...";
|
||||
kDebug() << " mode: " << event->mode << "(current " << m_currentMode << ")";
|
||||
kDebug() << " pos: (" << event->x << "," << event->y << ")";
|
||||
kDebug() << " size: " << event->width << "x" << event->height;
|
||||
kDebug() << " rotation: " << event->rotation;
|
||||
|
||||
int changed = 0;
|
||||
|
||||
if (event->mode != m_currentMode)
|
||||
{
|
||||
kDebug() << " Changed mode - old " << m_currentMode << " - new " << event->mode;
|
||||
changed |= RandR::ChangeMode;
|
||||
m_currentMode = event->mode;
|
||||
}
|
||||
|
||||
if (event->rotation != m_currentRotation)
|
||||
{
|
||||
kDebug() << " Changed rotation: " << event->rotation;
|
||||
changed |= RandR::ChangeRotation;
|
||||
m_currentRotation = event->rotation;
|
||||
}
|
||||
if (event->x != m_currentRect.x() || event->y != m_currentRect.y())
|
||||
{
|
||||
kDebug() << " Changed position: " << event->x << "," << event->y;
|
||||
changed |= RandR::ChangeRect;
|
||||
m_currentRect.moveTopLeft(QPoint(event->x, event->y));
|
||||
}
|
||||
|
||||
RandRMode mode = m_screen->mode(m_currentMode);
|
||||
QSize newSize = mode.size();
|
||||
|
||||
if (m_currentRotation == RandR::Rotate90 || m_currentRotation == RandR::Rotate270)
|
||||
{
|
||||
// in rotated modes leaving the screen on its "side" exchange width<->height
|
||||
newSize = QSize(newSize.height(), newSize.width());
|
||||
}
|
||||
|
||||
if (newSize != m_currentRect.size())
|
||||
{
|
||||
kDebug() << " Changed size: " << newSize;
|
||||
changed |= RandR::ChangeRect;
|
||||
m_currentRect.setSize(newSize);
|
||||
//Do NOT use event->width and event->height here, as it is being returned wrongly
|
||||
}
|
||||
|
||||
if (changed)
|
||||
emit crtcChanged(m_id, changed);
|
||||
}
|
||||
|
||||
RandRMode RandRCrtc::mode() const
|
||||
{
|
||||
return m_screen->mode(m_currentMode);
|
||||
}
|
||||
|
||||
QRect RandRCrtc::rect() const
|
||||
{
|
||||
return m_currentRect;
|
||||
}
|
||||
|
||||
float RandRCrtc::refreshRate() const
|
||||
{
|
||||
return m_currentRate;
|
||||
}
|
||||
|
||||
bool RandRCrtc::applyProposed()
|
||||
{
|
||||
kDebug() << "[CRTC] Going to apply (" << m_id << ") ....";
|
||||
kDebug() << " Current Screen rect: " << m_screen->rect();
|
||||
kDebug() << " Current CRTC Rect: " << m_currentRect;
|
||||
kDebug() << " Current Rotation: " << m_currentRotation;
|
||||
kDebug() << " Proposed rect: " << m_proposedRect;
|
||||
kDebug() << " Proposed rotation: " << m_proposedRotation;
|
||||
kDebug() << " Proposed refresh rate: " << m_proposedRate;
|
||||
kDebug() << " Outputs: ";
|
||||
for (int i = 0; i < m_connectedOutputs.count(); ++i)
|
||||
kDebug() << " - " << m_screen->output(m_connectedOutputs.at(i))->name();
|
||||
|
||||
RandRMode mode;
|
||||
if (m_proposedRect.size() == m_currentRect.size() && m_proposedRate == m_currentRate)
|
||||
{
|
||||
mode = m_screen->mode(m_currentMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find a mode that has the desired size and is supported
|
||||
// by all connected outputs
|
||||
ModeList modeList = modes();
|
||||
ModeList matchModes;
|
||||
|
||||
foreach(const RRMode & m, modeList)
|
||||
{
|
||||
RandRMode mode = m_screen->mode(m);
|
||||
if (mode.size() == m_proposedRect.size())
|
||||
matchModes.append(m);
|
||||
}
|
||||
|
||||
// if no matching modes were found, disable output
|
||||
// else set the mode to the first mode in the list. If no refresh rate was given
|
||||
// or no mode was found matching the given refresh rate, the first mode of the
|
||||
// list will be used
|
||||
if (!matchModes.count())
|
||||
mode = RandRMode();
|
||||
else
|
||||
mode = m_screen->mode(matchModes.first());
|
||||
|
||||
foreach(const RRMode & m, matchModes)
|
||||
{
|
||||
RandRMode testMode = m_screen->mode(m);
|
||||
if (testMode.refreshRate() == m_proposedRate)
|
||||
{
|
||||
mode = testMode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no output was connected, set the mode to None
|
||||
if (!m_connectedOutputs.count())
|
||||
mode = RandRMode();
|
||||
else if (!mode.isValid())
|
||||
return false;
|
||||
|
||||
RROutput *outputs = new RROutput[m_connectedOutputs.count()];
|
||||
for (int i = 0; i < m_connectedOutputs.count(); ++i)
|
||||
outputs[i] = m_connectedOutputs.at(i);
|
||||
|
||||
if (mode.isValid())
|
||||
{
|
||||
int currentRotation = m_currentRotation & RandR::RotateMask;
|
||||
int proposedRotation = m_proposedRotation & RandR::RotateMask;
|
||||
if (currentRotation == proposedRotation ||
|
||||
(currentRotation == RandR::Rotate0 && proposedRotation == RandR::Rotate180) ||
|
||||
(currentRotation == RandR::Rotate180 && proposedRotation == RandR::Rotate0) ||
|
||||
(currentRotation == RandR::Rotate90 && proposedRotation == RandR::Rotate270) ||
|
||||
(currentRotation == RandR::Rotate270 && proposedRotation == RandR::Rotate90))
|
||||
{
|
||||
QRect r = QRect(0,0,0,0).united(m_proposedRect);
|
||||
if (r.width() > m_screen->maxSize().width() || r.height() > m_screen->maxSize().height())
|
||||
{
|
||||
delete[] outputs;
|
||||
return false;
|
||||
}
|
||||
|
||||
// if the desired mode is bigger than the current screen size, first change the
|
||||
// screen size, and then the crtc size
|
||||
if (!m_screen->rect().contains(r))
|
||||
{
|
||||
// try to adjust the screen size
|
||||
if (!m_screen->adjustSize(r))
|
||||
{
|
||||
delete[] outputs;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
QRect r(m_proposedRect.topLeft(), QSize(m_proposedRect.height(), m_proposedRect.width()));
|
||||
if (!m_screen->rect().contains(r))
|
||||
{
|
||||
// check if the rotated rect is smaller than the max screen size
|
||||
r = m_screen->rect().united(r);
|
||||
if (r.width() > m_screen->maxSize().width() || r.height() > m_screen->maxSize().height())
|
||||
{
|
||||
delete[] outputs;
|
||||
return false;
|
||||
}
|
||||
|
||||
// adjust the screen size
|
||||
r = r.united(m_currentRect);
|
||||
if (!m_screen->adjustSize(r))
|
||||
{
|
||||
delete[] outputs;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
kDebug() << "calling XRRSetCrtcConfig()";
|
||||
Status s = XRRSetCrtcConfig(QX11Info::display(), m_screen->resources(), m_id,
|
||||
RandR::timestamp, m_proposedRect.x(), m_proposedRect.y(), mode.id(),
|
||||
m_proposedRotation, outputs, m_connectedOutputs.count());
|
||||
|
||||
delete[] outputs;
|
||||
|
||||
bool ret;
|
||||
if (s == RRSetConfigSuccess)
|
||||
{
|
||||
m_currentMode = mode.id();
|
||||
m_currentRotation = m_proposedRotation;
|
||||
m_currentRect = m_proposedRect;
|
||||
m_currentRate = mode.refreshRate();
|
||||
emit crtcChanged(m_id, RandR::ChangeMode);
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = false;
|
||||
// Invalidate the XRRScreenResources cache
|
||||
if(s == RRSetConfigInvalidConfigTime)
|
||||
m_screen->loadSettings(true);
|
||||
}
|
||||
|
||||
m_screen->adjustSize();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool RandRCrtc::proposeSize(const QSize &s)
|
||||
{
|
||||
m_proposedRect.setSize(s);
|
||||
m_proposedRate = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RandRCrtc::proposePosition(const QPoint &p)
|
||||
{
|
||||
m_proposedRect.moveTopLeft(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RandRCrtc::proposeRotation(int rotation)
|
||||
{
|
||||
// check if this crtc supports the asked rotation
|
||||
if (!(rotation & m_rotations))
|
||||
return false;
|
||||
|
||||
m_proposedRotation = rotation;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool RandRCrtc::proposeRefreshRate(float rate)
|
||||
{
|
||||
m_proposedRate = rate;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RandRCrtc::proposeOriginal()
|
||||
{
|
||||
m_proposedRotation = m_originalRotation;
|
||||
m_proposedRect = m_originalRect;
|
||||
m_proposedRate = m_originalRate;
|
||||
}
|
||||
|
||||
void RandRCrtc::setOriginal()
|
||||
{
|
||||
m_originalRotation = m_currentRotation;
|
||||
m_originalRect = m_currentRect;
|
||||
m_originalRate = m_currentRate;
|
||||
}
|
||||
|
||||
bool RandRCrtc::proposedChanged()
|
||||
{
|
||||
return (m_proposedRotation != m_currentRotation ||
|
||||
m_proposedRect != m_currentRect ||
|
||||
m_proposedRate != m_currentRate);
|
||||
}
|
||||
|
||||
bool RandRCrtc::addOutput(RROutput output, const QSize &s)
|
||||
{
|
||||
QSize size = s;
|
||||
// if no mode was given, use the current one
|
||||
if (!size.isValid())
|
||||
size = m_currentRect.size();
|
||||
|
||||
// check if this output is not already on this crtc
|
||||
// if not, add it
|
||||
if (m_connectedOutputs.indexOf(output) == -1)
|
||||
{
|
||||
kDebug() << "possible:" << m_possibleOutputs;
|
||||
// the given output is not possible
|
||||
if (m_possibleOutputs.indexOf(output) == -1)
|
||||
return false;
|
||||
|
||||
m_connectedOutputs.append(output);
|
||||
}
|
||||
m_proposedRect = QRect(m_proposedRect.topLeft(), s);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RandRCrtc::removeOutput(RROutput output)
|
||||
{
|
||||
int index = m_connectedOutputs.indexOf(output);
|
||||
if (index == -1)
|
||||
return false;
|
||||
|
||||
m_connectedOutputs.removeAt(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
OutputList RandRCrtc::connectedOutputs() const
|
||||
{
|
||||
return m_connectedOutputs;
|
||||
}
|
||||
|
||||
ModeList RandRCrtc::modes() const
|
||||
{
|
||||
ModeList modeList;
|
||||
|
||||
bool first = true;
|
||||
|
||||
foreach(const RROutput & o, m_connectedOutputs)
|
||||
{
|
||||
RandROutput *output = m_screen->output(o);
|
||||
if (first)
|
||||
{
|
||||
modeList = output->modes();
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(const RRMode & m, modeList)
|
||||
{
|
||||
if (output->modes().indexOf(m) == -1)
|
||||
modeList.removeAll(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modeList;
|
||||
}
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __RANDRCRTC_H__
|
||||
#define __RANDRCRTC_H__
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "randr.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
|
||||
/** Class representing a CRT controller. */
|
||||
class RandRCrtc : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RandRCrtc(RandRScreen *parent, RRCrtc id);
|
||||
~RandRCrtc();
|
||||
|
||||
RRCrtc id() const;
|
||||
int rotations() const;
|
||||
int rotation() const;
|
||||
|
||||
void loadSettings(bool notify = false);
|
||||
void handleEvent(XRRCrtcChangeNotifyEvent *event);
|
||||
|
||||
bool isValid(void) const;
|
||||
RandRMode mode() const;
|
||||
QRect rect() const;
|
||||
float refreshRate() const;
|
||||
|
||||
bool proposeSize(const QSize &s);
|
||||
bool proposePosition(const QPoint &p);
|
||||
bool proposeRotation(int rotation);
|
||||
bool proposeRefreshRate(float rate);
|
||||
|
||||
// applying stuff
|
||||
bool applyProposed();
|
||||
void proposeOriginal();
|
||||
void setOriginal();
|
||||
bool proposedChanged();
|
||||
|
||||
bool addOutput(RROutput output, const QSize &size = QSize());
|
||||
bool removeOutput(RROutput output);
|
||||
OutputList connectedOutputs() const;
|
||||
|
||||
ModeList modes() const;
|
||||
|
||||
signals:
|
||||
void crtcChanged(RRCrtc c, int changes);
|
||||
|
||||
private:
|
||||
RRCrtc m_id;
|
||||
RRMode m_currentMode;
|
||||
|
||||
QRect m_currentRect;
|
||||
float m_currentRate;
|
||||
int m_currentRotation;
|
||||
|
||||
|
||||
QRect m_originalRect;
|
||||
float m_originalRate;
|
||||
int m_originalRotation;
|
||||
|
||||
QRect m_proposedRect;
|
||||
float m_proposedRate;
|
||||
int m_proposedRotation;
|
||||
|
||||
OutputList m_connectedOutputs;
|
||||
OutputList m_possibleOutputs;
|
||||
int m_rotations;
|
||||
|
||||
RandRScreen *m_screen;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2008 Harry Bock <hbock@providence.edu>
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
* Copyright (c) 2002,2003 Hamish Rodda <rodda@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.
|
||||
*/
|
||||
|
||||
#include <KDebug>
|
||||
#include <QWidget>
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
||||
#include "randrdisplay.h"
|
||||
#include "randrscreen.h"
|
||||
|
||||
|
||||
RandRDisplay::RandRDisplay()
|
||||
: m_valid(true)
|
||||
{
|
||||
m_dpy = QX11Info::display();
|
||||
|
||||
// Check extension
|
||||
if(XRRQueryExtension(m_dpy, &m_eventBase, &m_errorBase) == False) {
|
||||
m_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int major_version, minor_version;
|
||||
XRRQueryVersion(m_dpy, &major_version, &minor_version);
|
||||
|
||||
// check if we have the new version of the XRandR extension
|
||||
m_valid = (major_version > 1 || (major_version == 1 && minor_version >= 2));
|
||||
if (! m_valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
kDebug() << "XRANDR error code base: " << m_errorBase;
|
||||
m_numScreens = ScreenCount(m_dpy);
|
||||
m_currentScreenIndex = 0;
|
||||
|
||||
// set the timestamp to 0
|
||||
RandR::timestamp = 0;
|
||||
|
||||
// This assumption is WRONG with Xinerama
|
||||
// Q_ASSERT(QApplication::desktop()->numScreens() == ScreenCount(QX11Info::display()));
|
||||
for (int i = 0; i < m_numScreens; i++) {
|
||||
m_screens.append(new RandRScreen(i));
|
||||
}
|
||||
|
||||
setCurrentScreen(DefaultScreen(QX11Info::display()));
|
||||
}
|
||||
|
||||
RandRDisplay::~RandRDisplay()
|
||||
{
|
||||
qDeleteAll(m_screens);
|
||||
}
|
||||
|
||||
bool RandRDisplay::isValid() const
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
const QString& RandRDisplay::errorCode() const
|
||||
{
|
||||
return m_errorCode;
|
||||
}
|
||||
|
||||
int RandRDisplay::eventBase() const
|
||||
{
|
||||
return m_eventBase;
|
||||
}
|
||||
|
||||
int RandRDisplay::errorBase() const
|
||||
{
|
||||
return m_errorBase;
|
||||
}
|
||||
|
||||
const QString& RandRDisplay::version() const
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
|
||||
void RandRDisplay::setCurrentScreen(int index)
|
||||
{
|
||||
Q_ASSERT(index < ScreenCount(m_dpy));
|
||||
m_currentScreenIndex = index;
|
||||
}
|
||||
|
||||
int RandRDisplay::screenIndexOfWidget(QWidget* widget)
|
||||
{
|
||||
// get info from Qt's X11 info directly; QDesktopWidget seems to use
|
||||
// Xinerama by default, which doesn't work properly with randr.
|
||||
// It will return more screens than exist for the display, causing
|
||||
// a crash in the screen/currentScreen methods.
|
||||
if(widget)
|
||||
return widget->x11Info().screen();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int RandRDisplay::currentScreenIndex() const
|
||||
{
|
||||
return m_currentScreenIndex;
|
||||
}
|
||||
|
||||
bool RandRDisplay::needsRefresh() const
|
||||
{
|
||||
Time time, config_timestamp;
|
||||
time = XRRTimes(m_dpy, m_currentScreenIndex, &config_timestamp);
|
||||
|
||||
kDebug() << "Cache:" << RandR::timestamp << "Server:" << time << "Config:" << config_timestamp;
|
||||
return (RandR::timestamp < time);
|
||||
}
|
||||
|
||||
void RandRDisplay::refresh()
|
||||
{
|
||||
foreach (RandRScreen* s, m_screens) {
|
||||
s->loadSettings();
|
||||
}
|
||||
}
|
||||
|
||||
bool RandRDisplay::canHandle(const XEvent *e) const
|
||||
{
|
||||
if (e->type == m_eventBase + RRScreenChangeNotify)
|
||||
return true;
|
||||
else if (e->type == m_eventBase + RRNotify)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void RandRDisplay::handleEvent(XEvent *e)
|
||||
{
|
||||
if (e->type == m_eventBase + RRScreenChangeNotify) {
|
||||
XRRScreenChangeNotifyEvent *event = (XRRScreenChangeNotifyEvent*)(e);
|
||||
kDebug() << "RRScreenChangeNotify window: " << event->window << " root: " << event->root;
|
||||
for (int i=0; i < m_screens.count(); ++i) {
|
||||
RandRScreen *screen = m_screens.at(i);
|
||||
if (screen->rootWindow() == event->root)
|
||||
screen->handleEvent(event);
|
||||
}
|
||||
}
|
||||
else if (e->type == m_eventBase + RRNotify) {
|
||||
//forward the event to the right screen
|
||||
XRRNotifyEvent *event = (XRRNotifyEvent*)e;
|
||||
kDebug() << "RRNotify window: " << event->window;
|
||||
for (int i=0; i < m_screens.count(); ++i) {
|
||||
RandRScreen *screen = m_screens.at(i);
|
||||
// TODO: removed the window check because randr seems to pass an incorrect window
|
||||
// if ( screen->rootWindow() == event->window ) {
|
||||
screen->handleRandREvent(event);
|
||||
// }
|
||||
}
|
||||
}
|
||||
else {
|
||||
kDebug() << "RandRDisplay::handleEvent - Other";
|
||||
}
|
||||
}
|
||||
|
||||
int RandRDisplay::numScreens() const
|
||||
{
|
||||
Q_ASSERT(ScreenCount(QX11Info::display()) == m_numScreens);
|
||||
return m_numScreens;
|
||||
}
|
||||
|
||||
RandRScreen* RandRDisplay::screen(int index)
|
||||
{
|
||||
return m_screens.at(index);
|
||||
}
|
||||
|
||||
RandRScreen* RandRDisplay::currentScreen()
|
||||
{
|
||||
return m_screens.at(m_currentScreenIndex);
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
* Copyright (c) 2002,2003 Hamish Rodda <rodda@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.
|
||||
*/
|
||||
|
||||
#ifndef __RANDRDISPLAY_H__
|
||||
#define __RANDRDISPLAY_H__
|
||||
|
||||
#include "randr.h"
|
||||
|
||||
//#include <X11/Xlib.h>
|
||||
|
||||
/**
|
||||
* Just wraps the X Display and provides access to RandRScreens
|
||||
*/
|
||||
class RandRDisplay
|
||||
{
|
||||
public:
|
||||
RandRDisplay();
|
||||
~RandRDisplay();
|
||||
|
||||
bool isValid() const;
|
||||
const QString& errorCode() const;
|
||||
const QString& version() const;
|
||||
|
||||
/**
|
||||
* Event and error code base offsets
|
||||
*/
|
||||
int eventBase() const;
|
||||
int errorBase() const;
|
||||
|
||||
int screenIndexOfWidget(QWidget* widget);
|
||||
|
||||
int numScreens() const;
|
||||
RandRScreen* screen(int index);
|
||||
RandRScreen* currentScreen();
|
||||
|
||||
void setCurrentScreen(int index);
|
||||
int currentScreenIndex() const;
|
||||
|
||||
bool needsRefresh() const;
|
||||
void refresh();
|
||||
|
||||
void applyProposed(bool confirm = true);
|
||||
|
||||
bool canHandle(const XEvent *e) const;
|
||||
void handleEvent(XEvent *e);
|
||||
|
||||
private:
|
||||
Display *m_dpy;
|
||||
int m_numScreens;
|
||||
int m_currentScreenIndex;
|
||||
|
||||
ScreenList m_screens;
|
||||
|
||||
bool m_valid;
|
||||
QString m_errorCode;
|
||||
QString m_version;
|
||||
|
||||
int m_eventBase;
|
||||
int m_errorBase;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "randrmode.h"
|
||||
|
||||
|
||||
RandRMode::RandRMode(XRRModeInfo *info)
|
||||
: m_size(0, 0)
|
||||
{
|
||||
m_valid = false;
|
||||
|
||||
if (info)
|
||||
m_valid = true;
|
||||
else
|
||||
return;
|
||||
|
||||
m_rate = 0;
|
||||
m_id = 0;
|
||||
m_name = "Invalid mode";
|
||||
|
||||
|
||||
|
||||
m_name = info->name;
|
||||
m_id = info->id;
|
||||
|
||||
m_size.setWidth(info->width);
|
||||
m_size.setHeight(info->height);
|
||||
|
||||
// calculate the refresh rate
|
||||
if (info->hTotal && info->vTotal)
|
||||
m_rate = ((float) info->dotClock / ((float) info->hTotal * (float) info->vTotal));
|
||||
else
|
||||
m_rate = 0;
|
||||
|
||||
}
|
||||
|
||||
RandRMode::~RandRMode()
|
||||
{
|
||||
// nothing to do for now
|
||||
}
|
||||
|
||||
RRMode RandRMode::id() const
|
||||
{
|
||||
if (!m_valid)
|
||||
return None;
|
||||
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QString RandRMode::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QSize RandRMode::size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
float RandRMode::refreshRate() const
|
||||
{
|
||||
return m_rate;
|
||||
}
|
||||
|
||||
bool RandRMode::isValid() const
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __RANDRMODE_H__
|
||||
#define __RANDRMODE_H__
|
||||
|
||||
#include "randr.h"
|
||||
|
||||
|
||||
class RandRMode
|
||||
{
|
||||
public:
|
||||
RandRMode(XRRModeInfo *info = 0);
|
||||
~RandRMode();
|
||||
|
||||
RRMode id() const;
|
||||
QString name() const;
|
||||
bool isValid() const;
|
||||
QSize size() const;
|
||||
float refreshRate() const;
|
||||
private:
|
||||
bool m_valid;
|
||||
QString m_name;
|
||||
QSize m_size;
|
||||
float m_rate;
|
||||
RRMode m_id;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,474 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
* Copyright (c) 2007, 2008 Harry Bock <hbock@providence.edu>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "randroutput.h"
|
||||
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
#include <KDebug>
|
||||
|
||||
#include "randrscreen.h"
|
||||
#include "randrcrtc.h"
|
||||
#include "randrmode.h"
|
||||
|
||||
|
||||
|
||||
RandROutput::RandROutput(RandRScreen *parent, RROutput id)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_screen = parent;
|
||||
Q_ASSERT(m_screen);
|
||||
|
||||
m_id = id;
|
||||
m_crtc = 0;
|
||||
m_rotations = 0;
|
||||
m_connected = false;
|
||||
|
||||
queryOutputInfo();
|
||||
|
||||
m_proposedRotation = m_originalRotation;
|
||||
m_proposedRate = m_originalRate;
|
||||
m_proposedRect = m_originalRect;
|
||||
}
|
||||
|
||||
RandROutput::~RandROutput()
|
||||
{
|
||||
}
|
||||
|
||||
RROutput RandROutput::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
RandRScreen *RandROutput::screen() const
|
||||
{
|
||||
return m_screen;
|
||||
}
|
||||
|
||||
bool RandROutput::queryOutputInfo(void)
|
||||
{
|
||||
XRROutputInfo *info = XRRGetOutputInfo(QX11Info::display(), m_screen->resources(), m_id);
|
||||
Q_ASSERT(info);
|
||||
|
||||
bool changes = false;
|
||||
if (RandR::timestamp != info->timestamp) {
|
||||
RandR::timestamp = info->timestamp;
|
||||
//changes = true;
|
||||
}
|
||||
|
||||
// Set up the output's connection status, name, and current
|
||||
// CRT controller.
|
||||
bool pConn = m_connected;
|
||||
m_connected = (info->connection == RR_Connected);
|
||||
if (pConn != m_connected) {
|
||||
changes = true;
|
||||
}
|
||||
m_name = info->name;
|
||||
|
||||
setCrtc(m_screen->crtc(info->crtc));
|
||||
m_crtc->loadSettings(false);
|
||||
|
||||
for(int i = 0; i < info->ncrtc; ++i)
|
||||
m_possibleCrtcs.append(info->crtcs[i]);
|
||||
|
||||
//TODO: is it worth notifying changes on mode list changing?
|
||||
m_modes.clear();
|
||||
m_preferredMode = m_screen->mode(info->modes[info->npreferred]);
|
||||
|
||||
for (int i = 0; i < info->nmode; ++i)
|
||||
m_modes.append(info->modes[i]);
|
||||
|
||||
//get all possible rotations
|
||||
m_rotations = 0;
|
||||
for (int i = 0; i < m_possibleCrtcs.count(); ++i)
|
||||
{
|
||||
RandRCrtc *crtc = m_screen->crtc(m_possibleCrtcs.at(i));
|
||||
Q_ASSERT(crtc);
|
||||
m_rotations |= crtc->rotations();
|
||||
}
|
||||
m_originalRotation = m_crtc->rotation();
|
||||
m_originalRate = m_crtc->refreshRate();
|
||||
m_originalRect = m_crtc->rect();
|
||||
|
||||
if(isConnected()) {
|
||||
kDebug() << "Output name:" << m_name;
|
||||
kDebug() << "Output refresh rate:" << m_originalRate;
|
||||
kDebug() << "Output rect:" << m_originalRect;
|
||||
kDebug() << "Output rotation:" << m_originalRotation;
|
||||
}
|
||||
|
||||
XRRFreeOutputInfo(info);
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
void RandROutput::loadSettings(bool notify)
|
||||
{
|
||||
Q_UNUSED(notify);
|
||||
queryOutputInfo();
|
||||
|
||||
kDebug() << "STUB: calling queryOutputInfo instead. Check if this has "
|
||||
<< "any undesired effects. ";
|
||||
}
|
||||
|
||||
void RandROutput::handleEvent(XRROutputChangeNotifyEvent *event)
|
||||
{
|
||||
int changed = 0;
|
||||
|
||||
kDebug() << "[OUTPUT" << m_id << "] Got event for " << m_name;
|
||||
kDebug() << " crtc: " << event->crtc << "(current " << m_crtc->id() << ")";
|
||||
kDebug() << " mode: " << event->mode << "(current " << mode().id() << ")";
|
||||
kDebug() << " rotation: " << event->rotation;
|
||||
kDebug() << " connection: " << event->connection;
|
||||
|
||||
//FIXME: handling these events incorrectly, causing an X11 I/O error...
|
||||
// Disable for now.
|
||||
//qWarning() << "FIXME: Output event ignored!";
|
||||
//return;
|
||||
|
||||
RRCrtc currentCrtc = m_crtc->id();
|
||||
if (event->crtc != currentCrtc)
|
||||
{
|
||||
changed |= RandR::ChangeCrtc;
|
||||
// update crtc settings
|
||||
if (currentCrtc != None)
|
||||
m_crtc->loadSettings(true);
|
||||
//m_screen->crtc(m_currentCrtc)->loadSettings(true);
|
||||
setCrtc(m_screen->crtc(event->crtc));
|
||||
if (currentCrtc != None)
|
||||
m_crtc->loadSettings(true);
|
||||
}
|
||||
|
||||
if (event->mode != mode().id())
|
||||
changed |= RandR::ChangeMode;
|
||||
|
||||
if (event->rotation != rotation())
|
||||
changed |= RandR::ChangeRotation;
|
||||
|
||||
if((event->connection == RR_Connected) != m_connected)
|
||||
{
|
||||
changed |= RandR::ChangeConnection;
|
||||
m_connected = (event->connection == RR_Connected);
|
||||
if (!m_connected && currentCrtc != None)
|
||||
m_crtc = m_screen->crtc(None);
|
||||
}
|
||||
|
||||
if(changed)
|
||||
emit outputChanged(m_id, changed);
|
||||
}
|
||||
|
||||
void RandROutput::handlePropertyEvent(XRROutputPropertyNotifyEvent *event)
|
||||
{
|
||||
// TODO: Do something with this!
|
||||
// By perusing thru some XOrg drivers, some of the properties that can
|
||||
// are configured through XRANDR are:
|
||||
// - LVDS Backlights
|
||||
// - TV output formats
|
||||
|
||||
char *name = XGetAtomName(QX11Info::display(), event->property);
|
||||
kDebug() << "Got XRROutputPropertyNotifyEvent for property Atom " << name;
|
||||
XFree(name);
|
||||
}
|
||||
|
||||
QString RandROutput::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QString RandROutput::icon() const
|
||||
{
|
||||
// FIXME: check what names we should use and what kind of outputs randr can
|
||||
// report. It would also be interesting to be able to get the monitor name
|
||||
// using EDID or something like that, just don't know if it is even possible.
|
||||
if (m_name.contains("VGA"))
|
||||
return "video-display";
|
||||
else if (m_name.contains("LVDS"))
|
||||
return "video-display";
|
||||
|
||||
// I doubt this is a good choice; can't find anything better in the spec.
|
||||
// video-x-generic might work, but that's a mimetype, which is inappropriate
|
||||
// for an output connection type.
|
||||
else if (m_name.contains("TV"))
|
||||
return "multimedia-player";
|
||||
|
||||
return "video-display";
|
||||
}
|
||||
|
||||
CrtcList RandROutput::possibleCrtcs() const
|
||||
{
|
||||
return m_possibleCrtcs;
|
||||
}
|
||||
|
||||
RandRCrtc *RandROutput::crtc() const
|
||||
{
|
||||
return m_crtc;
|
||||
}
|
||||
|
||||
ModeList RandROutput::modes() const
|
||||
{
|
||||
return m_modes;
|
||||
}
|
||||
|
||||
RandRMode RandROutput::mode() const
|
||||
{
|
||||
if (!isConnected() || !m_crtc)
|
||||
return RandRMode();
|
||||
|
||||
return m_crtc->mode();
|
||||
}
|
||||
|
||||
RandRMode RandROutput::preferredMode(void) const
|
||||
{
|
||||
return m_preferredMode;
|
||||
}
|
||||
|
||||
SizeList RandROutput::sizes() const
|
||||
{
|
||||
SizeList sizeList;
|
||||
|
||||
foreach(const RRMode & m, m_modes)
|
||||
{
|
||||
RandRMode mode = m_screen->mode(m);
|
||||
if (!mode.isValid())
|
||||
continue;
|
||||
if (sizeList.indexOf(mode.size()) == -1)
|
||||
sizeList.append(mode.size());
|
||||
}
|
||||
return sizeList;
|
||||
}
|
||||
|
||||
QRect RandROutput::rect() const
|
||||
{
|
||||
if (!m_crtc) kDebug() << "No Crtc for output" << m_id;
|
||||
Q_ASSERT(m_crtc);
|
||||
if (!m_crtc->isValid())
|
||||
return QRect(0, 0, 0, 0);
|
||||
|
||||
return m_crtc->rect();
|
||||
}
|
||||
|
||||
RateList RandROutput::refreshRates(const QSize &s) const
|
||||
{
|
||||
RateList list;
|
||||
QSize size = s;
|
||||
if (!size.isValid())
|
||||
size = rect().size();
|
||||
|
||||
foreach(const RRMode & m, m_modes)
|
||||
{
|
||||
RandRMode mode = m_screen->mode(m);
|
||||
if (!mode.isValid())
|
||||
continue;
|
||||
if (mode.size() == size)
|
||||
list.append(mode.refreshRate());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
float RandROutput::refreshRate() const
|
||||
{
|
||||
return m_crtc->mode().refreshRate();
|
||||
}
|
||||
|
||||
int RandROutput::rotations() const
|
||||
{
|
||||
return m_rotations;
|
||||
}
|
||||
|
||||
int RandROutput::rotation() const
|
||||
{
|
||||
if (!isActive())
|
||||
return RandR::Rotate0;
|
||||
|
||||
Q_ASSERT(m_crtc);
|
||||
return m_crtc->rotation();
|
||||
}
|
||||
|
||||
bool RandROutput::isConnected() const
|
||||
{
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
bool RandROutput::isActive() const
|
||||
{
|
||||
return (m_connected && mode().isValid() && m_crtc->id() != None);
|
||||
}
|
||||
|
||||
void RandROutput::proposeOriginal()
|
||||
{
|
||||
if (m_crtc->id() != None)
|
||||
m_crtc->proposeOriginal();
|
||||
}
|
||||
|
||||
void RandROutput::proposeRefreshRate(float rate)
|
||||
{
|
||||
m_originalRate = refreshRate();
|
||||
m_proposedRate = rate;
|
||||
}
|
||||
|
||||
void RandROutput::proposeRect(const QRect &r)
|
||||
{
|
||||
m_originalRect = rect();
|
||||
m_proposedRect = r;
|
||||
}
|
||||
|
||||
void RandROutput::proposeRotation(int r)
|
||||
{
|
||||
m_originalRotation = rotation();
|
||||
m_proposedRotation = r;
|
||||
}
|
||||
|
||||
void RandROutput::slotDisable()
|
||||
{
|
||||
setCrtc(m_screen->crtc(None));
|
||||
}
|
||||
|
||||
void RandROutput::slotEnable()
|
||||
{
|
||||
if(!m_connected)
|
||||
return;
|
||||
|
||||
kDebug() << "Attempting to enable " << m_name;
|
||||
RandRCrtc *crtc = findEmptyCrtc();
|
||||
|
||||
if(crtc)
|
||||
setCrtc(crtc);
|
||||
}
|
||||
|
||||
RandRCrtc *RandROutput::findEmptyCrtc()
|
||||
{
|
||||
RandRCrtc *crtc = 0;
|
||||
|
||||
foreach(const RRCrtc & c, m_possibleCrtcs)
|
||||
{
|
||||
crtc = m_screen->crtc(c);
|
||||
if (crtc->connectedOutputs().count() == 0)
|
||||
return crtc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RandROutput::tryCrtc(RandRCrtc *crtc, int changes)
|
||||
{
|
||||
RandRCrtc *oldCrtc = m_crtc;
|
||||
|
||||
// if we are not yet using this crtc, switch to use it
|
||||
if (crtc->id() != oldCrtc->id())
|
||||
setCrtc(crtc);
|
||||
|
||||
crtc->setOriginal();
|
||||
|
||||
if (changes & RandR::ChangeRect)
|
||||
{
|
||||
crtc->proposeSize(m_proposedRect.size());
|
||||
crtc->proposePosition(m_proposedRect.topLeft());
|
||||
}
|
||||
if (changes & RandR::ChangeRotation)
|
||||
crtc->proposeRotation(m_proposedRotation);
|
||||
if (changes & RandR::ChangeRate)
|
||||
crtc->proposeRefreshRate(m_proposedRate);
|
||||
|
||||
if (crtc->applyProposed())
|
||||
return true;
|
||||
|
||||
// revert changes if we didn't succeed
|
||||
crtc->proposeOriginal();
|
||||
crtc->applyProposed();
|
||||
|
||||
// switch back to the old crtc
|
||||
setCrtc(oldCrtc);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RandROutput::setCrtc(RandRCrtc *crtc, bool applyNow)
|
||||
{
|
||||
Q_UNUSED(applyNow);
|
||||
if( !crtc || (m_crtc && crtc->id() == m_crtc->id()) )
|
||||
return false;
|
||||
|
||||
kDebug() << "Setting CRTC" << crtc->id() << "on output" << m_name << "(previous" << (m_crtc ? m_crtc->id() : 0) << ")";
|
||||
|
||||
if(m_crtc && m_crtc->isValid()) {
|
||||
disconnect(m_crtc, SIGNAL(crtcChanged(RRCrtc,int)),
|
||||
this, SLOT(slotCrtcChanged(RRCrtc,int)));
|
||||
|
||||
m_crtc->removeOutput(m_id);
|
||||
// m_crtc->applyProposed();
|
||||
}
|
||||
m_crtc = crtc;
|
||||
if (!m_crtc->isValid())
|
||||
return false;
|
||||
|
||||
if (!m_crtc->addOutput(m_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
kDebug() << "CRTC outputs:" << m_crtc->connectedOutputs();
|
||||
connect(m_crtc, SIGNAL(crtcChanged(RRCrtc,int)),
|
||||
this, SLOT(slotCrtcChanged(RRCrtc,int)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RandROutput::slotCrtcChanged(RRCrtc c, int changes)
|
||||
{
|
||||
Q_UNUSED(c);
|
||||
|
||||
//FIXME select which changes we should notify
|
||||
emit outputChanged(m_id, changes);
|
||||
}
|
||||
|
||||
bool RandROutput::applyProposed(int changes)
|
||||
{
|
||||
RandRCrtc *crtc;
|
||||
|
||||
QRect r;
|
||||
|
||||
if (changes & RandR::ChangeRect)
|
||||
r = m_proposedRect;
|
||||
|
||||
|
||||
// first try to apply to the already attached crtc if any
|
||||
if (m_crtc->isValid())
|
||||
{
|
||||
crtc = m_crtc;
|
||||
if (tryCrtc(crtc, changes))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//then try an empty crtc
|
||||
crtc = findEmptyCrtc();
|
||||
|
||||
// TODO: check if we can add this output to a CRTC which already has an output
|
||||
// connection
|
||||
if (!crtc)
|
||||
return false;
|
||||
|
||||
// try the crtc, and if no confirmation is needed or the user confirm, save the new settings
|
||||
if (tryCrtc(crtc, changes))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
* Copyright (c) 2007, 2008 Harry Bock <hbock@providence.edu>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __RANDROUTPUT_H__
|
||||
#define __RANDROUTPUT_H__
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QRect>
|
||||
|
||||
#include "randr.h"
|
||||
#include "randrmode.h"
|
||||
|
||||
|
||||
/** Class representing an RROutput identifier. This class is used
|
||||
* to control a particular output's configuration (i.e., the mode or
|
||||
* refresh rate of a DVI-I port, or the resolution of a VGA port). */
|
||||
class RandROutput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RandROutput(RandRScreen *parent, RROutput id);
|
||||
~RandROutput();
|
||||
|
||||
/** Returns the internal RANDR identifier for a particular output. */
|
||||
RROutput id() const;
|
||||
|
||||
/** Return the screen that this output belongs to. */
|
||||
RandRScreen *screen() const;
|
||||
|
||||
void loadSettings(bool notify = false);
|
||||
|
||||
/** Handle an event from RANDR signifying a change in this output's
|
||||
* configuration. */
|
||||
void handleEvent(XRROutputChangeNotifyEvent *event);
|
||||
void handlePropertyEvent(XRROutputPropertyNotifyEvent *event);
|
||||
|
||||
/** The name of this output, as returned by the X device driver.
|
||||
* Examples may be VGA, TMDS, DVI-I_2/digital, etc. Note:
|
||||
* this is usually NOT the name returned in the EDID of your
|
||||
* display. */
|
||||
QString name() const;
|
||||
|
||||
/** Return the icon name according to the device type. */
|
||||
QString icon() const;
|
||||
|
||||
/** List possible CRT controllers for this output. */
|
||||
CrtcList possibleCrtcs() const;
|
||||
|
||||
/** Returns the current CRTC for this output. */
|
||||
RandRCrtc *crtc() const;
|
||||
|
||||
/** Returns a list of all RRModes supported by this output. */
|
||||
ModeList modes() const;
|
||||
|
||||
/** Returns the current mode for this output. */
|
||||
RandRMode mode() const;
|
||||
|
||||
/** Returns the preferred mode for this output. */
|
||||
RandRMode preferredMode(void) const;
|
||||
|
||||
/** The list of supported sizes */
|
||||
SizeList sizes() const;
|
||||
QRect rect() const;
|
||||
|
||||
/** The list of refresh rates for the given size.
|
||||
* If no size is specified, it will use the current size */
|
||||
RateList refreshRates(const QSize &s = QSize()) const;
|
||||
|
||||
/** The current refresh rate. */
|
||||
float refreshRate() const;
|
||||
|
||||
/** Return all possible rotations for all CRTCs this output can be connected
|
||||
* to. */
|
||||
int rotations() const;
|
||||
|
||||
/** Returns the curent rotation of the CRTC this output is currently
|
||||
* connected to */
|
||||
int rotation() const;
|
||||
|
||||
/** Determines whether this output is connected to a display device.
|
||||
* It is not necessarily active. */
|
||||
bool isConnected() const;
|
||||
|
||||
/** Determines whether this output is currently driving a display
|
||||
* device. */
|
||||
bool isActive() const;
|
||||
|
||||
bool applyProposed(int changes = 0xffffff);
|
||||
void proposeOriginal();
|
||||
|
||||
// proposal functions
|
||||
void proposeRefreshRate(float rate);
|
||||
void proposeRect(const QRect &r);
|
||||
void proposeRotation(int rotation);
|
||||
|
||||
public slots:
|
||||
void slotDisable();
|
||||
void slotEnable();
|
||||
|
||||
private slots:
|
||||
void slotCrtcChanged(RRCrtc c, int changes);
|
||||
|
||||
signals:
|
||||
/** This signal is emitted when any relevant change
|
||||
* occurs in an output (mode, CRTC, resolution,
|
||||
* connection, etc.) */
|
||||
void outputChanged(RROutput o, int changes);
|
||||
|
||||
protected:
|
||||
/** Query Xrandr for information about this output, and set
|
||||
* up this instance accordingly. */
|
||||
bool queryOutputInfo(void);
|
||||
|
||||
/** Find the first CRTC that is not controlling any
|
||||
* display devices. */
|
||||
RandRCrtc *findEmptyCrtc(void);
|
||||
bool tryCrtc(RandRCrtc *crtc, int changes);
|
||||
|
||||
/** Set the current CRT controller for this output.
|
||||
* The CRTC should never be set directly; it should be added through
|
||||
* this function to properly manage signals related to this output. */
|
||||
bool setCrtc(RandRCrtc *crtc, bool applyNow = true);
|
||||
|
||||
private:
|
||||
RROutput m_id;
|
||||
XRROutputInfo* m_info;
|
||||
QString m_name;
|
||||
QString m_alias;
|
||||
|
||||
CrtcList m_possibleCrtcs;
|
||||
|
||||
RandRScreen *m_screen;
|
||||
RandRCrtc *m_crtc;
|
||||
|
||||
//proposed stuff (mostly to read from the configuration)
|
||||
QRect m_proposedRect;
|
||||
int m_proposedRotation;
|
||||
float m_proposedRate;
|
||||
|
||||
QRect m_originalRect;
|
||||
int m_originalRotation;
|
||||
float m_originalRate;
|
||||
|
||||
ModeList m_modes;
|
||||
RandRMode m_preferredMode;
|
||||
|
||||
int m_rotations;
|
||||
bool m_connected;
|
||||
};
|
||||
#endif
|
|
@ -1,388 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "randrscreen.h"
|
||||
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
#include <KDebug>
|
||||
|
||||
#include "randrcrtc.h"
|
||||
#include "randroutput.h"
|
||||
#include "randrmode.h"
|
||||
|
||||
|
||||
RandRScreen::RandRScreen(int screenIndex)
|
||||
: m_resources(0L)
|
||||
{
|
||||
m_index = screenIndex;
|
||||
m_rect = QRect(0, 0, XDisplayWidth(QX11Info::display(), m_index),
|
||||
XDisplayHeight(QX11Info::display(), m_index));
|
||||
|
||||
m_connectedCount = 0;
|
||||
m_activeCount = 0;
|
||||
|
||||
// select for randr input events
|
||||
int mask = RRScreenChangeNotifyMask |
|
||||
RRCrtcChangeNotifyMask |
|
||||
RROutputChangeNotifyMask |
|
||||
RROutputPropertyNotifyMask;
|
||||
|
||||
XRRSelectInput(QX11Info::display(), rootWindow(), 0);
|
||||
XRRSelectInput(QX11Info::display(), rootWindow(), mask);
|
||||
|
||||
kDebug() << "RRInput mask is set!!";
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
RandRScreen::~RandRScreen()
|
||||
{
|
||||
if (m_resources)
|
||||
XRRFreeScreenResources(m_resources);
|
||||
}
|
||||
|
||||
int RandRScreen::index() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
|
||||
XRRScreenResources* RandRScreen::resources() const
|
||||
{
|
||||
return m_resources;
|
||||
}
|
||||
|
||||
Window RandRScreen::rootWindow() const
|
||||
{
|
||||
return RootWindow(QX11Info::display(), m_index);
|
||||
}
|
||||
|
||||
void RandRScreen::pollState()
|
||||
{
|
||||
XRRFreeScreenResources(XRRGetScreenResources(QX11Info::display(), rootWindow()));
|
||||
}
|
||||
|
||||
void RandRScreen::reloadResources()
|
||||
{
|
||||
if (m_resources)
|
||||
XRRFreeScreenResources(m_resources);
|
||||
|
||||
m_resources = XRRGetScreenResources(QX11Info::display(), rootWindow());
|
||||
Q_ASSERT(m_resources);
|
||||
}
|
||||
|
||||
void RandRScreen::loadSettings(bool notify)
|
||||
{
|
||||
bool changed = false;
|
||||
int minW, minH, maxW, maxH;
|
||||
|
||||
Status status = XRRGetScreenSizeRange(QX11Info::display(), rootWindow(),
|
||||
&minW, &minH, &maxW, &maxH);
|
||||
//FIXME: we should check the status here
|
||||
Q_UNUSED(status);
|
||||
QSize minSize = QSize(minW, minH);
|
||||
QSize maxSize = QSize(maxW, maxH);
|
||||
|
||||
if (minSize != m_minSize || maxSize != m_maxSize)
|
||||
{
|
||||
m_minSize = minSize;
|
||||
m_maxSize = maxSize;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
reloadResources();
|
||||
|
||||
RandR::timestamp = m_resources->timestamp;
|
||||
|
||||
// get all modes
|
||||
changed |= loadModes();
|
||||
|
||||
//get all crtcs
|
||||
RandRCrtc *c_none = new RandRCrtc(this, None);
|
||||
m_crtcs[None] = c_none;
|
||||
|
||||
for (int i = 0; i < m_resources->ncrtc; ++i)
|
||||
{
|
||||
RRCrtc crtc = m_resources->crtcs[i];
|
||||
if (m_crtcs.contains(crtc))
|
||||
m_crtcs[crtc]->loadSettings(notify);
|
||||
else
|
||||
{
|
||||
kDebug() << "adding crtc: " << crtc;
|
||||
RandRCrtc *c = new RandRCrtc(this, crtc);
|
||||
c->loadSettings(notify);
|
||||
connect(c, SIGNAL(crtcChanged(RRCrtc,int)), this, SIGNAL(configChanged()));
|
||||
m_crtcs[crtc] = c;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
//get all outputs
|
||||
for (int i = 0; i < m_resources->noutput; ++i)
|
||||
{
|
||||
RROutput output = m_resources->outputs[i];
|
||||
if (m_outputs.contains(output))
|
||||
;//m_outputs[m_resources->outputs[i]]->loadSettings(notify);
|
||||
else
|
||||
{
|
||||
kDebug() << "adding output: " << output;
|
||||
RandROutput *o = new RandROutput(this, output);
|
||||
connect(o, SIGNAL(outputChanged(RROutput,int)), this,
|
||||
SLOT(slotOutputChanged(RROutput,int)));
|
||||
m_outputs[output] = o;
|
||||
if (o->isConnected())
|
||||
m_connectedCount++;
|
||||
if (o->isActive())
|
||||
m_activeCount++;
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (notify && changed)
|
||||
emit configChanged();
|
||||
|
||||
}
|
||||
|
||||
bool RandRScreen::loadModes()
|
||||
{
|
||||
bool changed = false;
|
||||
for (int i = 0; i < m_resources->nmode; ++i)
|
||||
{
|
||||
XRRModeInfo mode = m_resources->modes[i];
|
||||
if (!m_modes.contains(mode.id))
|
||||
{
|
||||
kDebug() << "adding mode: " << mode.id << mode.width << "x" << mode.height;
|
||||
m_modes[mode.id] = RandRMode(&mode);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void RandRScreen::handleEvent(XRRScreenChangeNotifyEvent* event)
|
||||
{
|
||||
kDebug();
|
||||
|
||||
// rotation change not handled
|
||||
m_rect.setWidth(event->width);
|
||||
m_rect.setHeight(event->height);
|
||||
|
||||
// Will: the code between here and the emit was added in gpothiers 'fix many kephal bugs' commit
|
||||
// (910287). The RandROutput::loadSettings() call was added commented out, so I think he was
|
||||
// trying stuff out and forgot to remove it. I don't know the difference between
|
||||
// XRRScreenChangeNotifyEvent and XRRNotifyEvent, but XRRNotifyEvent is passed on to the output
|
||||
// so presumably it handles those events
|
||||
reloadResources();
|
||||
loadModes();
|
||||
kDebug() << "Reloaded modes";
|
||||
|
||||
// foreach(RandROutput *output, m_outputs) {
|
||||
// output->loadSettings(false);
|
||||
// }
|
||||
|
||||
|
||||
emit configChanged();
|
||||
}
|
||||
|
||||
void RandRScreen::handleRandREvent(XRRNotifyEvent* event)
|
||||
{
|
||||
RandRCrtc *c;
|
||||
RandROutput *o;
|
||||
XRRCrtcChangeNotifyEvent *crtcEvent;
|
||||
XRROutputChangeNotifyEvent *outputEvent;
|
||||
XRROutputPropertyNotifyEvent *propertyEvent;
|
||||
|
||||
// forward events to crtcs and outputs
|
||||
switch (event->subtype) {
|
||||
case RRNotify_CrtcChange:
|
||||
kDebug() << "CrtcChange";
|
||||
crtcEvent = (XRRCrtcChangeNotifyEvent*)event;
|
||||
c = crtc(crtcEvent->crtc);
|
||||
if (c) {
|
||||
c->handleEvent(crtcEvent);
|
||||
} else {
|
||||
kDebug() << "crtc not found";
|
||||
}
|
||||
return;
|
||||
|
||||
case RRNotify_OutputChange:
|
||||
kDebug() << "OutputChange";
|
||||
outputEvent = (XRROutputChangeNotifyEvent*)event;
|
||||
o = output(outputEvent->output);
|
||||
if (o) {
|
||||
o->handleEvent(outputEvent);
|
||||
} else {
|
||||
kDebug() << "output not found";
|
||||
}
|
||||
return;
|
||||
|
||||
case RRNotify_OutputProperty:
|
||||
kDebug() << "OutputProperty";
|
||||
propertyEvent = (XRROutputPropertyNotifyEvent*)event;
|
||||
o = output(propertyEvent->output);
|
||||
if (o) {
|
||||
o->handlePropertyEvent(propertyEvent);
|
||||
} else {
|
||||
kDebug() << "output not found";
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
kDebug() << "Other";
|
||||
}
|
||||
}
|
||||
|
||||
QSize RandRScreen::minSize() const
|
||||
{
|
||||
return m_minSize;
|
||||
}
|
||||
|
||||
QSize RandRScreen::maxSize() const
|
||||
{
|
||||
return m_maxSize;
|
||||
}
|
||||
|
||||
CrtcMap RandRScreen::crtcs() const
|
||||
{
|
||||
return m_crtcs;
|
||||
}
|
||||
|
||||
RandRCrtc* RandRScreen::crtc(RRCrtc id) const
|
||||
{
|
||||
if (m_crtcs.contains(id))
|
||||
return m_crtcs[id];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
OutputMap RandRScreen::outputs() const
|
||||
{
|
||||
return m_outputs;
|
||||
}
|
||||
|
||||
RandROutput* RandRScreen::output(RROutput id) const
|
||||
{
|
||||
if (m_outputs.contains(id))
|
||||
return m_outputs[id];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ModeMap RandRScreen::modes() const
|
||||
{
|
||||
return m_modes;
|
||||
}
|
||||
|
||||
RandRMode RandRScreen::mode(RRMode id) const
|
||||
{
|
||||
if (m_modes.contains(id))
|
||||
return m_modes[id];
|
||||
|
||||
return RandRMode(0);
|
||||
}
|
||||
|
||||
bool RandRScreen::adjustSize(const QRect &minimumSize)
|
||||
{
|
||||
//try to find a size in which all outputs fit
|
||||
|
||||
//start with a given minimum rect
|
||||
QRect rect = QRect(0, 0, 0, 0).united(minimumSize);
|
||||
|
||||
foreach(RandROutput *output, m_outputs)
|
||||
{
|
||||
// outputs that are not active should not be taken into account
|
||||
// when calculating the screen size
|
||||
if (!output->isActive())
|
||||
continue;
|
||||
rect = rect.united(output->rect());
|
||||
}
|
||||
|
||||
|
||||
// check bounds
|
||||
if (rect.width() < m_minSize.width())
|
||||
rect.setWidth(m_minSize.width());
|
||||
if (rect.height() < m_minSize.height())
|
||||
rect.setHeight(m_minSize.height());
|
||||
|
||||
if (rect.width() > m_maxSize.width())
|
||||
return false;
|
||||
if (rect.height() > m_maxSize.height())
|
||||
return false;
|
||||
|
||||
return setSize(rect.size());
|
||||
}
|
||||
|
||||
bool RandRScreen::setSize(const QSize &s)
|
||||
{
|
||||
if (s == m_rect.size())
|
||||
return true;
|
||||
|
||||
if (s.width() < m_minSize.width() ||
|
||||
s.height() < m_minSize.height() ||
|
||||
s.width() > m_maxSize.width() ||
|
||||
s.height() > m_maxSize.height())
|
||||
return false;
|
||||
|
||||
int widthMM, heightMM;
|
||||
float dpi;
|
||||
|
||||
/* values taken from xrandr */
|
||||
dpi = (25.4 * DisplayHeight(QX11Info::display(), m_index)) / DisplayHeightMM(QX11Info::display(), m_index);
|
||||
widthMM = (int) ((25.4 * s.width()) / dpi);
|
||||
heightMM = (int) ((25.4 * s.height()) / dpi);
|
||||
|
||||
XRRSetScreenSize(QX11Info::display(), rootWindow(), s.width(), s.height(), widthMM, heightMM);
|
||||
m_rect.setSize(s);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int RandRScreen::connectedCount() const
|
||||
{
|
||||
return m_connectedCount;
|
||||
}
|
||||
|
||||
int RandRScreen::activeCount() const
|
||||
{
|
||||
return m_activeCount;
|
||||
}
|
||||
|
||||
QRect RandRScreen::rect() const
|
||||
{
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
void RandRScreen::slotOutputChanged(RROutput id, int changes)
|
||||
{
|
||||
Q_UNUSED(id);
|
||||
Q_UNUSED(changes);
|
||||
|
||||
int connected = 0, active = 0;
|
||||
foreach(RandROutput *output, m_outputs)
|
||||
{
|
||||
if (output->isConnected())
|
||||
connected++;
|
||||
if (output->isActive())
|
||||
active++;
|
||||
}
|
||||
|
||||
m_connectedCount = connected;
|
||||
m_activeCount = active;
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __RANDRSCREEN_H__
|
||||
#define __RANDRSCREEN_H__
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "randr.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QRect>
|
||||
|
||||
|
||||
#include <QSize>
|
||||
|
||||
|
||||
class RandRScreen : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RandRScreen(int screenIndex);
|
||||
~RandRScreen();
|
||||
|
||||
int index() const;
|
||||
|
||||
XRRScreenResources* resources() const;
|
||||
Window rootWindow() const;
|
||||
|
||||
QSize minSize() const;
|
||||
QSize maxSize() const;
|
||||
|
||||
void loadSettings(bool notify = false);
|
||||
|
||||
void handleEvent(XRRScreenChangeNotifyEvent* event);
|
||||
void handleRandREvent(XRRNotifyEvent* event);
|
||||
|
||||
CrtcMap crtcs() const;
|
||||
RandRCrtc *crtc(RRCrtc id) const;
|
||||
|
||||
OutputMap outputs() const;
|
||||
RandROutput *output(RROutput id) const;
|
||||
|
||||
ModeMap modes() const;
|
||||
RandRMode mode(RRMode id) const;
|
||||
|
||||
bool adjustSize(const QRect &minimumSize = QRect(0,0,0,0));
|
||||
bool setSize(const QSize &s);
|
||||
|
||||
/**
|
||||
* Return the number of connected outputs
|
||||
*/
|
||||
int connectedCount() const;
|
||||
|
||||
/**
|
||||
* Return the number of active outputs
|
||||
*/
|
||||
int activeCount() const;
|
||||
|
||||
bool outputsUnified() const;
|
||||
void setOutputsUnified(bool unified);
|
||||
|
||||
int unifiedRotations() const;
|
||||
SizeList unifiedSizes() const;
|
||||
|
||||
QRect rect() const;
|
||||
|
||||
void pollState();
|
||||
|
||||
protected:
|
||||
bool loadModes();
|
||||
void reloadResources();
|
||||
|
||||
public slots:
|
||||
void slotOutputChanged(RROutput id, int changes);
|
||||
|
||||
signals:
|
||||
void configChanged();
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
QSize m_minSize;
|
||||
QSize m_maxSize;
|
||||
QRect m_rect;
|
||||
|
||||
int m_connectedCount;
|
||||
int m_activeCount;
|
||||
|
||||
XRRScreenResources* m_resources;
|
||||
|
||||
CrtcMap m_crtcs;
|
||||
OutputMap m_outputs;
|
||||
ModeMap m_modes;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,423 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "xrandroutputs.h"
|
||||
#include "edid.h"
|
||||
|
||||
#include "xrandr12/randrscreen.h"
|
||||
#include "xrandr12/randroutput.h"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
||||
#include <KDebug>
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
XRandROutputs::XRandROutputs(QObject * parent, RandRDisplay * display)
|
||||
: BackendOutputs(parent)
|
||||
{
|
||||
m_display = display;
|
||||
init();
|
||||
}
|
||||
|
||||
QList<Output *> XRandROutputs::outputs() {
|
||||
QList<Output *> result;
|
||||
foreach (XRandROutput * output, m_outputs) {
|
||||
result.append(output);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void XRandROutputs::init() {
|
||||
kDebug();
|
||||
RandRScreen * screen = m_display->screen(0);
|
||||
foreach (RandROutput * output, screen->outputs()) {
|
||||
XRandROutput * o = new XRandROutput(this, output->id());
|
||||
|
||||
connect(o, SIGNAL(outputConnected(Kephal::Output*)),
|
||||
this, SIGNAL(outputConnected(Kephal::Output*)));
|
||||
|
||||
connect(o, SIGNAL(outputDisconnected(Kephal::Output*)),
|
||||
this, SIGNAL(outputDisconnected(Kephal::Output*)));
|
||||
|
||||
connect(o, SIGNAL(outputActivated(Kephal::Output*)),
|
||||
this, SIGNAL(outputActivated(Kephal::Output*)));
|
||||
|
||||
connect(o, SIGNAL(outputDeactivated(Kephal::Output*)),
|
||||
this, SIGNAL(outputDeactivated(Kephal::Output*)));
|
||||
|
||||
connect(o, SIGNAL(outputResized(Kephal::Output*,QSize,QSize)),
|
||||
this, SIGNAL(outputResized(Kephal::Output*,QSize,QSize)));
|
||||
|
||||
connect(o, SIGNAL(outputMoved(Kephal::Output*,QPoint,QPoint)),
|
||||
this, SIGNAL(outputMoved(Kephal::Output*,QPoint,QPoint)));
|
||||
|
||||
connect(o, SIGNAL(outputRateChanged(Kephal::Output*,float,float)),
|
||||
this, SIGNAL(outputRateChanged(Kephal::Output*,float,float)));
|
||||
|
||||
connect(o, SIGNAL(outputRotated(Kephal::Output*,Kephal::Rotation,Kephal::Rotation)),
|
||||
this, SIGNAL(outputRotated(Kephal::Output*,Kephal::Rotation,Kephal::Rotation)));
|
||||
connect(o, SIGNAL(outputReflected(Kephal::Output*,bool,bool,bool,bool)),
|
||||
this, SIGNAL(outputReflected(Kephal::Output*,bool,bool,bool,bool)));
|
||||
|
||||
kDebug() << " added output " << output->id();
|
||||
m_outputs.insert(o->id(), o);
|
||||
}
|
||||
}
|
||||
|
||||
RandROutput * XRandROutputs::output(RROutput rrId) {
|
||||
return m_display->screen(0)->outputs()[rrId];
|
||||
}
|
||||
|
||||
RandRDisplay * XRandROutputs::display() {
|
||||
return m_display;
|
||||
}
|
||||
|
||||
XRandROutput::XRandROutput(XRandROutputs * parent, RROutput rrId)
|
||||
: BackendOutput(parent), m_productId(-1), m_serialNumber(0)
|
||||
{
|
||||
m_outputs = parent;
|
||||
m_rrId = rrId;
|
||||
|
||||
parseEdid();
|
||||
|
||||
saveAsPrevious();
|
||||
|
||||
connect(output(), SIGNAL(outputChanged(RROutput,int)),
|
||||
this, SLOT(outputChanged(RROutput,int)));
|
||||
//connect(this, SLOT(_activate()), output(), SLOT(slotEnable()));
|
||||
//connect(this, SLOT(_deactivate()), output(), SLOT(slotDisable()));
|
||||
}
|
||||
|
||||
void XRandROutput::parseEdid() {
|
||||
|
||||
Atom atom = XInternAtom (QX11Info::display(), "EDID_DATA", false);
|
||||
Atom type;
|
||||
unsigned char * data;
|
||||
unsigned long size;
|
||||
unsigned long after;
|
||||
int format;
|
||||
|
||||
XRRGetOutputProperty(QX11Info::display(), m_rrId, atom, 0, 100,
|
||||
False, False, AnyPropertyType,
|
||||
&type, &format, &size, &after, &data);
|
||||
|
||||
if (type == XA_INTEGER && format == 8 && EDID_TEST_HEADER(data)) {
|
||||
//kDebug() << "got a valid edid block...";
|
||||
|
||||
/**
|
||||
* parse the 3 letter vendor code
|
||||
*/
|
||||
char * vendor = new char[4];
|
||||
|
||||
vendor[0] = EDID_VENDOR_1(data);
|
||||
vendor[1] = EDID_VENDOR_2(data);
|
||||
vendor[2] = EDID_VENDOR_3(data);
|
||||
vendor[3] = 0x00;
|
||||
m_vendor = vendor;
|
||||
|
||||
kDebug() << "vendor code:" << m_vendor;
|
||||
|
||||
delete[] vendor;
|
||||
|
||||
/**
|
||||
* parse the 16bit product id
|
||||
*/
|
||||
m_productId = EDID_PRODUCT_ID(data);
|
||||
|
||||
kDebug() << "product id:" << m_productId;
|
||||
|
||||
/**
|
||||
* parse the 32bit serial number
|
||||
*/
|
||||
m_serialNumber = EDID_SERIAL_NUMBER(data);
|
||||
|
||||
kDebug() << "serial number:" << m_serialNumber;
|
||||
} else {
|
||||
m_vendor = QString();
|
||||
m_productId = -1;
|
||||
m_serialNumber = 0;
|
||||
}
|
||||
|
||||
XFree(data);
|
||||
}
|
||||
|
||||
void XRandROutput::outputChanged(RROutput id, int changes) {
|
||||
Q_ASSERT(id == m_rrId);
|
||||
kDebug() << isConnected() << isActivated() << geom();
|
||||
if (isConnected() != m_previousConnected) {
|
||||
if (isConnected()) {
|
||||
saveAsPrevious();
|
||||
parseEdid();
|
||||
emit outputConnected(this);
|
||||
if (isActivated()) {
|
||||
emit outputActivated(this);
|
||||
}
|
||||
} else {
|
||||
if (m_previousActivated) {
|
||||
saveAsPrevious();
|
||||
emit outputDeactivated(this);
|
||||
}
|
||||
saveAsPrevious();
|
||||
emit outputDisconnected(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (! isConnected()) {
|
||||
return;
|
||||
}
|
||||
if (isActivated() != m_previousActivated) {
|
||||
saveAsPrevious();
|
||||
if (isActivated()) {
|
||||
emit outputActivated(this);
|
||||
} else {
|
||||
emit outputDeactivated(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QRect previousGeom = m_previousGeom;
|
||||
Rotation previousRotation = m_previousRotation;
|
||||
float previousRate = m_previousRate;
|
||||
bool previousReflectX = m_previousReflectX;
|
||||
bool previousReflectY = m_previousReflectY;
|
||||
saveAsPrevious();
|
||||
if (size() != previousGeom.size()) {
|
||||
emit outputResized(this, previousGeom.size(), size());
|
||||
}
|
||||
if (position() != previousGeom.topLeft()) {
|
||||
emit outputMoved(this, previousGeom.topLeft(), position());
|
||||
}
|
||||
if (rotation() != previousRotation) {
|
||||
emit outputRotated(this, previousRotation, rotation());
|
||||
}
|
||||
if (rate() != previousRate) {
|
||||
emit outputRateChanged(this, previousRate, rate());
|
||||
}
|
||||
if ((reflectX() != previousReflectX) || (reflectY() != previousReflectY)) {
|
||||
emit outputReflected(this, previousReflectX, previousReflectY, reflectX(), reflectY());
|
||||
}
|
||||
}
|
||||
|
||||
void XRandROutput::saveAsPrevious() {
|
||||
m_previousConnected = isConnected();
|
||||
m_previousActivated = isActivated();
|
||||
m_previousGeom = geom();
|
||||
m_previousRotation = rotation();
|
||||
m_previousRate = rate();
|
||||
m_previousReflectX = reflectX();
|
||||
m_previousReflectY = reflectY();
|
||||
}
|
||||
|
||||
bool XRandROutput::applyGeom(const QRect & geom, float rate) {
|
||||
if ((geom == this->geom()) && ((rate < 1) || (qFuzzyCompare(rate, this->rate())))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
output()->proposeRect(geom);
|
||||
if (rate < 1) {
|
||||
rate = output()->refreshRate();
|
||||
}
|
||||
bool found = false;
|
||||
QList<float> rates = output()->refreshRates(geom.size());
|
||||
foreach (float r, rates) {
|
||||
if (qFuzzyCompare(rate, r)) {
|
||||
rate = r;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((! found) && (! rates.empty())) {
|
||||
rate = rates[0];
|
||||
}
|
||||
if (rate > 1) {
|
||||
output()->proposeRefreshRate(rate);
|
||||
}
|
||||
|
||||
return output()->applyProposed();
|
||||
}
|
||||
|
||||
bool XRandROutput::applyOrientation(Rotation rotation, bool reflectX, bool reflectY) {
|
||||
if ((rotation == this->rotation()) && (reflectX == this->reflectX()) && (reflectY == this->reflectY())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int orientation = 0;
|
||||
|
||||
switch (rotation) {
|
||||
case RotateRight:
|
||||
orientation |= RandR::Rotate90;
|
||||
break;
|
||||
case RotateLeft:
|
||||
orientation |= RandR::Rotate270;
|
||||
break;
|
||||
case RotateInverted:
|
||||
orientation |= RandR::Rotate180;
|
||||
break;
|
||||
default:
|
||||
orientation |= RandR::Rotate0;
|
||||
}
|
||||
|
||||
if (reflectX) {
|
||||
orientation |= RandR::ReflectX;
|
||||
}
|
||||
if (reflectY) {
|
||||
orientation |= RandR::ReflectY;
|
||||
}
|
||||
|
||||
output()->proposeRotation(orientation);
|
||||
return output()->applyProposed();
|
||||
}
|
||||
|
||||
void XRandROutput::deactivate()
|
||||
{
|
||||
output()->slotDisable();
|
||||
}
|
||||
|
||||
RandROutput * XRandROutput::output() const
|
||||
{
|
||||
return m_outputs->output(m_rrId);
|
||||
}
|
||||
|
||||
QString XRandROutput::id() const
|
||||
{
|
||||
return output()->name();
|
||||
}
|
||||
|
||||
QSize XRandROutput::size() const
|
||||
{
|
||||
return output()->rect().size();
|
||||
}
|
||||
|
||||
QSize XRandROutput::preferredSize() const
|
||||
{
|
||||
if (output()->preferredMode().size().isEmpty()) {
|
||||
return QSize();
|
||||
} else {
|
||||
return output()->preferredMode().size();
|
||||
}
|
||||
}
|
||||
|
||||
QList<QSize> XRandROutput::availableSizes() const {
|
||||
QList<QSize> sizes = output()->sizes();
|
||||
return sizes;
|
||||
}
|
||||
|
||||
QPoint XRandROutput::position() const {
|
||||
return output()->rect().topLeft();
|
||||
}
|
||||
|
||||
bool XRandROutput::isConnected() const {
|
||||
return output()->isConnected();
|
||||
}
|
||||
|
||||
bool XRandROutput::isActivated() const
|
||||
{
|
||||
return output()->isActive();
|
||||
}
|
||||
|
||||
QString XRandROutput::vendor() const
|
||||
{
|
||||
return m_vendor;
|
||||
}
|
||||
|
||||
int XRandROutput::productId() const
|
||||
{
|
||||
return m_productId;
|
||||
}
|
||||
|
||||
unsigned int XRandROutput::serialNumber() const
|
||||
{
|
||||
return m_serialNumber;
|
||||
}
|
||||
|
||||
RROutput XRandROutput::_id() const {
|
||||
return m_rrId;
|
||||
}
|
||||
|
||||
Rotation XRandROutput::rotation() const
|
||||
{
|
||||
switch (output()->rotation() & RandR::RotateMask) {
|
||||
case RandR::Rotate90:
|
||||
return RotateRight;
|
||||
case RandR::Rotate180:
|
||||
return RotateInverted;
|
||||
case RandR::Rotate270:
|
||||
return RotateLeft;
|
||||
default:
|
||||
return RotateNormal;
|
||||
}
|
||||
}
|
||||
|
||||
bool XRandROutput::reflectX() const
|
||||
{
|
||||
return (output()->rotation() & RandR::ReflectX);
|
||||
}
|
||||
|
||||
bool XRandROutput::reflectY() const
|
||||
{
|
||||
return (output()->rotation() & RandR::ReflectY);
|
||||
}
|
||||
|
||||
float XRandROutput::rate() const
|
||||
{
|
||||
return output()->refreshRate();
|
||||
}
|
||||
|
||||
QList<float> XRandROutput::availableRates() const
|
||||
{
|
||||
return output()->refreshRates(size());
|
||||
}
|
||||
|
||||
void XRandROutput::resize(const QSize & size)
|
||||
{
|
||||
Q_UNUSED(size)
|
||||
#warning implement!
|
||||
}
|
||||
|
||||
void XRandROutput::rotate(Rotation rotation)
|
||||
{
|
||||
Q_UNUSED(rotation)
|
||||
#warning implement!
|
||||
}
|
||||
|
||||
void XRandROutput::setReflectX(bool reflect)
|
||||
{
|
||||
Q_UNUSED(reflect)
|
||||
#warning implement!
|
||||
}
|
||||
|
||||
void XRandROutput::setReflectY(bool reflect)
|
||||
{
|
||||
Q_UNUSED(reflect)
|
||||
#warning implement!
|
||||
}
|
||||
|
||||
void XRandROutput::changeRate(double rate)
|
||||
{
|
||||
Q_UNUSED(rate)
|
||||
#warning implement!
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHAL_XRANDROUTPUTS_H
|
||||
#define KEPHAL_XRANDROUTPUTS_H
|
||||
|
||||
#include "backendoutputs.h"
|
||||
#include "xrandr12/randrdisplay.h"
|
||||
|
||||
|
||||
namespace Kephal {
|
||||
|
||||
class XRandROutputs;
|
||||
|
||||
/**
|
||||
* Maps RandROutput class to Kephal::Output
|
||||
*/
|
||||
class XRandROutput : public BackendOutput {
|
||||
Q_OBJECT
|
||||
public:
|
||||
XRandROutput(XRandROutputs * parent, RROutput rrId);
|
||||
|
||||
QString id() const;
|
||||
|
||||
QSize size() const;
|
||||
QSize preferredSize() const;
|
||||
QList<QSize> availableSizes() const;
|
||||
QPoint position() const;
|
||||
bool isConnected() const;
|
||||
bool isActivated() const;
|
||||
QString vendor() const;
|
||||
int productId() const;
|
||||
unsigned int serialNumber() const;
|
||||
Rotation rotation() const;
|
||||
bool reflectX() const;
|
||||
bool reflectY() const;
|
||||
float rate() const;
|
||||
QList<float> availableRates() const;
|
||||
|
||||
bool applyGeom(const QRect & rect, float rate);
|
||||
bool applyOrientation(Rotation rotation, bool reflectX, bool reflectY);
|
||||
|
||||
//void _revert();
|
||||
void deactivate();
|
||||
//void _activate();
|
||||
RROutput _id() const;
|
||||
|
||||
void resize(const QSize & size);
|
||||
|
||||
void rotate(Rotation rotation);
|
||||
|
||||
void setReflectX(bool reflect);
|
||||
|
||||
void setReflectY(bool reflect);
|
||||
|
||||
void changeRate(double rate);
|
||||
|
||||
public Q_SLOTS:
|
||||
void outputChanged(RROutput id, int changes);
|
||||
|
||||
Q_SIGNALS:
|
||||
void outputConnected(Kephal::Output * o);
|
||||
void outputDisconnected(Kephal::Output * o);
|
||||
void outputActivated(Kephal::Output * o);
|
||||
void outputDeactivated(Kephal::Output * o);
|
||||
void outputResized(Kephal::Output * o, QSize oldSize, QSize newSize);
|
||||
void outputMoved(Kephal::Output * o, QPoint oldPosition, QPoint newPosition);
|
||||
void outputRateChanged(Kephal::Output * o, float oldRate, float newRate);
|
||||
void outputRotated(Kephal::Output * o, Kephal::Rotation oldRotation, Kephal::Rotation newRotation);
|
||||
void outputReflected(Kephal::Output * o, bool oldX, bool oldY, bool newX, bool newY);
|
||||
|
||||
private:
|
||||
RandROutput * output() const;
|
||||
void parseEdid();
|
||||
void saveAsPrevious();
|
||||
|
||||
XRandROutputs * m_outputs;
|
||||
RROutput m_rrId;
|
||||
QString m_vendor;
|
||||
int m_productId;
|
||||
unsigned int m_serialNumber;
|
||||
QRect m_previousGeom;
|
||||
bool m_previousConnected;
|
||||
bool m_previousActivated;
|
||||
Rotation m_previousRotation;
|
||||
float m_previousRate;
|
||||
bool m_previousReflectX;
|
||||
bool m_previousReflectY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Maps RandRDisplay to Kephal::Outputs
|
||||
*/
|
||||
class XRandROutputs : public BackendOutputs {
|
||||
Q_OBJECT
|
||||
public:
|
||||
XRandROutputs(QObject * parent, RandRDisplay * display);
|
||||
|
||||
QList<Output *> outputs();
|
||||
|
||||
RandROutput * output(RROutput rrId);
|
||||
using Outputs::output;
|
||||
RandRDisplay * display();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
RandRDisplay * m_display;
|
||||
QMap<QString, XRandROutput *> m_outputs;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // KEPHAL_XRANDROUTPUTS_H
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
SET (kephalapp_SRCS kephalapp.cpp)
|
||||
|
||||
ADD_EXECUTABLE (kephalapp ${kephalapp_SRCS})
|
||||
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}/.. ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
TARGET_LINK_LIBRARIES (kephalapp ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTDBUS_LIBRARY} kephal)
|
||||
|
||||
#INSTALL (TARGETS kephalapp RUNTIME DESTINATION bin)
|
|
@ -1,3 +0,0 @@
|
|||
This is a little command-line client to kephal.
|
||||
Currently it allows to query kephal for current screens and outputs and to listen
|
||||
for kephal-messages. This allows for better understanding where errors occur.
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "kephalapp.h"
|
||||
#include "kephal/screens.h"
|
||||
#include "kephal/outputs.h"
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KCmdLineArgs>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define WITH_OUTPUTS 0
|
||||
|
||||
using namespace Kephal;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
KAboutData aboutData( "kephalapp", "filetypes", ki18n("KEditFileType"), "1.0",
|
||||
ki18n("KDE file type editor - simplified version for editing a single file type"),
|
||||
KAboutData::License_GPL,
|
||||
ki18n("(c) 2000, KDE developers") );
|
||||
|
||||
aboutData.addAuthor(ki18n("Aike J Sommer"), ki18n("Original author"), "dev@aikesommer.name");
|
||||
aboutData.addAuthor(ki18n("Will Stephenson"), ki18n("Developer"), "wstephenson@kde.org");
|
||||
|
||||
KCmdLineArgs::init( argc, argv, &aboutData );
|
||||
KCmdLineOptions options;
|
||||
|
||||
options.add("listen", ki18n("keep running and report events"));
|
||||
KCmdLineArgs::addCmdLineOptions(options);
|
||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||
|
||||
KephalApp app(args->isSet("listen"), argc, argv);
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
||||
KephalApp::KephalApp(bool listen, int & argc, char ** argv)
|
||||
: QApplication(argc, argv), m_listen(listen)
|
||||
{
|
||||
QTimer::singleShot(0, this, SLOT(run()));
|
||||
}
|
||||
|
||||
KephalApp::~KephalApp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void KephalApp::run() {
|
||||
query();
|
||||
if (!m_listen) {
|
||||
QApplication::exit(0);
|
||||
}
|
||||
|
||||
connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(qdwScreenResized(int)));
|
||||
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(qdwScreenCountChanged(int)));
|
||||
connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(qdwWorkAreaResized(int)));
|
||||
|
||||
connect(Kephal::Screens::self(), SIGNAL(screenMoved(Kephal::Screen*,QPoint,QPoint)),
|
||||
this, SLOT(screenMoved(Kephal::Screen*,QPoint,QPoint)));
|
||||
connect(Kephal::Screens::self(), SIGNAL(screenResized(Kephal::Screen*,QSize,QSize)),
|
||||
this, SLOT(screenResized(Kephal::Screen*,QSize,QSize)));
|
||||
connect(Kephal::Screens::self(), SIGNAL(screenRemoved(int)),
|
||||
this, SLOT(screenRemoved(int)));
|
||||
connect(Kephal::Screens::self(), SIGNAL(screenAdded(Kephal::Screen*)),
|
||||
this, SLOT(screenAdded(Kephal::Screen*)));
|
||||
}
|
||||
|
||||
void KephalApp::screenMoved(Kephal::Screen * s, QPoint o, QPoint n)
|
||||
{
|
||||
qDebug() << "****************";
|
||||
qDebug() << "* New message coming in:";
|
||||
qDebug() << "* screenMoved: " << s->id() << " from " << o << " to " << n;
|
||||
qDebug() << "****************";
|
||||
}
|
||||
|
||||
void KephalApp::screenResized(Kephal::Screen * s, QSize o, QSize n)
|
||||
{
|
||||
qDebug() << "****************";
|
||||
qDebug() << "* New message coming in:";
|
||||
qDebug() << "* screenResized: " << s->id() << " from " << o << " to " << n;
|
||||
qDebug() << "****************";
|
||||
}
|
||||
|
||||
void KephalApp::screenRemoved(int s)
|
||||
{
|
||||
qDebug() << "****************";
|
||||
qDebug() << "* New message coming in:";
|
||||
qDebug() << "* screenRemoved: " << s;
|
||||
qDebug() << "****************";
|
||||
}
|
||||
|
||||
void KephalApp::screenAdded(Kephal::Screen * s)
|
||||
{
|
||||
qDebug() << "****************";
|
||||
qDebug() << "* New message coming in:";
|
||||
qDebug() << "* screenAdded: " << s->id() << " at " << s->position() << " with size " << s->size();
|
||||
qDebug() << "****************";
|
||||
}
|
||||
|
||||
|
||||
void KephalApp::query()
|
||||
{
|
||||
qDebug() << "Screens:";
|
||||
foreach (Screen * screen, Screens::self()->screens()) {
|
||||
qDebug() << " Screen " << screen->id();
|
||||
qDebug() << " Size: " << screen->size();
|
||||
qDebug() << " Position: " << screen->position();
|
||||
|
||||
#if WITH_OUTPUTS
|
||||
foreach (Output * output, screen->outputs()) {
|
||||
qDebug() << " Output: " << output->id() << "\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WITH_OUTPUTS
|
||||
qDebug() << "\nOutputs:\n";
|
||||
foreach (Output * output, Outputs::self()->outputs()) {
|
||||
qDebug() << " Output " << output->id() << ":\n";
|
||||
qDebug() << " Connected: " << output->isConnected() << "\n";
|
||||
|
||||
if (! output->isConnected()) continue;
|
||||
|
||||
qDebug() << " Activated: " << output->isActivated() << "\n";
|
||||
qDebug() << " Size: " << output->size().width() << "x" << output->size().height() << "\n";
|
||||
qDebug() << " Position: (" << output->position().x() << "," << output->position().y() << ")\n";
|
||||
qDebug() << " Vendor: " << output->vendor() << "\n";
|
||||
qDebug() << " PreferredSize: " << output->preferredSize().width() << "x" << output->preferredSize().height() << "\n";
|
||||
qDebug() << " Rotation: " << output->rotation() << "\n";
|
||||
qDebug() << " ReflectX: " << output->reflectX() << "\n";
|
||||
qDebug() << " ReflectY: " << output->reflectY() << "\n";
|
||||
qDebug() << " Rate: " << output->rate() << "\n";
|
||||
qDebug() << " Screen: " << (output->screen() ? output->screen()->id() : -1) << "\n";
|
||||
|
||||
qDebug() << "\n Available sizes: ";
|
||||
foreach (const QSize &size, output->availableSizes()) {
|
||||
qDebug() << size.width() << "x" << size.height() << ", ";
|
||||
}
|
||||
|
||||
qDebug() << "\n Available positions: ";
|
||||
foreach (const QPoint &pos, output->availablePositions()) {
|
||||
qDebug() << "(" << pos.x() << "," << pos.y() << "), ";
|
||||
}
|
||||
|
||||
qDebug() << "\n Available rates: ";
|
||||
foreach (float rate, output->availableRates()) {
|
||||
qDebug() << rate << ", ";
|
||||
}
|
||||
|
||||
qDebug() << "\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void KephalApp::qdwScreenResized(int screen)
|
||||
{
|
||||
qDebug() << " *****************";
|
||||
qDebug() << " ** QDesktopWidget:";
|
||||
qDebug() << " ** screenResized: " << screen;
|
||||
QRect geom = QApplication::desktop()->screenGeometry(screen);
|
||||
qDebug() << " ** New geometry:";
|
||||
qDebug() << " ** Size: " << geom.width() << "x" << geom.height();
|
||||
qDebug() << " ** Position: " << geom.x() << "," << geom.y();
|
||||
qDebug() << " ** isVirtual: " << QApplication::desktop()->isVirtualDesktop();
|
||||
qDebug() << " *****************";
|
||||
}
|
||||
|
||||
void KephalApp::qdwScreenCountChanged(int newCount)
|
||||
{
|
||||
qDebug() << " *****************";
|
||||
qDebug() << " ** QDesktopWidget:";
|
||||
qDebug() << " ** Screen Count Changed, now:" << newCount;
|
||||
qDebug() << " *****************";
|
||||
}
|
||||
|
||||
void KephalApp::qdwWorkAreaResized(int screen)
|
||||
{
|
||||
qDebug() << " *****************";
|
||||
qDebug() << " ** QDesktopWidget:";
|
||||
qDebug() << " ** workAreaResized: " << screen;
|
||||
QRect geom = QApplication::desktop()->availableGeometry(screen);
|
||||
qDebug() << " ** New geometry:";
|
||||
qDebug() << " ** Size: " << geom.width() << "x" << geom.height();
|
||||
qDebug() << " ** Position: (" << geom.x() << "," << geom.y();
|
||||
qDebug() << " ** isVirtual: " << (QApplication::desktop()->isVirtualDesktop() ? "true" : "false" );
|
||||
qDebug() << " *****************";
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aike J Sommer <dev@aikesommer.name>
|
||||
*
|
||||
* 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,
|
||||
* 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEPHALAPP_H
|
||||
#define KEPHALAPP_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
#include <QDesktopWidget>
|
||||
|
||||
namespace Kephal
|
||||
{
|
||||
class Screen;
|
||||
} // namespace Kephal
|
||||
|
||||
class KephalApp : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KephalApp(bool listen, int & argc, char ** argv);
|
||||
~KephalApp();
|
||||
|
||||
private:
|
||||
bool m_listen;
|
||||
QString m_arg;
|
||||
QString m_exec;
|
||||
QDesktopWidget * m_widget;
|
||||
|
||||
void query();
|
||||
|
||||
private Q_SLOTS:
|
||||
void run();
|
||||
|
||||
void screenMoved(Kephal::Screen * s, QPoint o, QPoint n);
|
||||
void screenResized(Kephal::Screen * s, QSize o, QSize n);
|
||||
void screenRemoved(int s);
|
||||
void screenAdded(Kephal::Screen * s);
|
||||
|
||||
void qdwScreenResized(int screen);
|
||||
void qdwScreenCountChanged(int newCount);
|
||||
void qdwWorkAreaResized(int screen);
|
||||
};
|
||||
|
||||
|
||||
#endif //KEPHALAPP_H
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
include_directories(${CMAKE_SOURCE_DIR}/libs
|
||||
${CMAKE_SOURCE_DIR}/libs/plasmagenericshell
|
||||
${CMAKE_SOURCE_DIR}/plasma/desktop/shell/scripting
|
||||
${CMAKE_SOURCE_DIR}/libs/kephal
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/libs
|
||||
${CMAKE_SOURCE_DIR}/libs/plasmagenericshell
|
||||
${CMAKE_SOURCE_DIR}/plasma/desktop/shell/scripting
|
||||
)
|
||||
|
||||
set(plasma_SRCS
|
||||
|
@ -11,6 +11,7 @@ set(plasma_SRCS
|
|||
controllerwindow.cpp
|
||||
desktopcorona.cpp
|
||||
desktopview.cpp
|
||||
desktoptracker.cpp
|
||||
interactiveconsole.cpp
|
||||
main.cpp
|
||||
supportinformation.cpp
|
||||
|
@ -37,7 +38,7 @@ add_executable(plasma-desktop ${plasma_SRCS})
|
|||
target_link_libraries(plasma-desktop ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KIDLETIME_LIBS} ${QT_QTSCRIPT_LIBRARY} kworkspace plasmagenericshell ${QT_QTDECLARATIVE_LIBRARY})
|
||||
|
||||
if(UNIX AND Q_WS_X11)
|
||||
target_link_libraries(plasma-desktop ${X11_LIBRARIES} kephal)
|
||||
target_link_libraries(plasma-desktop ${X11_LIBRARIES})
|
||||
|
||||
if(X11_Xrender_FOUND)
|
||||
target_link_libraries(plasma-desktop ${X11_Xrender_LIB})
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDir>
|
||||
#include <QGraphicsLayout>
|
||||
#include <QTimer>
|
||||
|
@ -43,8 +44,6 @@
|
|||
#include <Plasma/DataEngineManager>
|
||||
#include <Plasma/Package>
|
||||
|
||||
#include <kephal/screens.h>
|
||||
|
||||
#include "panelview.h"
|
||||
#include "plasmaapp.h"
|
||||
#include "plasma-shell-desktop.h"
|
||||
|
@ -72,8 +71,8 @@ void DesktopCorona::init()
|
|||
setPreferredToolBoxPlugin(Plasma::Containment::CustomPanelContainment, "org.kde.paneltoolbox");
|
||||
|
||||
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init start" << "(line:" << __LINE__ << ")";
|
||||
Kephal::Screens *screens = Kephal::Screens::self();
|
||||
connect(screens, SIGNAL(screenAdded(Kephal::Screen*)), SLOT(screenAdded(Kephal::Screen*)));
|
||||
DesktopTracker *tracker = DesktopTracker::self();
|
||||
connect(tracker, SIGNAL(screenAdded(DesktopTracker::Screen)), SLOT(screenAdded(DesktopTracker::Screen)));
|
||||
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SIGNAL(availableScreenRegionChanged()));
|
||||
|
||||
Plasma::ContainmentActionsPluginsConfig desktopPlugins;
|
||||
|
@ -180,7 +179,7 @@ int DesktopCorona::numScreens() const
|
|||
}
|
||||
#endif
|
||||
|
||||
return Kephal::ScreenUtils::numScreens();
|
||||
return QApplication::desktop()->screenCount();
|
||||
}
|
||||
|
||||
QRect DesktopCorona::screenGeometry(int id) const
|
||||
|
@ -197,7 +196,7 @@ QRect DesktopCorona::screenGeometry(int id) const
|
|||
}
|
||||
#endif
|
||||
|
||||
return Kephal::ScreenUtils::screenGeometry(id);
|
||||
return QApplication::desktop()->screenGeometry(id);
|
||||
}
|
||||
|
||||
QRegion DesktopCorona::availableScreenRegion(int id) const
|
||||
|
@ -215,7 +214,7 @@ QRegion DesktopCorona::availableScreenRegion(int id) const
|
|||
#endif
|
||||
|
||||
if (id < 0) {
|
||||
id = Kephal::ScreenUtils::primaryScreenId();
|
||||
id = QApplication::desktop()->primaryScreen();
|
||||
}
|
||||
|
||||
QRegion r(screenGeometry(id));
|
||||
|
@ -231,7 +230,7 @@ QRegion DesktopCorona::availableScreenRegion(int id) const
|
|||
QRect DesktopCorona::availableScreenRect(int id) const
|
||||
{
|
||||
if (id < 0) {
|
||||
id = Kephal::ScreenUtils::primaryScreenId();
|
||||
id = QApplication::desktop()->primaryScreen();
|
||||
}
|
||||
|
||||
QRect r(screenGeometry(id));
|
||||
|
@ -282,7 +281,7 @@ int DesktopCorona::screenId(const QPoint &pos) const
|
|||
}
|
||||
#endif
|
||||
|
||||
return Kephal::ScreenUtils::screenId(pos);
|
||||
return QApplication::desktop()->screenNumber(pos);
|
||||
}
|
||||
|
||||
void DesktopCorona::evaluateScripts(const QStringList &scripts, bool isStartup)
|
||||
|
@ -345,10 +344,10 @@ Plasma::Applet *DesktopCorona::loadDefaultApplet(const QString &pluginName, Plas
|
|||
return applet;
|
||||
}
|
||||
|
||||
void DesktopCorona::screenAdded(Kephal::Screen *s)
|
||||
void DesktopCorona::screenAdded(const DesktopTracker::Screen &screen)
|
||||
{
|
||||
kDebug() << s->id();
|
||||
checkScreen(s->id());
|
||||
kDebug() << screen.id;
|
||||
checkScreen(screen.id);
|
||||
}
|
||||
|
||||
void DesktopCorona::populateAddPanelsMenu()
|
||||
|
@ -407,7 +406,7 @@ void DesktopCorona::addPanel(const QString &plugin)
|
|||
panel->showConfigurationInterface();
|
||||
|
||||
//Fall back to the cursor position since we don't know what is the originating containment
|
||||
const int screen = Kephal::ScreenUtils::screenId(QCursor::pos());
|
||||
const int screen = QApplication::desktop()->screenNumber(QCursor::pos());
|
||||
|
||||
panel->setScreen(screen);
|
||||
|
||||
|
|
|
@ -26,15 +26,13 @@
|
|||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include "desktoptracker.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class Applet;
|
||||
} // namespace Plasma
|
||||
|
||||
namespace Kephal {
|
||||
class Screen;
|
||||
} // namespace Kephal
|
||||
|
||||
/**
|
||||
* @short A Corona with desktop-y considerations
|
||||
*/
|
||||
|
@ -72,7 +70,7 @@ public Q_SLOTS:
|
|||
void evaluateScripts(const QStringList &scripts, bool isStartup = true);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void screenAdded(Kephal::Screen *s);
|
||||
void screenAdded(const DesktopTracker::Screen &screen);
|
||||
void saveDefaultSetup();
|
||||
void printScriptError(const QString &error);
|
||||
void printScriptMessage(const QString &error);
|
||||
|
|
119
plasma/shells/plasma-desktop/desktoptracker.cpp
Normal file
119
plasma/shells/plasma-desktop/desktoptracker.cpp
Normal file
|
@ -0,0 +1,119 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "desktoptracker.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <KDebug>
|
||||
|
||||
Q_GLOBAL_STATIC(DesktopTracker, globaldesktoptracker);
|
||||
|
||||
DesktopTracker::Screen::Screen()
|
||||
: id(-1)
|
||||
{
|
||||
}
|
||||
|
||||
DesktopTracker::DesktopTracker(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) {
|
||||
DesktopTracker::Screen screen;
|
||||
screen.id = i;
|
||||
screen.geom = QApplication::desktop()->screenGeometry(i);
|
||||
screen.position = screen.geom.topLeft();
|
||||
m_screens.append(screen);
|
||||
}
|
||||
qStableSort(m_screens);
|
||||
|
||||
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(slotResized(int)));
|
||||
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(slotScreenCountChanged(int)));
|
||||
}
|
||||
|
||||
DesktopTracker* DesktopTracker::self()
|
||||
{
|
||||
return globaldesktoptracker();
|
||||
}
|
||||
|
||||
QRect DesktopTracker::desktopGeometry()
|
||||
{
|
||||
QRect desktopgeom;
|
||||
foreach (const DesktopTracker::Screen &screen, self()->screens()) {
|
||||
desktopgeom |= screen.geom;
|
||||
}
|
||||
return desktopgeom;
|
||||
}
|
||||
|
||||
DesktopTracker::Screen DesktopTracker::primaryScreen() const
|
||||
{
|
||||
const int primaryscreen = QApplication::desktop()->primaryScreen();
|
||||
foreach (const DesktopTracker::Screen &screen, screens()) {
|
||||
if (screen.id == primaryscreen) {
|
||||
return screen;
|
||||
}
|
||||
}
|
||||
kDebug() << "No primary screen";
|
||||
return DesktopTracker::Screen();
|
||||
}
|
||||
|
||||
QList<DesktopTracker::Screen> DesktopTracker::screens() const
|
||||
{
|
||||
return m_screens;
|
||||
}
|
||||
|
||||
void DesktopTracker::slotResized(int screennumber)
|
||||
{
|
||||
for (int i = 0; i < m_screens.size(); i++) {
|
||||
DesktopTracker::Screen screen = m_screens.at(i);
|
||||
if (screen.id == screennumber) {
|
||||
const QPoint oldposition = screen.position;
|
||||
screen.geom = QApplication::desktop()->screenGeometry(screen.id);
|
||||
screen.position = screen.geom.topLeft();
|
||||
m_screens.removeAt(i);
|
||||
m_screens.append(screen);
|
||||
qStableSort(m_screens);
|
||||
emit screenResized(screen);
|
||||
if (oldposition != screen.position) {
|
||||
emit screenMoved(screen);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
kDebug() << "Untracked screen resized" << screennumber;
|
||||
}
|
||||
|
||||
void DesktopTracker::slotScreenCountChanged(int count)
|
||||
{
|
||||
// this is bogus but it is how kephal did it
|
||||
for (int i = m_screens.size(); i < count; i++) {
|
||||
DesktopTracker::Screen screen;
|
||||
screen.id = i;
|
||||
screen.geom = QApplication::desktop()->screenGeometry(i);
|
||||
screen.position = screen.geom.topLeft();
|
||||
m_screens.append(screen);
|
||||
qStableSort(m_screens);
|
||||
emit screenAdded(screen);
|
||||
}
|
||||
|
||||
while (m_screens.size() > count) {
|
||||
DesktopTracker::Screen screen = m_screens.takeLast();
|
||||
emit screenRemoved(screen);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_desktoptracker.cpp"
|
68
plasma/shells/plasma-desktop/desktoptracker.h
Normal file
68
plasma/shells/plasma-desktop/desktoptracker.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef DESKTOPTRACKER_H
|
||||
#define DESKTOPTRACKER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
class DesktopTracker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class Screen
|
||||
{
|
||||
public:
|
||||
Screen();
|
||||
|
||||
int id;
|
||||
QRect geom;
|
||||
QPoint position;
|
||||
|
||||
bool operator==(const Screen &other) const
|
||||
{ return id == other.id && geom == other.geom && position == other.position; }
|
||||
|
||||
bool operator<(const Screen &other) const
|
||||
{ return id < other.id; }
|
||||
};
|
||||
|
||||
DesktopTracker(QObject *parent = nullptr);
|
||||
|
||||
static DesktopTracker* self();
|
||||
|
||||
static QRect desktopGeometry();
|
||||
|
||||
DesktopTracker::Screen primaryScreen() const;
|
||||
QList<DesktopTracker::Screen> screens() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void screenResized(DesktopTracker::Screen screen);
|
||||
void screenAdded(DesktopTracker::Screen screen);
|
||||
void screenMoved(DesktopTracker::Screen screen);
|
||||
void screenRemoved(DesktopTracker::Screen screen);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotResized(int screennumber);
|
||||
void slotScreenCountChanged(int count);
|
||||
|
||||
private:
|
||||
QList<DesktopTracker::Screen> m_screens;
|
||||
};
|
||||
|
||||
#endif // DESKTOPTRACKER_H
|
|
@ -37,8 +37,6 @@
|
|||
#include <Plasma/Wallpaper>
|
||||
#include <Plasma/Theme>
|
||||
|
||||
#include <kephal/screens.h>
|
||||
|
||||
#include "desktopcorona.h"
|
||||
#include "plasmaapp.h"
|
||||
#include "plasma-shell-desktop.h"
|
||||
|
@ -90,11 +88,11 @@ DesktopView::DesktopView(Plasma::Containment *containment, int id, QWidget *pare
|
|||
setGeometry(geom);
|
||||
}
|
||||
|
||||
Kephal::Screens *screens = Kephal::Screens::self();
|
||||
connect(screens, SIGNAL(screenResized(Kephal::Screen*,QSize,QSize)),
|
||||
this, SLOT(screenResized(Kephal::Screen*)));
|
||||
connect(screens, SIGNAL(screenMoved(Kephal::Screen*,QPoint,QPoint)),
|
||||
this, SLOT(screenMoved(Kephal::Screen*)));
|
||||
DesktopTracker *tracker = DesktopTracker::self();
|
||||
connect(tracker, SIGNAL(screenResized(DesktopTracker::Screen)),
|
||||
this, SLOT(screenResized(DesktopTracker::Screen)));
|
||||
connect(tracker, SIGNAL(screenMoved(DesktopTracker::Screen)),
|
||||
this, SLOT(screenMoved(DesktopTracker::Screen)));
|
||||
}
|
||||
|
||||
DesktopView::~DesktopView()
|
||||
|
@ -106,17 +104,17 @@ void DesktopView::checkDesktopAffiliation()
|
|||
KWindowSystem::setOnAllDesktops(winId(), true);
|
||||
}
|
||||
|
||||
void DesktopView::screenResized(Kephal::Screen *s)
|
||||
void DesktopView::screenResized(const DesktopTracker::Screen &s)
|
||||
{
|
||||
if (s->id() == screen()) {
|
||||
if (s.id == screen()) {
|
||||
kDebug() << screen();
|
||||
adjustSize();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopView::screenMoved(Kephal::Screen *s)
|
||||
void DesktopView::screenMoved(const DesktopTracker::Screen &s)
|
||||
{
|
||||
if (s->id() == screen()) {
|
||||
if (s.id == screen()) {
|
||||
kDebug() << screen();
|
||||
adjustSize();
|
||||
}
|
||||
|
|
|
@ -23,16 +23,13 @@
|
|||
#include <Plasma/Plasma>
|
||||
#include <Plasma/View>
|
||||
|
||||
#include "desktoptracker.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class Containment;
|
||||
} // namespace Plasma
|
||||
|
||||
namespace Kephal
|
||||
{
|
||||
class Screen;
|
||||
} // namespace Kephal
|
||||
|
||||
class DesktopView : public Plasma::View
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -47,8 +44,8 @@ public:
|
|||
void checkDesktopAffiliation();
|
||||
|
||||
public slots:
|
||||
void screenResized(Kephal::Screen *);
|
||||
void screenMoved(Kephal::Screen *);
|
||||
void screenResized(const DesktopTracker::Screen &screen);
|
||||
void screenMoved(const DesktopTracker::Screen &screen);
|
||||
void adjustSize();
|
||||
void toolBoxOpened(bool);
|
||||
void showDesktopUntoggled(WId id);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "panelview.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QTimer>
|
||||
|
@ -41,9 +42,8 @@
|
|||
#include <Plasma/Theme>
|
||||
#include <Plasma/WindowEffects>
|
||||
|
||||
#include <kephal/screens.h>
|
||||
|
||||
#include "desktopcorona.h"
|
||||
#include "desktoptracker.h"
|
||||
#include "panelappletoverlay.h"
|
||||
#include "panelcontroller.h"
|
||||
#include "panelshadows.h"
|
||||
|
@ -261,12 +261,12 @@ PanelView::PanelView(Plasma::Containment *panel, int id, QWidget *parent)
|
|||
|
||||
connect(this, SIGNAL(sceneRectAboutToChange()), this, SLOT(pinchContainmentToCurrentScreen()));
|
||||
|
||||
Kephal::Screens *screens = Kephal::Screens::self();
|
||||
connect(screens, SIGNAL(screenResized(Kephal::Screen*,QSize,QSize)),
|
||||
connect(QApplication::desktop(), SIGNAL(resized(int)),
|
||||
this, SLOT(pinchContainmentToCurrentScreen()));
|
||||
connect(screens, SIGNAL(screenMoved(Kephal::Screen*,QPoint,QPoint)),
|
||||
DesktopTracker *tracker = DesktopTracker::self();
|
||||
connect(tracker, SIGNAL(screenMoved(DesktopTracker::Screen)),
|
||||
this, SLOT(updatePanelGeometry()));
|
||||
connect(screens, SIGNAL(screenAdded(Kephal::Screen*)),
|
||||
connect(tracker, SIGNAL(screenAdded(DesktopTracker::Screen)),
|
||||
this, SLOT(updateStruts()));
|
||||
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()), Qt::QueuedConnection);
|
||||
}
|
||||
|
@ -968,7 +968,7 @@ void PanelView::updateStruts()
|
|||
|
||||
if (m_visibilityMode == NormalPanel) {
|
||||
const QRect thisScreen = PlasmaApp::self()->corona()->screenGeometry(containment()->screen());
|
||||
const QRect wholeScreen = Kephal::ScreenUtils::desktopGeometry();
|
||||
const QRect wholeScreen = DesktopTracker::desktopGeometry();
|
||||
|
||||
//Extended struts against a screen edge near to another screen are really harmful, so windows maximized under the panel is a lesser pain
|
||||
//TODO: force "windows can cover" in those cases?
|
||||
|
|
|
@ -65,8 +65,6 @@
|
|||
#include <Plasma/Wallpaper>
|
||||
#include <Plasma/WindowEffects>
|
||||
|
||||
#include <kephal/screens.h>
|
||||
|
||||
#include <plasmagenericshell/backgrounddialog.h>
|
||||
|
||||
#include "appadaptor.h"
|
||||
|
@ -141,12 +139,11 @@ PlasmaApp::PlasmaApp()
|
|||
XCloseDisplay(dpy);
|
||||
}
|
||||
#endif
|
||||
const QSize size = Kephal::ScreenUtils::screenSize(id);
|
||||
const QSize size = QApplication::desktop()->screenGeometry(id).size();
|
||||
cacheSize += 4 * size.width() * size.height() / 1024;
|
||||
} else {
|
||||
const int numScreens = Kephal::ScreenUtils::numScreens();
|
||||
for (int i = 0; i < numScreens; i++) {
|
||||
QSize size = Kephal::ScreenUtils::screenSize(i);
|
||||
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) {
|
||||
QSize size = QApplication::desktop()->screenGeometry(i).size();
|
||||
cacheSize += 4 * size.width() * size.height() / 1024;
|
||||
}
|
||||
}
|
||||
|
@ -232,9 +229,9 @@ void PlasmaApp::setupDesktop()
|
|||
// this line initializes the corona.
|
||||
corona();
|
||||
|
||||
Kephal::Screens *screens = Kephal::Screens::self();
|
||||
connect(screens, SIGNAL(screenRemoved(int)), SLOT(screenRemoved(int)));
|
||||
connect(screens, SIGNAL(screenAdded(Kephal::Screen*)), SLOT(screenAdded(Kephal::Screen*)));
|
||||
DesktopTracker *tracker = DesktopTracker::self();
|
||||
connect(tracker, SIGNAL(screenRemoved(DesktopTracker::Screen)), SLOT(screenRemoved(DesktopTracker::Screen)));
|
||||
connect(tracker, SIGNAL(screenAdded(DesktopTracker::Screen)), SLOT(screenAdded(DesktopTracker::Screen)));
|
||||
|
||||
// free the memory possibly occupied by the background image of the
|
||||
// root window - login managers will typically set one
|
||||
|
@ -514,16 +511,16 @@ bool PlasmaApp::x11EventFilter(XEvent *event)
|
|||
}
|
||||
#endif
|
||||
|
||||
void PlasmaApp::screenRemoved(int id)
|
||||
void PlasmaApp::screenRemoved(const DesktopTracker::Screen &screen)
|
||||
{
|
||||
kDebug() << "@@@@" << id;
|
||||
kDebug() << "@@@@" << screen.id;
|
||||
QMutableListIterator<DesktopView *> it(m_desktops);
|
||||
while (it.hasNext()) {
|
||||
DesktopView *view = it.next();
|
||||
if (view->screen() == id) {
|
||||
if (view->screen() == screen.id) {
|
||||
// the screen was removed, so we'll destroy the
|
||||
// corresponding view
|
||||
kDebug() << "@@@@removing the view for screen" << id;
|
||||
kDebug() << "@@@@removing the view for screen" << screen.id;
|
||||
view->setContainment(0);
|
||||
it.remove();
|
||||
delete view;
|
||||
|
@ -538,8 +535,8 @@ void PlasmaApp::screenRemoved(int id)
|
|||
NOTE: CURRENTLY UNSAFE DUE TO HOW KEPHAL (or rather, it seems, Qt?) PROCESSES EVENTS
|
||||
DURING XRANDR EVENTS. REVISIT IN 4.8!
|
||||
*/
|
||||
Kephal::Screen *primary = Kephal::Screens::self()->primaryScreen();
|
||||
QList<Kephal::Screen *> screens = Kephal::Screens::self()->screens();
|
||||
const DesktopTracker::Screen primary = DesktopTracker::self()->primaryScreen();
|
||||
QList<DesktopTracker::Screen> screens = DesktopTracker::self()->screens();
|
||||
screens.removeAll(primary);
|
||||
|
||||
// Now we process panels: if there is room on another screen for the panel,
|
||||
|
@ -548,12 +545,12 @@ void PlasmaApp::screenRemoved(int id)
|
|||
QMutableListIterator<PanelView*> pIt(m_panels);
|
||||
while (pIt.hasNext()) {
|
||||
PanelView *panel = pIt.next();
|
||||
if (panel->screen() == id) {
|
||||
Kephal::Screen *moveTo = 0;
|
||||
if (panel->screen() == screen.id) {
|
||||
DesktopTracker::Screen moveTo;
|
||||
if (canRelocatePanel(panel, primary)) {
|
||||
moveTo = primary;
|
||||
} else {
|
||||
foreach (Kephal::Screen *screen, screens) {
|
||||
foreach (const DesktopTracker::Screen &screen, screens) {
|
||||
if (canRelocatePanel(panel, screen)) {
|
||||
moveTo = screen;
|
||||
break;
|
||||
|
@ -561,8 +558,8 @@ void PlasmaApp::screenRemoved(int id)
|
|||
}
|
||||
}
|
||||
|
||||
if (moveTo) {
|
||||
panel->migrateTo(moveTo->id());
|
||||
if (moveTo.id >= 0) {
|
||||
panel->migrateTo(moveTo.id);
|
||||
} else {
|
||||
pIt.remove();
|
||||
delete panel;
|
||||
|
@ -576,7 +573,7 @@ void PlasmaApp::screenRemoved(int id)
|
|||
QMutableListIterator<PanelView*> pIt(m_panels);
|
||||
while (pIt.hasNext()) {
|
||||
PanelView *panel = pIt.next();
|
||||
if (panel->screen() == id) {
|
||||
if (panel->screen() == screen.id) {
|
||||
pIt.remove();
|
||||
delete panel;
|
||||
}
|
||||
|
@ -584,55 +581,55 @@ void PlasmaApp::screenRemoved(int id)
|
|||
#endif
|
||||
}
|
||||
|
||||
void PlasmaApp::screenAdded(Kephal::Screen *screen)
|
||||
void PlasmaApp::screenAdded(const DesktopTracker::Screen &screen)
|
||||
{
|
||||
foreach (Plasma::Containment *containment, corona()->containments()) {
|
||||
if (isPanelContainment(containment) && containment->screen() == screen->id()) {
|
||||
if (isPanelContainment(containment) && containment->screen() == screen.id) {
|
||||
m_panelsWaiting << containment;
|
||||
m_panelViewCreationTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PanelView *view, m_panels) {
|
||||
if (view->migratedFrom(screen->id())) {
|
||||
view->migrateTo(screen->id());
|
||||
if (view->migratedFrom(screen.id)) {
|
||||
view->migrateTo(screen.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PlasmaApp::canRelocatePanel(PanelView * view, Kephal::Screen *screen)
|
||||
bool PlasmaApp::canRelocatePanel(PanelView * view, const DesktopTracker::Screen &screen)
|
||||
{
|
||||
if (!screen || !view->containment()) {
|
||||
if (!view->containment()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QRect newGeom = view->geometry();
|
||||
switch (view->location()) {
|
||||
case Plasma::TopEdge:
|
||||
newGeom.setY(screen->geom().y());
|
||||
newGeom.setY(screen.geom.y());
|
||||
newGeom.setX(view->offset());
|
||||
break;
|
||||
case Plasma::BottomEdge:
|
||||
newGeom.setY(screen->geom().bottom() - newGeom.height());
|
||||
newGeom.setY(screen.geom.bottom() - newGeom.height());
|
||||
newGeom.setX(view->offset());
|
||||
break;
|
||||
case Plasma::LeftEdge:
|
||||
newGeom.setX(screen->geom().left());
|
||||
newGeom.setX(screen.geom.left());
|
||||
newGeom.setY(view->offset());
|
||||
break;
|
||||
case Plasma::RightEdge:
|
||||
newGeom.setX(screen->geom().right() - newGeom.width());
|
||||
newGeom.setX(screen.geom.right() - newGeom.width());
|
||||
newGeom.setY(view->offset());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
kDebug() << "testing:" << screen->id() << view << view->geometry() << view->location() << newGeom;
|
||||
kDebug() << "testing:" << screen.id << view << view->geometry() << view->location() << newGeom;
|
||||
foreach (PanelView *pv, m_panels) {
|
||||
kDebug() << pv << pv->screen() << pv->screen() << pv->location() << pv->geometry();
|
||||
if (pv != view &&
|
||||
pv->screen() == screen->id() &&
|
||||
pv->screen() == screen.id &&
|
||||
pv->location() == view->location() &&
|
||||
pv->geometry().intersects(newGeom)) {
|
||||
return false;
|
||||
|
@ -828,8 +825,8 @@ void PlasmaApp::relocatePanels()
|
|||
{
|
||||
// we go through relocatables last so that all other panels can be set up first,
|
||||
// preventing panel creation ordering to trip up the canRelocatePanel algorithm
|
||||
Kephal::Screen *primary = Kephal::Screens::self()->primaryScreen();
|
||||
QList<Kephal::Screen *> screens = Kephal::Screens::self()->screens();
|
||||
const DesktopTracker::Screen primary = DesktopTracker::self()->primaryScreen();
|
||||
QList<DesktopTracker::Screen> screens = DesktopTracker::self()->screens();
|
||||
screens.removeAll(primary);
|
||||
|
||||
foreach (QWeakPointer<Plasma::Containment> c, m_panelRelocationCandidates) {
|
||||
|
@ -838,12 +835,12 @@ void PlasmaApp::relocatePanels()
|
|||
continue;
|
||||
}
|
||||
|
||||
Kephal::Screen *moveTo = 0;
|
||||
DesktopTracker::Screen moveTo;
|
||||
PanelView *panelView = createPanelView(containment);
|
||||
if (canRelocatePanel(panelView, primary)) {
|
||||
moveTo = primary;
|
||||
} else {
|
||||
foreach (Kephal::Screen *screen, screens) {
|
||||
foreach (const DesktopTracker::Screen &screen, screens) {
|
||||
if (canRelocatePanel(panelView, screen)) {
|
||||
moveTo = screen;
|
||||
break;
|
||||
|
@ -851,8 +848,8 @@ void PlasmaApp::relocatePanels()
|
|||
}
|
||||
}
|
||||
|
||||
if (moveTo) {
|
||||
panelView->migrateTo(moveTo->id());
|
||||
if (moveTo.id >= 0) {
|
||||
panelView->migrateTo(moveTo.id);
|
||||
} else {
|
||||
m_panels.removeAll(panelView);
|
||||
delete panelView;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#include <QSignalMapper>
|
||||
|
||||
#include "desktoptracker.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class AccessAppletJob;
|
||||
|
@ -44,10 +46,6 @@ namespace Plasma
|
|||
class Dialog;
|
||||
} // namespace Plasma
|
||||
|
||||
namespace Kephal {
|
||||
class Screen;
|
||||
} // namespace Kephal
|
||||
|
||||
class ControllerWindow;
|
||||
class DesktopView;
|
||||
class DesktopCorona;
|
||||
|
@ -121,7 +119,7 @@ private:
|
|||
PlasmaApp();
|
||||
DesktopView* viewForScreen(int screen, int desktop) const;
|
||||
ControllerWindow *showController(int screen, Plasma::Containment *c, bool widgetExplorerMode);
|
||||
bool canRelocatePanel(PanelView * view, Kephal::Screen *screen);
|
||||
bool canRelocatePanel(PanelView * view, const DesktopTracker::Screen &screen);
|
||||
PanelView *createPanelView(Plasma::Containment *containment);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
@ -131,8 +129,8 @@ private Q_SLOTS:
|
|||
void containmentScreenOwnerChanged(int, int, Plasma::Containment*);
|
||||
void syncConfig();
|
||||
void panelRemoved(QObject* panel);
|
||||
void screenRemoved(int id);
|
||||
void screenAdded(Kephal::Screen *screen);
|
||||
void screenRemoved(const DesktopTracker::Screen &screen);
|
||||
void screenAdded(const DesktopTracker::Screen &screen);
|
||||
void configureContainment(Plasma::Containment*);
|
||||
void setWmClass(WId id);
|
||||
void wallpaperCheckedIn();
|
||||
|
|
Loading…
Add table
Reference in a new issue