From 604e48172be8fd6674f6d46f4bccd6a0c2b0bb0d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 17 Apr 2015 08:45:54 -0400 Subject: Fix the implementation of the hardware brightness control on PC-BSD. Now it works consistently. --- libLumina/LuminaOS-FreeBSD.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libLumina') diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index 73637048..430a31fc 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -8,6 +8,7 @@ #include "LuminaOS.h" #include +#include //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) ); } -- cgit From c90279a8649744171e7a24a99ace0512f41fed70 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Sun, 19 Apr 2015 19:49:11 +0200 Subject: auto-detect Debian vs. non-Debian Linux distribution --- libLumina/libLumina.pro | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libLumina') diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro index 1b78367a..8da9598c 100644 --- a/libLumina/libLumina.pro +++ b/libLumina/libLumina.pro @@ -36,10 +36,22 @@ 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 + +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 -- cgit From fbd67e202c15ffec78ad15dc9ea1ba8b6eb1b798 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Sun, 19 Apr 2015 14:19:11 -0400 Subject: Add support to LuminaOS for checking/starting the system suspend functionality. --- libLumina/LuminaOS-Debian.cpp | 10 ++++++++++ libLumina/LuminaOS-DragonFly.cpp | 10 ++++++++++ libLumina/LuminaOS-FreeBSD.cpp | 16 ++++++++++++++++ libLumina/LuminaOS-Linux.cpp | 10 ++++++++++ libLumina/LuminaOS-OpenBSD.cpp | 10 ++++++++++ libLumina/LuminaOS-kFreeBSD.cpp | 10 ++++++++++ libLumina/LuminaOS-template.cpp | 10 ++++++++++ libLumina/LuminaOS.h | 5 +++++ 8 files changed, 81 insertions(+) (limited to 'libLumina') 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 430a31fc..e294cf25 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -171,6 +171,22 @@ void LOS::systemRestart(){ //start reboot sequence QProcess::startDetached("shutdown -ro now"); } +//Check for suspend support +bool LOS::systemCanSuspend(){ + //Check the supported CPU sleep states and ensure that S3 is listed + QStringList info = LUtils::getCmdOutput("sysctl -ae").filter("hw.acpi.supported_sleep_state="); + bool ok = false; + if(!info.isEmpty()){ + ok = info.first().section("=",1,1).split(" ").contains("S3"); + } + return ok; +} + +//Put the system into the suspend state +void LOS::systemSuspend(){ + LUtils::runCmd("acpiconf -s 3"); +} + //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(); -- cgit From 1b3a24268a6b3e030550a00c0ddfdcee37db56ff Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Sun, 19 Apr 2015 15:22:37 -0400 Subject: Clean up the new suspend support in Lumina, and add it to the system "log out" menu as an option (if supported on that system). --- libLumina/LuminaOS-FreeBSD.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libLumina') diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index e294cf25..c9874605 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -173,18 +173,18 @@ void LOS::systemRestart(){ //start reboot sequence //Check for suspend support bool LOS::systemCanSuspend(){ - //Check the supported CPU sleep states and ensure that S3 is listed - QStringList info = LUtils::getCmdOutput("sysctl -ae").filter("hw.acpi.supported_sleep_state="); - bool ok = false; - if(!info.isEmpty()){ - ok = info.first().section("=",1,1).split(" ").contains("S3"); + //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(){ - LUtils::runCmd("acpiconf -s 3"); + QProcess::startDetached("pc-sysconfig suspendsystem"); } //Battery Availability -- cgit From 570272ccbe285afcad3f5b4ab00a18475ef163ed Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 20 Apr 2015 10:47:57 -0400 Subject: Remove the last libX11 usage in the sytem tray protocols. Move the damage ID creation to XCB, and place it within the embedding routine in LuminaX11 instead. --- libLumina/LuminaX11.cpp | 14 ++++++++++---- libLumina/LuminaX11.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'libLumina') 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 #include #include +#include //===== 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); }; -- cgit From 5260eecf035a37e54eaceef2f7a45e8162400864 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 20 Apr 2015 12:34:06 -0400 Subject: Update th elibLumina.pro: 1)Require the xcb-damage library 2) Verify the existance of "lsb_release" before trying to use it (Linux/Debian distinction utility). --- libLumina/libLumina.pro | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libLumina') diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro index 8da9598c..ef30bd20 100644 --- a/libLumina/libLumina.pro +++ b/libLumina/libLumina.pro @@ -43,7 +43,9 @@ SOURCES += LuminaXDG.cpp \ # LuminaOS support functions (or fall back to # generic one -LINUX_DISTRIBUTION = $$system(lsb_release -si) +exists(/bin/lsb_release){ + LINUX_DISTRIBUTION = $$system(lsb_release -si) +} equals(LINUX_DISTRIBUTION, "Debian"): { SOURCES += LuminaOS-Debian.cpp @@ -52,9 +54,10 @@ equals(LINUX_DISTRIBUTION, "Debian"): { } + 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 \ -- cgit