Advance KWin Wayland port for Red Bear desktop session
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -6,7 +6,28 @@
|
||||
*/
|
||||
#include "orientationsensor.h"
|
||||
|
||||
#include "qorientationreading_compat.h"
|
||||
|
||||
#if __has_include(<QOrientationSensor>)
|
||||
#include <QOrientationSensor>
|
||||
#define KWIN_HAVE_QT_ORIENTATION_SENSOR 1
|
||||
#else
|
||||
#define KWIN_HAVE_QT_ORIENTATION_SENSOR 0
|
||||
class QOrientationSensor : public QObject
|
||||
{
|
||||
public:
|
||||
using QObject::QObject;
|
||||
|
||||
QOrientationReading *reading() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void start()
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
@@ -22,6 +43,7 @@ OrientationSensor::~OrientationSensor() = default;
|
||||
|
||||
void OrientationSensor::setEnabled(bool enable)
|
||||
{
|
||||
#if KWIN_HAVE_QT_ORIENTATION_SENSOR
|
||||
if (enable) {
|
||||
connect(m_sensor.get(), &QOrientationSensor::readingChanged, this, &OrientationSensor::update, Qt::UniqueConnection);
|
||||
m_sensor->start();
|
||||
@@ -29,6 +51,10 @@ void OrientationSensor::setEnabled(bool enable)
|
||||
disconnect(m_sensor.get(), &QOrientationSensor::readingChanged, this, &OrientationSensor::update);
|
||||
m_reading->setOrientation(QOrientationReading::Undefined);
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(enable)
|
||||
m_reading->setOrientation(QOrientationReading::Undefined);
|
||||
#endif
|
||||
}
|
||||
|
||||
QOrientationReading *OrientationSensor::reading() const
|
||||
@@ -38,6 +64,7 @@ QOrientationReading *OrientationSensor::reading() const
|
||||
|
||||
void OrientationSensor::update()
|
||||
{
|
||||
#if KWIN_HAVE_QT_ORIENTATION_SENSOR
|
||||
if (auto reading = m_sensor->reading()) {
|
||||
if (m_reading->orientation() != reading->orientation()) {
|
||||
m_reading->setOrientation(reading->orientation());
|
||||
@@ -47,6 +74,7 @@ void OrientationSensor::update()
|
||||
m_reading->setOrientation(QOrientationReading::Orientation::Undefined);
|
||||
Q_EMIT orientationChanged();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<QOrientationReading>)
|
||||
#include <QOrientationReading>
|
||||
#else
|
||||
class QOrientationReading
|
||||
{
|
||||
public:
|
||||
enum Orientation {
|
||||
TopUp,
|
||||
TopDown,
|
||||
LeftUp,
|
||||
RightUp,
|
||||
FaceUp,
|
||||
FaceDown,
|
||||
Undefined,
|
||||
};
|
||||
|
||||
QOrientationReading() = default;
|
||||
|
||||
Orientation orientation() const
|
||||
{
|
||||
return m_orientation;
|
||||
}
|
||||
|
||||
void setOrientation(Orientation orientation)
|
||||
{
|
||||
m_orientation = orientation;
|
||||
}
|
||||
|
||||
private:
|
||||
Orientation m_orientation = Undefined;
|
||||
};
|
||||
#endif
|
||||
@@ -78,14 +78,18 @@ RamFile::RamFile(const char *name, const void *inData, int size, RamFile::Flags
|
||||
m_tmp->unmap(data);
|
||||
#endif
|
||||
|
||||
#if defined(F_SEAL_SHRINK) && defined(F_SEAL_GROW) && defined(F_SEAL_SEAL) && defined(F_ADD_SEALS)
|
||||
int seals = F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_SEAL;
|
||||
if (flags.testFlag(RamFile::Flag::SealWrite)) {
|
||||
#if defined(F_SEAL_WRITE)
|
||||
seals |= F_SEAL_WRITE;
|
||||
#endif
|
||||
}
|
||||
// This can fail for QTemporaryFile based on the underlying file system.
|
||||
if (fcntl(fd(), F_ADD_SEALS, seals) != 0) {
|
||||
qCDebug(KWIN_CORE).nospace() << name << ": Failed to seal RamFile: " << strerror(errno);
|
||||
}
|
||||
#endif
|
||||
|
||||
guard.dismiss();
|
||||
}
|
||||
@@ -137,12 +141,16 @@ RamFile::Flags RamFile::effectiveFlags() const
|
||||
{
|
||||
Flags flags = {};
|
||||
|
||||
#if defined(F_GET_SEALS) && defined(F_SEAL_WRITE)
|
||||
const int seals = fcntl(fd(), F_GET_SEALS);
|
||||
if (seals > 0) {
|
||||
if (seals & F_SEAL_WRITE) {
|
||||
flags.setFlag(Flag::SealWrite);
|
||||
}
|
||||
}
|
||||
#else
|
||||
flags = m_flags;
|
||||
#endif
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user