aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-08-05 09:30:14 -0400
committerKen Moore <moorekou@gmail.com>2015-08-05 09:30:14 -0400
commit57230742d2edde716e90e3cb8413744909054c4f (patch)
tree9ecb827de44742bd8aa72e90caaf6b830b857aa4
parentOops, committed a temporary change to include the xcb-render library (not nec... (diff)
downloadlumina-57230742d2edde716e90e3cb8413744909054c4f.tar.gz
lumina-57230742d2edde716e90e3cb8413744909054c4f.tar.bz2
lumina-57230742d2edde716e90e3cb8413744909054c4f.zip
Finish converting libLumina to XCB-only and finish replacing any LX11 functions in lumina-desktop.
-rw-r--r--libLumina/LuminaX11.cpp132
-rw-r--r--libLumina/LuminaX11.h9
-rw-r--r--libLumina/libLumina.pro2
-rw-r--r--lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp7
-rw-r--r--lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp18
-rw-r--r--lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp25
-rw-r--r--lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp2
7 files changed, 69 insertions, 126 deletions
diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp
index e79915d4..7033e62c 100644
--- a/libLumina/LuminaX11.cpp
+++ b/libLumina/LuminaX11.cpp
@@ -15,11 +15,11 @@
#include <QDesktopWidget>
//X includes (these need to be last due to Qt compile issues)
-#include <X11/Xlib.h>
+/*#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xrender.h>
-#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/Xcomposite.h>*/
//XCB Library includes
#include <xcb/xcb.h>
@@ -36,7 +36,7 @@
#define DEBUG 0
//===== WindowList() ========
-QList<WId> LX11::WindowList(){
+/*QList<WId> LX11::WindowList(){
QList<WId> output;
output << LX11::GetClientList();
@@ -53,13 +53,7 @@ QList<WId> LX11::WindowList(){
//qDebug() << "Lumina Window:" << name << LX11::WindowName(output[i]);
if(LX11::WindowName(output[i]).toLower()==name.toLower() ){ remove=true; }
}
- /*else if( name.isEmpty() ){
- qDebug() << "Abnormal Window:" << output[i];
- qDebug() << " - Class:" << name;
- qDebug() << " - Text:" << LX11::WindowName(output[i]);
- qDebug() << " - Visible Name:" << LX11::WindowVisibleName(output[i]);
- qDebug() << " - Icon Name:" << LX11::WindowIconName(output[i]);
- }*/
+
if(remove){
//qDebug() << "Skip Window:" << output[i];
output.removeAt(i);
@@ -74,16 +68,6 @@ QList<WId> LX11::WindowList(){
// ===== GetClientList() =====
QList<WId> LX11::GetClientList(){
QList<WId> output;
- //XCB Library
- /*qDebug() << "Get Client list cookie";
- xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list_unchecked( LX11::EWMH_C(), 0);
- xcb_ewmh_get_windows_reply_t winlist;
- qDebug() << "Get client list";
- if( xcb_ewmh_get_client_list_reply( LX11::EWMH_C(), cookie, &winlist, NULL) ){
- qDebug() << " - Loop over items";
- for(unsigned int i=0; i<winlist.windows_len; i++){ output << winlist.windows[i]; }
- }*/
-
//XLib
Atom a = XInternAtom(QX11Info::display(), "_NET_CLIENT_LIST", true);
Atom realType;
@@ -243,18 +227,6 @@ int LX11::GetCurrentDesktop(){
return number;
}
-// ===== ValidWindowEvent() =====
-/*bool LX11::ValidWindowEvent(Atom evAtom){
-
- if(evAtom == XInternAtom(QX11Info::display(),"_NET_CLIENT_LIST",false) ){ return true; }
- else if( evAtom == XInternAtom(QX11Info::display(),"_NET_ACTIVE_WINDOW",false) ){ return true; }
- else if( evAtom == XInternAtom(QX11Info::display(),"_NET_WM_NAME",false) ){ return true; }
- else if( evAtom == XInternAtom(QX11Info::display(),"_NET_WM_VISIBLE_NAME",false) ){ return true; }
- else if( evAtom == XInternAtom(QX11Info::display(),"_NET_WM_ICON_NAME",false) ){ return true; }
- else if( evAtom == XInternAtom(QX11Info::display(),"_NET_WM_VISIBLE_ICON_NAME",false) ){ return true; }
- else{ return false; }
-}*/
-
// ===== CloseWindow() =====
void LX11::CloseWindow(WId win){
Display *display = QX11Info::display();
@@ -524,59 +496,6 @@ QString LX11::WindowVisibleIconName(WId win){
return LX11::getNetWMProp(win, "_NET_WM_VISIBLE_ICON_NAME");
}
-// ===== WindowIcon() =====
-/*QIcon LX11::WindowIcon(WId win){
- //Use the _NET_WM_ICON value instead of the WMHints pixmaps
- // - the pixmaps are very unstable and erratic
- QIcon icon;
- Display *disp = QX11Info::display();
- Atom type;
- Atom SA = XInternAtom(disp, "_NET_WM_ICON", false);
- int format;
- unsigned long num, bytes;
- unsigned long *data = 0;
- XGetWindowProperty( disp, win, SA, 0, LONG_MAX, False, AnyPropertyType,
- &type, &format, &num, &bytes, (uchar**)&data);
- if(data != 0){
- //qDebug() << "Icon Data Found:" << win;
- ulong* dat = data;
- while(dat < data+num){ //consider the fact that there may be multiple graphical layers
- //Now convert it into a Qt image
- // - first 2 elements are width and height
- // - data in rows from left to right and top to bottom
- QImage image(dat[0], dat[1], QImage::Format_ARGB32); //initial setup
- dat+=2; //remember the first 2 element offset
- for(int i=0; i<image.byteCount()/4; ++i, ++dat){
- ((uint*)image.bits())[i] = *dat;
- }
- icon.addPixmap(QPixmap::fromImage(image)); //layer this pixmap onto the icon
- }
- XFree(data);
- }
- return icon;
-}*/
-
-
-// ===== WindowImage() =====
-/*QPixmap LX11::WindowImage(WId win, bool useleader){
- QPixmap pix;
- Display *disp = QX11Info::display();
- WId leader = LX11::leaderWindow(win); //check for an alternate window that contains the image
- if(leader!=0 && useleader){ win = leader; } //use the leader window instead
- //First get the size of the window image (embedded in the window attributes)
- XWindowAttributes att;
- if( 0 == XGetWindowAttributes(disp, win, &att) ){ return pix; } //invalid window attributes
- //Now extract the image
- XImage *xim = XGetImage(disp, win, 0,0, att.width, att.height, AllPlanes, ZPixmap);
- if(xim!=0){
- //Convert the X image to a Qt Image
- pix.convertFromImage( QImage( (const uchar*) xim->data, xim->width, xim->height, xim->bytes_per_line, QImage::Format_ARGB32_Premultiplied) );
- XDestroyImage(xim); //clean up
- }
- //Return the pixmap
- return pix;
-}*/
-
// ===== GetNumberOfDesktops() =====
int LX11::WindowDesktop(WId win){
int number = -1;
@@ -834,7 +753,7 @@ QString LX11::getNetWMProp(WId win, QString prop){
}
return property;
}
-
+*/
//===============================
//===============================
// XCB LIBRARY FUNCTIONS
@@ -939,6 +858,26 @@ void LXCB::RegisterVirtualRoots(QList<WId> roots){
delete list;
}
+// ===== SetCurrentWorkspace() =====
+void LXCB::SetCurrentWorkspace(int number){
+ //Need to send a client message event for the window so the WM picks it up
+ xcb_client_message_event_t event;
+ event.response_type = XCB_CLIENT_MESSAGE;
+ event.format = 32;
+ event.window = QX11Info::appRootWindow();
+ event.type = EWMH._NET_CURRENT_DESKTOP;
+ event.data.data32[0] = number; //set to enabled
+ event.data.data32[1] = XCB_TIME_CURRENT_TIME;
+ event.data.data32[2] = 0;
+ event.data.data32[3] = 0;
+ event.data.data32[4] = 0;
+
+ xcb_send_event(QX11Info::connection(), 0, QX11Info::appRootWindow(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event);
+
+ //EWMH function (does not seem to be recognized by Fluxbox)
+ xcb_ewmh_request_change_showing_desktop(&EWMH, QX11Info::appScreen(), number);
+}
+
// === WindowClass() ===
QString LXCB::WindowClass(WId win){
if(DEBUG){ qDebug() << "XCB: WindowClass()" << win; }
@@ -1011,6 +950,7 @@ QRect LXCB::WindowGeometry(WId win, bool includeFrame){
return geom;
}
+// === WindowFrameGeometry() ===
QList<int> LXCB::WindowFrameGeometry(WId win){
if(DEBUG){ qDebug() << "XCB: WindowFrameGeometry()"; }
//Returns: [top, bottom, left, right] sizes for the frame
@@ -1300,7 +1240,7 @@ void LXCB::SetAsPanel(WId win){
//qDebug() << " -- got cookie";
if(1 == xcb_icccm_get_wm_hints_reply(QX11Info::connection(), cookie, &hints, NULL) ){
//qDebug() << " -- Set no inputs flag";
- xcb_icccm_wm_hints_set_input(&hints, False); //set no input focus
+ xcb_icccm_wm_hints_set_input(&hints, false); //set no input focus
xcb_icccm_set_wm_hints(QX11Info::connection(), win, &hints); //save hints back to window
}
// - Remove WM_TAKE_FOCUS from the WM_PROTOCOLS for the window
@@ -1445,6 +1385,13 @@ void LXCB::ActivateWindow(WId win){ //request that the window become active
}
+// ===== RestoreWindow() =====
+void LXCB::RestoreWindow(WId win){
+ uint32_t val = XCB_STACK_MODE_ABOVE;
+ xcb_configure_window(QX11Info::connection(), win, XCB_CONFIG_WINDOW_STACK_MODE, &val); //raise it
+ xcb_map_window(QX11Info::connection(), win); //map it
+}
+
// === MaximizeWindow() ===
void LXCB::MaximizeWindow(WId win, bool flagsonly){ //request that the window become maximized
if(DEBUG){ qDebug() << "XCB: MaximizeWindow()"; }
@@ -1493,6 +1440,13 @@ void LXCB::MoveResizeWindow(WId win, QRect geom){
}
+// ===== ResizeWindow() =====
+void LXCB::ResizeWindow(WId win, int width, int height){
+ //Use the basic XCB functions instead of ewmh
+ uint32_t values[] = {width, height};
+ xcb_configure_window(QX11Info::connection(), win, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
+}
+
// === ReserveLocation ===
void LXCB::ReserveLocation(WId win, QRect geom, QString loc){
loc = loc.toLower().simplified();
@@ -1554,7 +1508,7 @@ uint LXCB::EmbedWindow(WId win, WId container){
event.format = 32;
event.window = win;
event.type = emb; //_XEMBED
- event.data.data32[0] = CurrentTime;
+ event.data.data32[0] = XCB_TIME_CURRENT_TIME; //CurrentTime;
event.data.data32[1] = 0; //XEMBED_EMBEDDED_NOTIFY
event.data.data32[2] = 0;
event.data.data32[3] = container; //WID of the container
@@ -1687,7 +1641,7 @@ WId LXCB::startSystemTray(int screen){
event.format = 32;
event.window = root_screen->root;
event.type = EWMH.MANAGER; //MANAGER atom
- event.data.data32[0] = CurrentTime;
+ event.data.data32[0] = XCB_TIME_CURRENT_TIME; //CurrentTime;
event.data.data32[1] = _NET_SYSTEM_TRAY_S; //_NET_SYSTEM_TRAY_S atom
event.data.data32[2] = LuminaSessionTrayID;
event.data.data32[3] = 0;
diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h
index 7d7585e6..7318e2c2 100644
--- a/libLumina/LuminaX11.h
+++ b/libLumina/LuminaX11.h
@@ -45,7 +45,7 @@
#define URGENCYHINT (1L << 8) //For window urgency detection
-class LX11{
+/*class LX11{
public:
enum WINDOWSTATE {VISIBLE, INVISIBLE, ACTIVE, ATTENTION, IGNORE};
@@ -106,7 +106,7 @@ public:
//EWMH Convenience functions
static QString getNetWMProp(WId win, QString prop); //Returns a _NET_WM_* string value
-};
+};*/
//XCB Library replacement for LX11 (Qt5 uses XCB instead of XLib)
class LXCB{
@@ -129,7 +129,7 @@ public:
//Session Modification
bool CheckDisableXinerama(); //returns true if Xinerama was initially set but now disabled
void RegisterVirtualRoots(QList<WId> roots);
-
+ void SetCurrentWorkspace(int);
//Window Information
QString WindowClass(WId);
@@ -156,8 +156,11 @@ public:
void KillClient(WId); //Force the application that created the window to close
void MinimizeWindow(WId); //request that the window be unmapped/minimized
void ActivateWindow(WId); //request that the window become active
+ void RestoreWindow(WId); //Re-map/raise the window
void MaximizeWindow(WId win, bool flagsonly = false); //request that the window become maximized
void MoveResizeWindow(WId win, QRect geom);
+ void ResizeWindow(WId win, int width, int height);
+ void ResizeWindow(WId win, QSize sz){ ResizeWindow(win, sz.width(), sz.height()); } //overload for simplicity
void ReserveLocation(WId win, QRect geom, QString loc);
//Window Embedding/Detaching (for system tray)
diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro
index d7df7960..68632da8 100644
--- a/libLumina/libLumina.pro
+++ b/libLumina/libLumina.pro
@@ -59,7 +59,7 @@ equals(LINUX_DISTRIBUTION, "Debian"): {
INCLUDEPATH += $$PREFIX/include
-LIBS += -lX11 -lc -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image -lxcb-composite -lxcb-damage
+LIBS += -lc -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image -lxcb-composite -lxcb-damage
include.path=$$PREFIX/include/
include.files=LuminaXDG.h \
diff --git a/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp b/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp
index 7ab2fda1..a1de725d 100644
--- a/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp
+++ b/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp
@@ -5,6 +5,7 @@
// See the LICENSE file for full details
//===========================================
#include "LDesktopSwitcher.h"
+#include <LSession.h>
LDesktopSwitcher::LDesktopSwitcher(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal) {
iconOld = -1;
@@ -114,8 +115,8 @@ QAction* LDesktopSwitcher::newAction(int what, QString name) {
}
void LDesktopSwitcher::createMenu() {
- int cur = LX11::GetCurrentDesktop(); //current desktop number
- int tot = LX11::GetNumberOfDesktops(); //total number of desktops
+ int cur = LSession::handle()->XCB->CurrentWorkspace(); //current desktop number
+ int tot = LSession::handle()->XCB->NumberOfWorkspaces(); //total number of desktops
//qDebug() << "-- vor getCurrentDesktop SWITCH";
qDebug() << "Virtual Desktops:" << tot << cur;
menu->clear();
@@ -127,7 +128,7 @@ void LDesktopSwitcher::createMenu() {
}
void LDesktopSwitcher::menuActionTriggered(QAction* act) {
- LX11::SetCurrentDesktop(act->whatsThis().toInt());
+ LSession::handle()->XCB->SetCurrentWorkspace(act->whatsThis().toInt());
label->setToolTip(QString(tr("Workspace %1")).arg(act->whatsThis().toInt() +1));
QTimer::singleShot(500, this, SLOT(createMenu()) ); //make sure the menu gets updated
}
diff --git a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp
index c45687cd..8ce01c06 100644
--- a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp
+++ b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp
@@ -114,8 +114,8 @@ void LSysMenuQuick::UpdateMenu(){
ui->group_battery->setVisible(false);
}
//Workspace
- val = LX11::GetCurrentDesktop();
- int tot = LX11::GetNumberOfDesktops();
+ val = LSession::handle()->XCB->CurrentWorkspace();
+ int tot = LSession::handle()->XCB->NumberOfWorkspaces();
ui->group_workspace->setVisible(val>=0 && tot>1);
ui->label_wk_text->setText( QString(tr("%1 of %2")).arg(QString::number(val+1), QString::number(tot)) );
}
@@ -157,20 +157,22 @@ void LSysMenuQuick::setCurrentBrightness(){
}
void LSysMenuQuick::nextWorkspace(){
- int cur = LX11::GetCurrentDesktop();
- int tot = LX11::GetNumberOfDesktops();
+ int cur = LSession::handle()->XCB->CurrentWorkspace();
+ int tot = LSession::handle()->XCB->NumberOfWorkspaces();
+ //qDebug()<< "Next Workspace:" << cur << tot;
cur++;
if(cur>=tot){ cur = 0; } //back to beginning
- LX11::SetCurrentDesktop(cur);
+ //qDebug() << " - New Current:" << cur;
+ LSession::handle()->XCB->SetCurrentWorkspace(cur);
ui->label_wk_text->setText( QString(tr("%1 of %2")).arg(QString::number(cur+1), QString::number(tot)) );
}
void LSysMenuQuick::prevWorkspace(){
- int cur = LX11::GetCurrentDesktop();
- int tot = LX11::GetNumberOfDesktops();
+ int cur = LSession::handle()->XCB->CurrentWorkspace();
+ int tot = LSession::handle()->XCB->NumberOfWorkspaces();
cur--;
if(cur<0){ cur = tot-1; } //back to last
- LX11::SetCurrentDesktop(cur);
+ LSession::handle()->XCB->SetCurrentWorkspace(cur);
ui->label_wk_text->setText( QString(tr("%1 of %2")).arg(QString::number(cur+1), QString::number(tot)) );
}
diff --git a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp
index e9e45872..6f324e7a 100644
--- a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp
+++ b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp
@@ -1,22 +1,14 @@
//===========================================
// Lumina-DE source code
-// Copyright (c) 2014, Ken Moore
+// Copyright (c) 2014-2015, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
#include "TrayIcon.h"
-//#include <X11/Xlib.h>
-//#include <X11/Xutil.h>
-//#include <X11/extensions/Xdamage.h>
-
-//#include <xcb/damage.h>
-//static xcb_damage_damage_t dmgID;
-
#include <LSession.h>
#include <QScreen>
#include <LuminaX11.h>
-//static int dmgID = 0;
TrayIcon::TrayIcon(QWidget *parent) : QWidget(parent){
AID = 0; //nothing yet
@@ -25,9 +17,6 @@ TrayIcon::TrayIcon(QWidget *parent) : QWidget(parent){
}
TrayIcon::~TrayIcon(){
- /*if(AID!=0){
- detachApp();
- }*/
}
WId TrayIcon::appID(){
@@ -41,13 +30,11 @@ void TrayIcon::attachApp(WId id){
IID = this->winId(); //embed directly into this widget
dmgID = LSession::handle()->XCB->EmbedWindow(AID, IID);
if( dmgID != 0 ){
- LX11::RestoreWindow(AID); //make it visible
- //dmgID = XDamageCreate( QX11Info::display(), AID, XDamageReportRawRectangles );
+ LSession::handle()->XCB->RestoreWindow(AID); //make it visible
qDebug() << "New System Tray App:" << AID;
QTimer::singleShot(1000, this, SLOT(updateIcon()) );
}else{
qWarning() << "Could not Embed Tray Application:" << AID;
- //LX11::DestroyWindow(IID);
IID = 0;
AID = 0;
}
@@ -69,11 +56,7 @@ void TrayIcon::detachApp(){
//Now detach the application window and clean up
qDebug() << " - Unembed";
LSession::handle()->XCB->UnembedWindow(tmp);
- //if(dmgID!=0){
- //XDamageDestroy(QX11Info::display(), dmgID);
- //}
qDebug() << " - finished app:" << tmp;
- //if(IID!=this->winId()){ LX11::DestroyWindow(IID); }
IID = 0;
}
@@ -84,7 +67,7 @@ void TrayIcon::updateIcon(){
if(AID==0){ return; }
//Make sure the icon is square
QSize icosize = this->size();
- LX11::ResizeWindow(AID, icosize.width(), icosize.height());
+ LSession::handle()->XCB->ResizeWindow(AID, icosize.width(), icosize.height());
QTimer::singleShot(500, this, SLOT(update()) ); //make sure to re-draw the window in a moment
}
@@ -122,7 +105,7 @@ void TrayIcon::paintEvent(QPaintEvent *event){
void TrayIcon::resizeEvent(QResizeEvent *event){
//qDebug() << "Resize Event:" << event->size().width() << event->size().height();
if(AID!=0){
- LX11::ResizeWindow(AID, event->size().width(), event->size().height());
+ LSession::handle()->XCB->ResizeWindow(AID, event->size());
QTimer::singleShot(500, this, SLOT(update()) ); //make sure to re-draw the window in a moment
}
}
diff --git a/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp
index 9da86da8..79a164b8 100644
--- a/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp
+++ b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp
@@ -84,7 +84,7 @@ void LTaskManagerPlugin::UpdateButtons(){
//New windows, create buttons for each (add grouping later)
if(updating > ctime){ return; } //another thread kicked off already - stop this one
//Check for a button that this can just be added to
- QString ctxt = LX11::WindowClass(winlist[i]);
+ QString ctxt = LSession::handle()->XCB->WindowClass(winlist[i]);
bool found = false;
for(int b=0; b<BUTTONS.length(); b++){
if(updating > ctime){ return; } //another thread kicked off already - stop this one
bgstack15