diff options
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaOS-Debian.cpp | 6 | ||||
-rw-r--r-- | libLumina/LuminaOS-FreeBSD.cpp | 2 | ||||
-rw-r--r-- | libLumina/LuminaUtils.cpp | 12 | ||||
-rw-r--r-- | libLumina/LuminaX11.cpp | 61 | ||||
-rw-r--r-- | libLumina/LuminaX11.h | 2 |
5 files changed, 70 insertions, 13 deletions
diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp index 12d8f11e..85dd657e 100644 --- a/libLumina/LuminaOS-Debian.cpp +++ b/libLumina/LuminaOS-Debian.cpp @@ -262,12 +262,12 @@ int LOS::CPUUsagePercent(){ //Returns: Overall percentage of the amount of CPU c } int LOS::MemoryUsagePercent(){ - QStringList mem = LUtils::getCmdOutput("top -bn1").filter("Mem:"); + QStringList mem = LUtils::getCmdOutput("top -bn1").filter("Mem :"); if(mem.isEmpty()){ return -1; } double fB = 0; //Free Bytes double uB = 0; //Used Bytes - fB = mem.first().section(" ", 6, 6, QString::SectionSkipEmpty).toDouble(); - uB = mem.first().section(" ", 4, 4, QString::SectionSkipEmpty).toDouble(); + fB = mem.first().section(" ", 5, 5, QString::SectionSkipEmpty).toDouble(); + uB = mem.first().section(" ", 7, 7, QString::SectionSkipEmpty).toDouble(); double per = (uB/(fB+uB)) * 100.0; return qRound(per); } diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index b5d3ed80..fd117079 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -339,7 +339,7 @@ QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for ea if(i==1){ labs = info[i].split(" ", QString::SkipEmptyParts); }//the labels for each column else{ QStringList data = info[i].split(" ",QString::SkipEmptyParts); //data[0] is always the device - qDebug() << "Data Line:" << data; + //qDebug() << "Data Line:" << data; if(data.length()>2 && labs.length()>2){ out << fmt.arg(data[0], data[1]+" "+labs[1], data[2]+" "+labs[2]); } diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 42f36962..9d1eaf0d 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -24,7 +24,7 @@ static QStringList fav; // LUtils Functions //============= QString LUtils::LuminaDesktopVersion(){ - return "0.8.5-devel"; + return "0.8.6-devel"; } int LUtils::runCmd(QString cmd, QStringList args){ @@ -202,19 +202,24 @@ QStringList LUtils::listQuickPlugins(){ QDir dir(QDir::homePath()+"/.lumina/quickplugins"); QStringList files = dir.entryList(QStringList() << "quick-*.qml", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); dir.cd(LOS::LuminaShare()+"quickplugins"); - files << files = dir.entryList(QStringList() << "quick-*.qml", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + files << dir.entryList(QStringList() << "quick-*.qml", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); for(int i=0; i<files.length(); i++){ files[i] = files[i].section("quick-",1,100).section(".qml",0,0); //just grab the ID out of the middle of the filename } files.removeDuplicates(); + //qDebug() << "Found Quick Plugins:" << files; return files; } QStringList LUtils::infoQuickPlugin(QString ID){ //Returns: [Name, Description, Icon] + //qDebug() << "Find Quick Info:" << ID; QString path = findQuickPluginFile(ID); + //qDebug() << " - path:" << path; if(path.isEmpty()){ return QStringList(); } //invalid ID - QStringList contents = LUtils::readFile(path).filter("//").filter("=").filter("Plugin"); + QStringList contents = LUtils::readFile(path); if(contents.isEmpty()){ return QStringList(); } //invalid file (unreadable) + contents = contents.filter("//").filter("=").filter("Plugin"); //now just grab the comments + //qDebug() << " - Filtered Contents:" << contents; QStringList info; info << "" << "" << ""; for(int i=0; i<contents.length(); i++){ if(contents[i].contains("Plugin-Name=")){ info[0] = contents[i].section("Plugin-Name=",1,1).simplified(); } @@ -223,6 +228,7 @@ QStringList LUtils::infoQuickPlugin(QString ID){ //Returns: [Name, Description, } if(info[0].isEmpty()){ info[0]=ID; } if(info[2].isEmpty()){ info[2]="preferences-plugin"; } + //qDebug() << " - info:" << info; return info; } diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index 770f64db..ba091771 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -29,6 +29,7 @@ #include <xcb/composite.h> #include <xcb/damage.h> +#define DEBUG 0 //===== WindowList() ======== QList<WId> LX11::WindowList(){ @@ -849,6 +850,7 @@ LXCB::~LXCB(){ // === WindowList() === QList<WId> LXCB::WindowList(bool rawlist){ + if(DEBUG){ qDebug() << "XCB: WindowList()" << rawlist; } QList<WId> output; //qDebug() << "Get Client list cookie"; xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list_unchecked( &EWMH, 0); @@ -872,6 +874,7 @@ QList<WId> LXCB::WindowList(bool rawlist){ // === CurrentWorkspace() === unsigned int LXCB::CurrentWorkspace(){ + if(DEBUG){ qDebug() << "XCB: CurrentWorkspace()"; } //qDebug() << "Get Current Workspace"; xcb_get_property_cookie_t cookie = xcb_ewmh_get_current_desktop_unchecked(&EWMH, 0); uint32_t wkspace = 0; @@ -882,6 +885,7 @@ unsigned int LXCB::CurrentWorkspace(){ // === ActiveWindow() === WId LXCB::ActiveWindow(){ + if(DEBUG){ qDebug() << "XCB: ActiveWindow()"; } xcb_get_property_cookie_t cookie = xcb_ewmh_get_active_window_unchecked(&EWMH, 0); xcb_window_t actwin; if(1 == xcb_ewmh_get_active_window_reply(&EWMH, cookie, &actwin, NULL) ){ @@ -893,6 +897,7 @@ WId LXCB::ActiveWindow(){ // === RegisterVirtualRoots() === void LXCB::RegisterVirtualRoots(QList<WId> roots){ + if(DEBUG){ qDebug() << "XCB: RegisterVirtualRoots()"; } //First convert the QList into the proper format xcb_window_t *list = new xcb_window_t[ roots.length() ]; for(int i=0; i<roots.length(); i++){ @@ -906,6 +911,7 @@ void LXCB::RegisterVirtualRoots(QList<WId> roots){ // === WindowClass() === QString LXCB::WindowClass(WId win){ + if(DEBUG){ qDebug() << "XCB: WindowClass()" << win; } QString out; if(win==0){ return ""; } xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_class_unchecked(QX11Info::connection(), win); @@ -920,6 +926,7 @@ QString LXCB::WindowClass(WId win){ // === WindowWorkspace() === unsigned int LXCB::WindowWorkspace(WId win){ + if(DEBUG){ qDebug() << "XCB: WindowWorkspace()" << win; } //qDebug() << "Get Window Workspace"; if(win==0){ return 0; } uint32_t wkspace = 0; @@ -932,6 +939,7 @@ unsigned int LXCB::WindowWorkspace(WId win){ // === WindowGeometry() === QRect LXCB::WindowGeometry(WId win, bool includeFrame){ + if(DEBUG){ qDebug() << "XCB: WindowGeometry()"; } QRect geom; if(win==0){ return geom; } xcb_get_geometry_cookie_t cookie = xcb_get_geometry(QX11Info::connection(), win); @@ -974,14 +982,17 @@ QRect LXCB::WindowGeometry(WId win, bool includeFrame){ } QList<int> LXCB::WindowFrameGeometry(WId win){ + if(DEBUG){ qDebug() << "XCB: WindowFrameGeometry()"; } //Returns: [top, bottom, left, right] sizes for the frame QList<int> geom; - xcb_get_property_cookie_t cookie = xcb_ewmh_get_frame_extents_unchecked(&EWMH, win); - if(cookie.sequence != 0){ - xcb_ewmh_get_extents_reply_t frame; - if(1== xcb_ewmh_get_frame_extents_reply(&EWMH, cookie, &frame, NULL) ){ - //adjust the origin point to account for the frame - geom << frame.top << frame.bottom << frame.left << frame.right; + if(win!=0){ + xcb_get_property_cookie_t cookie = xcb_ewmh_get_frame_extents_unchecked(&EWMH, win); + if(cookie.sequence != 0){ + xcb_ewmh_get_extents_reply_t frame; + if(1== xcb_ewmh_get_frame_extents_reply(&EWMH, cookie, &frame, NULL) ){ + //adjust the origin point to account for the frame + geom << frame.top << frame.bottom << frame.left << frame.right; + } } } if(geom.isEmpty()){ geom << 0 << 0 << 0 << 0; } @@ -990,6 +1001,7 @@ QList<int> LXCB::WindowFrameGeometry(WId win){ // === WindowState() === LXCB::WINDOWSTATE LXCB::WindowState(WId win){ + if(DEBUG){ qDebug() << "XCB: WindowState()"; } if(win==0){ return IGNORE; } xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(&EWMH, win); if(cookie.sequence == 0){ return IGNORE; } @@ -1033,6 +1045,7 @@ LXCB::WINDOWSTATE LXCB::WindowState(WId win){ // === WindowVisibleIconName() === QString LXCB::WindowVisibleIconName(WId win){ //_NET_WM_VISIBLE_ICON_NAME + if(DEBUG){ qDebug() << "XCB: WindowVisibleIconName()"; } if(win==0){ return ""; } QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_visible_icon_name_unchecked(&EWMH, win); @@ -1046,6 +1059,7 @@ QString LXCB::WindowVisibleIconName(WId win){ //_NET_WM_VISIBLE_ICON_NAME // === WindowIconName() === QString LXCB::WindowIconName(WId win){ //_NET_WM_ICON_NAME + if(DEBUG){ qDebug() << "XCB: WindowIconName()"; } if(win==0){ return ""; } QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon_name_unchecked(&EWMH, win); @@ -1059,6 +1073,7 @@ QString LXCB::WindowIconName(WId win){ //_NET_WM_ICON_NAME // === WindowVisibleName() === QString LXCB::WindowVisibleName(WId win){ //_NET_WM_VISIBLE_NAME + if(DEBUG){ qDebug() << "XCB: WindowVisibleName()"; } if(win==0){ return ""; } QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_visible_name_unchecked(&EWMH, win); @@ -1072,6 +1087,7 @@ QString LXCB::WindowVisibleName(WId win){ //_NET_WM_VISIBLE_NAME // === WindowName() === QString LXCB::WindowName(WId win){ //_NET_WM_NAME + if(DEBUG){ qDebug() << "XCB: WindowName()"; } if(win==0){ return ""; } QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked(&EWMH, win); @@ -1085,6 +1101,7 @@ QString LXCB::WindowName(WId win){ //_NET_WM_NAME // === OldWindowName() === QString LXCB::OldWindowName(WId win){ //WM_NAME (old standard) + if(DEBUG){ qDebug() << "XCB: OldWindowName()"; } if(win==0){ return ""; } xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_name_unchecked(QX11Info::connection(), win); xcb_icccm_get_text_property_reply_t reply; @@ -1099,6 +1116,7 @@ QString LXCB::OldWindowName(WId win){ //WM_NAME (old standard) // === OldWindowIconName() === QString LXCB::OldWindowIconName(WId win){ //WM_ICON_NAME (old standard) + if(DEBUG){ qDebug() << "XCB: OldWindowIconName()"; } if(win==0){ return ""; } xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_icon_name_unchecked(QX11Info::connection(), win); xcb_icccm_get_text_property_reply_t reply; @@ -1113,6 +1131,7 @@ QString LXCB::OldWindowIconName(WId win){ //WM_ICON_NAME (old standard) // === WindowIsMaximized() === bool LXCB::WindowIsMaximized(WId win){ + if(DEBUG){ qDebug() << "XCB: WindowIsMaximized()"; } if(win==0){ return ""; } //See if the _NET_WM_STATE_MAXIMIZED_[VERT/HORZ] flags are set on the window xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(&EWMH, win); @@ -1133,6 +1152,7 @@ bool LXCB::WindowIsMaximized(WId win){ // === WindowIcon() === QIcon LXCB::WindowIcon(WId win){ //Fetch the _NET_WM_ICON for the window and return it as a QIcon + if(DEBUG){ qDebug() << "XCB: WindowIcon()"; } QIcon icon; if(win==0){ return icon; } xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon_unchecked(&EWMH, win); @@ -1163,6 +1183,7 @@ QIcon LXCB::WindowIcon(WId win){ // === SetAsSticky() === void LXCB::SetAsSticky(WId win){ + if(DEBUG){ qDebug() << "XCB: SetAsSticky()"; } if(win==0){ return; } //Need to send a client message event for the window so the WM picks it up xcb_client_message_event_t event; @@ -1183,9 +1204,20 @@ void LXCB::SetAsSticky(WId win){ xcb_flush(QX11Info::connection()); //apply it right away*/ } +// === SetDisableWMActions() === +void LXCB::SetDisableWMActions(WId win){ + if(DEBUG){ qDebug() << "XCB: SetDisableWMActions()"; } + //This disables all the various control that a WM allows for the window (except for allowing the "Sticky" state) + xcb_atom_t list[1]; + list[0] = EWMH._NET_WM_ACTION_STICK; + xcb_ewmh_set_wm_allowed_actions(&EWMH, win, 1, list); +} + // === SetAsPanel() === void LXCB::SetAsPanel(WId win){ + if(DEBUG){ qDebug() << "XCB: SetAsPanel()"; } if(win==0){ return; } + SetDisableWMActions(win); //also need to disable WM actions for this window //Disable Input focus (panel activation ruins task manager window detection routines) // - Disable Input flag in WM_HINTS xcb_icccm_wm_hints_t hints; @@ -1262,20 +1294,32 @@ void LXCB::SetAsPanel(WId win){ } +void LXCB::SetAsDesktop(WId win){ + if(DEBUG){ qDebug() << "XCB: SetAsDesktop()"; } + if(win==0){ return; } + SetDisableWMActions(win); //also need to disable WM actions for this window + xcb_atom_t list[1]; + list[0] = EWMH._NET_WM_WINDOW_TYPE_DESKTOP; + xcb_ewmh_set_wm_window_type(&EWMH, win, 1, list); +} + // === CloseWindow() === void LXCB::CloseWindow(WId win){ + if(DEBUG){ qDebug() << "XCB: CloseWindow()"; } if(win==0){ return; } //This will close the specified window (might not close the entire application) xcb_ewmh_request_close_window(&EWMH, 0, win, QX11Info::getTimestamp(), XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER); } void LXCB::KillClient(WId win){ + if(DEBUG){ qDebug() << "XCB: KillClient()"; } if(win==0){ return; } //This will forcibly close the application which created WIN xcb_kill_client(QX11Info::connection(), win); } // === MinimizeWindow() === void LXCB::MinimizeWindow(WId win){ //request that the window be unmapped/minimized + if(DEBUG){ qDebug() << "XCB: MinimizeWindow()"; } if(win==0){ return; } //Note: Fluxbox completely removes this window from the open list if unmapped manually // xcb_unmap_window(QX11Info::connection(), win); @@ -1298,6 +1342,7 @@ void LXCB::MinimizeWindow(WId win){ //request that the window be unmapped/minimi // === ActivateWindow() === void LXCB::ActivateWindow(WId win){ //request that the window become active + if(DEBUG){ qDebug() << "XCB: ActivateWindow();"; } if(win==0){ return; } //First need to get the currently active window xcb_get_property_cookie_t cookie = xcb_ewmh_get_active_window_unchecked(&EWMH, 0); @@ -1325,6 +1370,7 @@ void LXCB::ActivateWindow(WId win){ //request that the window become active // === MaximizeWindow() === void LXCB::MaximizeWindow(WId win, bool flagsonly){ //request that the window become maximized + if(DEBUG){ qDebug() << "XCB: MaximizeWindow()"; } if(win==0){ return; } if(flagsonly){ //Directly set the flags on the window (bypassing the WM) @@ -1352,6 +1398,7 @@ void LXCB::MaximizeWindow(WId win, bool flagsonly){ //request that the window be // === MoveResizeWindow() === void LXCB::MoveResizeWindow(WId win, QRect geom){ + if(DEBUG){ qDebug() << "XCB: MoveResizeWindow()"; } if(win==0){ return; } //NOTE: geom needs to be in root/absolute coordinates! //qDebug() << "MoveResize Window:" << geom.x() << geom.y() << geom.width() << geom.height(); @@ -1371,6 +1418,7 @@ void LXCB::MoveResizeWindow(WId win, QRect geom){ // === EmbedWindow() === uint LXCB::EmbedWindow(WId win, WId container){ + if(DEBUG){ qDebug() << "XCB: EmbedWindow()"; } //This returns the damage control ID number (or 0 for a failure) if(win==0 || container==0){ return 0; } //qDebug() << "Embed Window:" << win << container; @@ -1423,6 +1471,7 @@ uint LXCB::EmbedWindow(WId win, WId container){ // === Unembed Window() === bool LXCB::UnembedWindow(WId win){ + if(DEBUG){ qDebug() << "XCB: UnembedWindow()"; } if(win==0){ return false; } //Display *disp = QX11Info::display(); //Remove redirects diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h index 468045d1..d098a740 100644 --- a/libLumina/LuminaX11.h +++ b/libLumina/LuminaX11.h @@ -145,7 +145,9 @@ public: //Window Modification void SetAsSticky(WId); //Stick to all workspaces + void SetDisableWMActions(WId); //Disable WM control (shortcuts/automatic functions) void SetAsPanel(WId); //Adjust all the window flags for a proper panel (cannot be done through Qt) + void SetAsDesktop(WId); //Adjust window flags to set as the desktop void CloseWindow(WId); //request that the window be closed void KillClient(WId); //Force the application that created the window to close void MinimizeWindow(WId); //request that the window be unmapped/minimized |