diff options
author | wi <william.os4y@gmail.com> | 2015-04-20 21:53:25 +0200 |
---|---|---|
committer | wi <william.os4y@gmail.com> | 2015-04-20 21:53:25 +0200 |
commit | a33566d53dab6f5bf3d4b6663014b6b548446525 (patch) | |
tree | 6e57deaa6afc289cb6a51a523e2fb1530830bd9c /libLumina | |
parent | This is a complete adaptation of lumina-fileinfo. (diff) | |
parent | Add a special flag to prevent the lumina-open crash handler from starting up ... (diff) | |
download | lumina-a33566d53dab6f5bf3d4b6663014b6b548446525.tar.gz lumina-a33566d53dab6f5bf3d4b6663014b6b548446525.tar.bz2 lumina-a33566d53dab6f5bf3d4b6663014b6b548446525.zip |
Merge remote-tracking branch 'upstream/master' into deskEditor
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaOS-Debian.cpp | 10 | ||||
-rw-r--r-- | libLumina/LuminaOS-DragonFly.cpp | 10 | ||||
-rw-r--r-- | libLumina/LuminaOS-FreeBSD.cpp | 24 | ||||
-rw-r--r-- | libLumina/LuminaOS-Linux.cpp | 10 | ||||
-rw-r--r-- | libLumina/LuminaOS-OpenBSD.cpp | 10 | ||||
-rw-r--r-- | libLumina/LuminaOS-kFreeBSD.cpp | 10 | ||||
-rw-r--r-- | libLumina/LuminaOS-template.cpp | 10 | ||||
-rw-r--r-- | libLumina/LuminaOS.h | 5 | ||||
-rw-r--r-- | libLumina/LuminaX11.cpp | 14 | ||||
-rw-r--r-- | libLumina/LuminaX11.h | 2 | ||||
-rw-r--r-- | libLumina/libLumina.pro | 19 |
11 files changed, 114 insertions, 10 deletions
diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp index 7ce8250f..a7be653c 100644 --- a/libLumina/LuminaOS-Debian.cpp +++ b/libLumina/LuminaOS-Debian.cpp @@ -152,6 +152,16 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -r now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + return false; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + +} + //Battery Availability bool LOS::hasBattery(){ QString my_status = LUtils::getCmdOutput("acpi -b").join(""); diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp index b9ba58a2..57ff1b2a 100644 --- a/libLumina/LuminaOS-DragonFly.cpp +++ b/libLumina/LuminaOS-DragonFly.cpp @@ -148,6 +148,16 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -r now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + return false; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + +} + //Battery Availability bool LOS::hasBattery(){ int val = LUtils::getCmdOutput("apm -l").join("").toInt(); diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index 73637048..c9874605 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -8,6 +8,7 @@ #include "LuminaOS.h" #include <unistd.h> +#include <QDebug> //can't read xbrightness settings - assume invalid until set static int screenbrightness = -1; @@ -71,17 +72,18 @@ void LOS::setScreenBrightness(int percent){ //ensure bounds if(percent<0){percent=0;} else if(percent>100){ percent=100; } - float pf = percent/100.0; //convert to a decimel //Run the command(s) bool success = false; // - try hardware setting first (PC-BSD only) if(QFile::exists("/usr/local/bin/pc-sysconfig")){ - QString ret = LUtils::getCmdOutput("pc-sysconfig \"setscreenbrightness "+QString::number(percent)+"\"").join(""); - success = (ret.simplified() == "[SUCCESS]"); + QString ret = LUtils::getCmdOutput("pc-sysconfig", QStringList() <<"setscreenbrightness "+QString::number(percent)).join(""); + success = ret.toLower().contains("success"); + qDebug() << "Set hardware brightness:" << percent << success; } // - if hardware brightness does not work, use software brightness if(!success){ QString cmd = "xbrightness %1"; + float pf = percent/100.0; //convert to a decimel cmd = cmd.arg( QString::number( int(65535*pf) ) ); success = (0 == LUtils::runCmd(cmd) ); } @@ -169,6 +171,22 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -ro now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + //This will only function on PC-BSD + //(permissions issues on standard FreeBSD unless setup a special way) + bool ok = QFile::exists("/usr/local/bin/pc-sysconfig"); + if(ok){ + ok = LUtils::getCmdOutput("pc-sysconfig systemcansuspend").join("").toLower().contains("true"); + } + return ok; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + QProcess::startDetached("pc-sysconfig suspendsystem"); +} + //Battery Availability bool LOS::hasBattery(){ int val = LUtils::getCmdOutput("apm -l").join("").toInt(); diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp index 46a6371a..6929c9c3 100644 --- a/libLumina/LuminaOS-Linux.cpp +++ b/libLumina/LuminaOS-Linux.cpp @@ -149,6 +149,16 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -r now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + return false; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + +} + //Battery Availability bool LOS::hasBattery(){ QString my_status = LUtils::getCmdOutput("acpi -b").join(""); diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp index df6ddeba..5fda4866 100644 --- a/libLumina/LuminaOS-OpenBSD.cpp +++ b/libLumina/LuminaOS-OpenBSD.cpp @@ -166,6 +166,16 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -r now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + return false; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + +} + //Battery Availability bool LOS::hasBattery(){ int val = LUtils::getCmdOutput("apm -b").join("").toInt(); diff --git a/libLumina/LuminaOS-kFreeBSD.cpp b/libLumina/LuminaOS-kFreeBSD.cpp index 2b24ce51..dee5a6c8 100644 --- a/libLumina/LuminaOS-kFreeBSD.cpp +++ b/libLumina/LuminaOS-kFreeBSD.cpp @@ -133,6 +133,16 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -r now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + return false; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + +} + //Battery Availability bool LOS::hasBattery(){ return false; diff --git a/libLumina/LuminaOS-template.cpp b/libLumina/LuminaOS-template.cpp index dfb9d850..aabd7da3 100644 --- a/libLumina/LuminaOS-template.cpp +++ b/libLumina/LuminaOS-template.cpp @@ -81,6 +81,16 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -r now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + return false; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + +} + //Battery Availability bool LOS::hasBattery(){ return false; //not implemented yet diff --git a/libLumina/LuminaOS.h b/libLumina/LuminaOS.h index 091a8d96..eb0e2eb6 100644 --- a/libLumina/LuminaOS.h +++ b/libLumina/LuminaOS.h @@ -71,6 +71,11 @@ public: static void systemShutdown(); //start poweroff sequence //System Restart static void systemRestart(); //start reboot sequence + //Check for suspend support + static bool systemCanSuspend(); + //Put the system into the suspend state + static void systemSuspend(); + //Battery Availability static bool hasBattery(); diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index 05a03631..89c138ca 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -27,6 +27,7 @@ #include <xcb/xcb_icccm.h> #include <xcb/xcb_image.h> #include <xcb/composite.h> +#include <xcb/damage.h> //===== WindowList() ======== @@ -1357,15 +1358,16 @@ void LXCB::MoveResizeWindow(WId win, QRect geom){ } // === EmbedWindow() === -bool LXCB::EmbedWindow(WId win, WId container){ - if(win==0 || container==0){ return false; } +uint LXCB::EmbedWindow(WId win, WId container){ + //This returns the damage control ID number (or 0 for a failure) + if(win==0 || container==0){ return 0; } //qDebug() << "Embed Window:" << win << container; //Initialize any atoms that will be needed xcb_intern_atom_cookie_t ecookie = xcb_intern_atom_unchecked(QX11Info::connection(), 0, 7, "_XEMBED"); xcb_intern_atom_reply_t *ereply = xcb_intern_atom_reply(QX11Info::connection(), ecookie, NULL); - if(ereply==0){ return false; } //unable to initialize the atom + if(ereply==0){ return 0; } //unable to initialize the atom xcb_atom_t emb = ereply->atom; free(ereply); //done with this structure @@ -1399,8 +1401,12 @@ bool LXCB::EmbedWindow(WId win, WId container){ //Now map the window (will be a transparent child of the container) xcb_map_window(QX11Info::connection(), win); + //Now create/register the damage handler + xcb_damage_damage_t dmgID = xcb_generate_id(QX11Info::connection()); //This is a typedef for a 32-bit unsigned integer + xcb_damage_create(QX11Info::connection(), dmgID, win, XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES); + //qDebug() << " - Done"; - return true; + return ( (uint) dmgID ); } // === Unembed Window() === diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h index 4ce279f4..0a950d63 100644 --- a/libLumina/LuminaX11.h +++ b/libLumina/LuminaX11.h @@ -153,7 +153,7 @@ public: void MoveResizeWindow(WId win, QRect geom); //Window Embedding/Detaching (for system tray) - bool EmbedWindow(WId win, WId container); + uint EmbedWindow(WId win, WId container); //returns the damage ID (or 0 for an error) bool UnembedWindow(WId win); }; diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro index 1b78367a..ef30bd20 100644 --- a/libLumina/libLumina.pro +++ b/libLumina/libLumina.pro @@ -36,13 +36,28 @@ SOURCES += LuminaXDG.cpp \ LuminaOS-FreeBSD.cpp \ LuminaOS-DragonFly.cpp \ LuminaOS-OpenBSD.cpp \ - LuminaOS-Linux.cpp \ LuminaOS-kFreeBSD.cpp # new OS support can be added here +# check linux distribution and use specific +# LuminaOS support functions (or fall back to +# generic one + +exists(/bin/lsb_release){ + LINUX_DISTRIBUTION = $$system(lsb_release -si) +} + +equals(LINUX_DISTRIBUTION, "Debian"): { + SOURCES += LuminaOS-Debian.cpp +} else { + SOURCES += LuminaOS-Linux.cpp +} + + + INCLUDEPATH += $$PREFIX/include -LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image -lxcb-composite +LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image -lxcb-composite -lxcb-damage include.path=$$PREFIX/include/ include.files=LuminaXDG.h \ |