diff options
author | Ken Moore <ken@pcbsd.org> | 2014-09-12 11:43:21 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2014-09-12 11:43:21 -0400 |
commit | eaad2f3b8da84e6ac1e879f2995207162588f1ff (patch) | |
tree | fc168c145a36db404502b7cf74d1f5f10aa12a39 /libLumina | |
parent | Update the *.desktop "Exec=" compliance to the standards as of 9/9/2014 in Lu... (diff) | |
download | lumina-eaad2f3b8da84e6ac1e879f2995207162588f1ff.tar.gz lumina-eaad2f3b8da84e6ac1e879f2995207162588f1ff.tar.bz2 lumina-eaad2f3b8da84e6ac1e879f2995207162588f1ff.zip |
Move all the OS-specific path PREFIX settings into LuminaOS so that we don't have all the different defines all over the place.
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaOS-FreeBSD.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-Linux.cpp | 4 | ||||
-rw-r--r-- | libLumina/LuminaOS-template.cpp | 33 | ||||
-rw-r--r-- | libLumina/LuminaOS.h | 4 | ||||
-rw-r--r-- | libLumina/LuminaX11.cpp | 32 | ||||
-rw-r--r-- | libLumina/LuminaX11.h | 2 | ||||
-rw-r--r-- | libLumina/LuminaXDG.cpp | 31 |
7 files changed, 62 insertions, 49 deletions
diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index a3dcb91e..0e381660 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -11,6 +11,11 @@ //can't read xbrightness settings - assume invalid until set static int screenbrightness = -1; + +//OS-specific prefix(s) +QString LOS::AppPrefix(){ return "/usr/local/"; } //Prefix for applications +QString LOS::SysPrefix(){ return "/usr/"; } //Prefix for system + // ==== ExternalDevicePaths() ==== QStringList LOS::ExternalDevicePaths(){ //Returns: QStringList[<type>::::<filesystem>::::<path>] diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp index db1d71bd..f3ac854e 100644 --- a/libLumina/LuminaOS-Linux.cpp +++ b/libLumina/LuminaOS-Linux.cpp @@ -13,6 +13,10 @@ //can't read xbrightness settings - assume invalid until set static int screenbrightness = -1; +//OS-specific prefix(s) +QString LOS::AppPrefix(){ return "/usr/"; } //Prefix for applications +QString LOS::SysPrefix(){ return "/usr/"; } //Prefix for system + // ==== ExternalDevicePaths() ==== QStringList LOS::ExternalDevicePaths(){ //Returns: QStringList[<type>::::<filesystem>::::<path>] diff --git a/libLumina/LuminaOS-template.cpp b/libLumina/LuminaOS-template.cpp index be70e1a5..88d1b72e 100644 --- a/libLumina/LuminaOS-template.cpp +++ b/libLumina/LuminaOS-template.cpp @@ -9,54 +9,59 @@ #include <unistd.h> #include <stdio.h> // Needed for BUFSIZ +//OS-specific prefix(s) +QString LOS::AppPrefix(){ return "/usr/local/"; } //Prefix for applications +QString LOS::SysPrefix(){ return "/usr/"; } //Prefix for system + // ==== ExternalDevicePaths() ==== QStringList LOS::ExternalDevicePaths(){ //Returns: QStringList[<type>::::<filesystem>::::<path>] //Note: <type> = [USB, HDRIVE, DVD, SDCARD, UNKNOWN] - //Not implemented yet for Linux + //Not implemented yet return QStringList(); } //Read screen brightness information int LOS::ScreenBrightness(){ //Returns: Screen Brightness as a percentage (0-100, with -1 for errors) - return -1; //not implemented yet for Linux + return -1; //not implemented yet } //Set screen brightness void LOS::setScreenBrightness(int percent){ - //not implemented yet for Linux + //not implemented yet } //Read the current volume -int LOS::audioVolume(){ //Returns: audio volume as a percentage (0-100, with -1 for errors) - return -1; //Not implemented yet for Linux +int LOS::audioVolume(){ + //Returns: audio volume as a percentage (0-100, with -1 for errors) + return -1; //Not implemented yet } //Set the current volume void LOS::setAudioVolume(int percent){ - //not implemented yet for Linux + //not implemented yet } //Change the current volume a set amount (+ or -) void LOS::changeAudioVolume(int percentdiff){ - //not implemented yet for Linux + //not implemented yet } //Check if a graphical audio mixer is installed bool LOS::hasMixerUtility(){ - return false; //not implemented yet for Linux + return false; //not implemented yet } //Launch the graphical audio mixer utility void LOS::startMixerUtility(){ - //not implemented yet for Linux + //not implemented yet } //System Shutdown void LOS::systemShutdown(){ //start poweroff sequence - QProcess::startDetached("shutdown -h now"); + QProcess::startDetached("shutdown -p now"); } //System Restart @@ -66,22 +71,22 @@ void LOS::systemRestart(){ //start reboot sequence //Battery Availability bool LOS::hasBattery(){ - return false; //not implemented yet for Linux + return false; //not implemented yet } //Battery Charge Level int LOS::batteryCharge(){ //Returns: percent charge (0-100), anything outside that range is counted as an error - return -1; //not implemented yet for Linux + return -1; //not implemented yet } //Battery Charging State bool LOS::batteryIsCharging(){ - return false; //not implemented yet for Linux + return false; //not implemented yet } //Battery Time Remaining int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining - return 0; //not implemented yet for Linux + return 0; //not implemented yet } #endif diff --git a/libLumina/LuminaOS.h b/libLumina/LuminaOS.h index a091a25e..84bc9806 100644 --- a/libLumina/LuminaOS.h +++ b/libLumina/LuminaOS.h @@ -21,6 +21,10 @@ class LOS{ public: + //OS-specific prefix(s) + static QString AppPrefix(); //Prefix for applications (/usr/local/ on FreeBSD) + static QString SysPrefix(); //Prefix for system (/usr/ on FreeBSD) + //Scan for mounted external devices static QStringList ExternalDevicePaths(); //Returns: QStringList[<type>::::<filesystem>::::<path>] //Note: <type> = [USB, HDRIVE, DVD, SDCARD, UNKNOWN] diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index be6d807c..6b847df6 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -550,18 +550,18 @@ int LX11::WindowDesktop(WId win){ // ===== GetWindowState() ===== LX11::WINDOWSTATE LX11::GetWindowState(WId win){ - Display *disp = QX11Info::display(); /* + Display *disp = QX11Info::display(); Atom SA = XInternAtom(disp, "_NET_WM_STATE", false); Atom ATTENTION = XInternAtom(disp, "_NET_WM_STATE_DEMANDS_ATTENTION", false); Atom SKIPP = XInternAtom(disp, "_NET_WM_STATE_SKIP_PAGER", false); Atom HIDDEN = XInternAtom(disp, "_NET_WM_STATE_HIDDEN", false); Atom SKIPT = XInternAtom(disp, "_NET_WM_STATE_SKIP_TASKBAR", false); - Atom MODAL = XInternAtom(disp, "_NET_WM_STATE_MODAL", false); */ - //Atom type; - //int format; - //unsigned long num, bytes; - //unsigned char *data = 0; - /* + Atom MODAL = XInternAtom(disp, "_NET_WM_STATE_MODAL", false); + Atom type; + int format; + unsigned long num, bytes; + unsigned char *data = 0; + int status = XGetWindowProperty( disp, win, SA, 0, ~(0L), false, AnyPropertyType, &type, &format, &num, &bytes, &data); @@ -569,7 +569,7 @@ LX11::WINDOWSTATE LX11::GetWindowState(WId win){ if(status >= Success && data){ Atom *array = (Atom*) data; for(unsigned int i=0; i<num; i++){ - if(forDisplay && (array[i] == SKIPP || array[i]==SKIPT || array[i]==MODAL) ){ + if(array[i] == SKIPP || array[i]==SKIPT || array[i]==MODAL ){ state = LX11::IGNORE; break; }else if(array[i]==HIDDEN){ @@ -582,8 +582,8 @@ LX11::WINDOWSTATE LX11::GetWindowState(WId win){ } XFree(data); } - */ - LX11::WINDOWSTATE state = LX11::VISIBLE; + + //LX11::WINDOWSTATE state = LX11::VISIBLE; if(state==LX11::VISIBLE){ XWindowAttributes attr; if( 0 != XGetWindowAttributes(disp, win, &attr) ){ @@ -598,6 +598,18 @@ LX11::WINDOWSTATE LX11::GetWindowState(WId win){ state = LX11::ACTIVE; } } + //(ALTERNATE) Also check whether the window has the URGENT flag set (override all other states) + if(state!= LX11::ATTENTION){ + XWMHints *hints = XGetWMHints(disp, win); + if(hints!=0){ + if(hints->flags & URGENCYHINT){ + qDebug() << "Found Urgent Flag:"; + state = LX11::ATTENTION; + } + XFree(hints); + } + } + return state; } diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h index a60adafc..e7cded49 100644 --- a/libLumina/LuminaX11.h +++ b/libLumina/LuminaX11.h @@ -40,6 +40,8 @@ #define SYSTEM_TRAY_BEGIN_MESSAGE 1 #define SYSTEM_TRAY_CANCEL_MESSAGE 2 +#define URGENCYHINT (1L << 8) //For window urgency detection + class LX11{ public: enum WINDOWSTATE {VISIBLE, INVISIBLE, ACTIVE, ATTENTION, IGNORE}; diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index 8d210abe..3bbc32f9 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -5,6 +5,7 @@ // See the LICENSE file for full details //=========================================== #include "LuminaXDG.h" +#include "LuminaOS.h" static QStringList mimeglobs; static qint64 mimechecktime; @@ -273,12 +274,7 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){ for(int i=0; i<xdd.length(); i++){ paths << xdd[i]+"/icons"; } - #ifdef __FreeBSD__ - paths << "/usr/local/share/pixmaps"; - #endif - #ifdef __linux__ - paths << "/usr/share/pixmaps"; - #endif + paths << LOS::AppPrefix()+"share/pixmaps"; QIcon::setThemeSearchPaths(paths); } if(DEBUG){ qDebug() << "[LXDG] Icon search paths:" << paths; } @@ -291,31 +287,16 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){ //Try to load the icon from /usr/local/share/pixmaps if( ico.isNull() ){ //qDebug() << "Could not find icon:" << iconName; - #ifdef __FreeBSD__ - QDir base("/usr/local/share/pixmaps"); - #endif - #ifdef __linux__ - QDir base("/usr/share/pixmaps"); - #endif + QDir base(LOS::AppPrefix()+"share/pixmaps"); QStringList matches = base.entryList(QStringList() << "*"+iconName+"*", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); if( !matches.isEmpty() ){ - #ifdef __FreeBSD__ - ico = QIcon("/usr/local/share/pixmaps/"+matches[0]); //just use the first match - #endif - #ifdef __linux__ - ico = QIcon("/usr/share/pixmaps/"+matches[0]); //just use the first match - #endif + ico = QIcon(base.absoluteFilePath(matches[0])); //just use the first match }else{ //Fallback on a manual search over the default theme directories (hicolor, then oxygen) if( QDir::searchPaths("fallbackicons").isEmpty() ){ //Set the fallback search paths - #ifdef __FreeBSD__ - QString base = "/usr/local/share/icons/"; - #endif - #ifdef __linux__ - QString base = "/usr/share/icons/"; - #endif - QDir::setSearchPaths("fallbackicons", QStringList() << getChildIconDirs(base+"hicolor") << getChildIconDirs(base+"oxygen") ); + QString localbase = LOS::AppPrefix()+"share/icons/"; + QDir::setSearchPaths("fallbackicons", QStringList() << getChildIconDirs(localbase+"hicolor") << getChildIconDirs(localbase+"oxygen") ); } if(QFile::exists("fallbackicons:"+iconName+".png")){ ico = QIcon("fallbackicons:"+iconName+".png"); |