From 5de0c9816f9bd93f13592c6c16e27396a5bcb8ea Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 20 Jun 2017 14:02:57 -0400 Subject: Commit a bit more work on the LuminaRandR class - still not ready yet. --- src-qt5/core/libLumina/LuminaRandR-X11.cpp | 40 ++++++++++++++++++++---------- src-qt5/core/libLumina/LuminaRandR.h | 11 ++++---- src-qt5/core/libLumina/test/main.cpp | 1 + 3 files changed, 34 insertions(+), 18 deletions(-) (limited to 'src-qt5') diff --git a/src-qt5/core/libLumina/LuminaRandR-X11.cpp b/src-qt5/core/libLumina/LuminaRandR-X11.cpp index f8907741..d22955fd 100644 --- a/src-qt5/core/libLumina/LuminaRandR-X11.cpp +++ b/src-qt5/core/libLumina/LuminaRandR-X11.cpp @@ -27,7 +27,7 @@ inline QStringList atomsToNames(xcb_atom_t *atoms, unsigned int num){ for(unsigned int i=0; i OutputDevice::availableMonitors(){ //Get the list of monitors xcb_randr_get_monitors_cookie_t cookie = xcb_randr_get_monitors_unchecked(QX11Info::connection(), QX11Info::appRootWindow(), 1); xcb_randr_get_monitors_reply_t *reply = xcb_randr_get_monitors_reply(QX11Info::connection(), cookie, NULL); - if(reply==0){ + if(reply==0){ qDebug() << "Could not get monitor list"; return list; } @@ -113,6 +113,7 @@ bool OutputDevice::isAutomatic(){ return p_obj.automatic; } QList OutputDevice::availableResolutions(){ return p_obj.resolutions; } QSize OutputDevice::currentResolution(){ return p_obj.geometry.size(); } //no concept of panning/scaling yet QRect OutputDevice::currentGeometry(){ return p_obj.geometry; } +QSize OutputDevice::physicalSizeMM(){ return p_obj.physicalSizeMM; } //Modification bool OutputDevice::setAsPrimary(bool set){ @@ -131,7 +132,7 @@ bool OutputDevice::disable(){ if(p_obj.monitor_atom!=0){ xcb_randr_delete_monitor(QX11Info::connection(), QX11Info::appRootWindow(), p_obj.monitor_atom); p_obj.monitor_atom = 0; - return true; + return true; } return false; } @@ -152,7 +153,7 @@ void OutputDevice::updateInfoCache(){ if(p_obj.monitor_atom !=0 || !p_obj.name.isEmpty() ){ xcb_randr_get_monitors_cookie_t cookie = xcb_randr_get_monitors_unchecked(QX11Info::connection(), QX11Info::appRootWindow(), 1); xcb_randr_get_monitors_reply_t *reply = xcb_randr_get_monitors_reply(QX11Info::connection(), cookie, NULL); - if(reply!=0){ + if(reply!=0){ xcb_randr_monitor_info_iterator_t iter = xcb_randr_get_monitors_monitors_iterator(reply); //qDebug() << "Number of Monitors:" << xcb_randr_get_monitors_monitors_length(reply); while(iter.rem>0){ @@ -165,7 +166,7 @@ void OutputDevice::updateInfoCache(){ p_obj.automatic = (iter.data->automatic == 1); p_obj.geometry = QRect(iter.data->x, iter.data->y, iter.data->width, iter.data->height); p_obj.physicalSizeMM = QSize(iter.data->width_in_millimeters, iter.data->height_in_millimeters); - //Load the "outputs" + //Load the "outputs" p_obj.outputs.clear(); int out_len = xcb_randr_monitor_info_outputs_length(iter.data); for(int i=0; i0){ @@ -225,9 +230,18 @@ OutputDeviceList::OutputDeviceList(){ free(replyA); } //end loading of active/enabled monitors -/* + //Now get the information about any **UNUSED** monitors/outputs - xcb_randr_get_screen_resources_reply_t *reply = xcb_randr_get_screen_resources_reply(QX11Info::connection(), + xcb_randr_get_providers_reply_t *pinfo = xcb_randr_get_providers_reply( QX11Info::connection(), + xcb_randr_get_providers(QX11Info::connection(), QX11Info::appRootWindow()), NULL); + if(pinfo != 0){ + xcb_randr_provider_t *prov = xcb_randr_get_providers_providers(pinfo); + int plen = xcb_randr_get_providers_providers_length(pinfo); + qDebug() << "Number of Providers:" << plen; + free(pinfo); + } + + /*xcb_randr_get_screen_resources_reply_t *reply = xcb_randr_get_screen_resources_reply(QX11Info::connection(), xcb_randr_get_screen_resources_unchecked(QX11Info::connection(), QX11Info::appRootWindow()), NULL); int outputnum = xcb_randr_get_screen_resources_outputs_length(reply); @@ -255,7 +269,7 @@ OutputDeviceList::OutputDeviceList(){ if(mode_len<=0){ continue; } //skip this output - not a physical screen which can be used - //Clones + //Clones qDebug() << "Number of Clones:" << xcb_randr_get_output_info_clones_length(info); //Names @@ -289,7 +303,7 @@ OutputDeviceList::OutputDeviceList(){ free(info); } - + free(reply);*/ } diff --git a/src-qt5/core/libLumina/LuminaRandR.h b/src-qt5/core/libLumina/LuminaRandR.h index 86c713db..a061a261 100644 --- a/src-qt5/core/libLumina/LuminaRandR.h +++ b/src-qt5/core/libLumina/LuminaRandR.h @@ -38,7 +38,7 @@ struct p_objects{ primary = automatic = false; monitor_atom = 0; }*/ - + }; class OutputDevice{ @@ -61,14 +61,15 @@ public: //Information QString ID(); - + bool isEnabled(); bool isPrimary(); bool isAutomatic(); QList availableResolutions(); QSize currentResolution(); //could be different from geometry.size() if things like panning/rotation are enabled QRect currentGeometry(); - + QSize physicalSizeMM(); + //Modification bool setAsPrimary(bool); bool disable(); @@ -78,7 +79,7 @@ public: void updateInfoCache(); //Run this after all modification functions to refresh the current info for this device - //Now define a simple public_objects class so that each implementation + //Now define a simple public_objects class so that each implementation // has a storage container for placing semi-private objects as needed //class p_objects; //forward declaration - defined in the .cpp file p_objects p_obj; @@ -92,7 +93,7 @@ public: //Simplification functions for dealing with multiple monitors void setPrimaryMonitor(QString id); void disableMonitor(QString id); - //void enableMonitor(QString id, + //void enableMonitor(QString id, QRect geom); }; #endif diff --git a/src-qt5/core/libLumina/test/main.cpp b/src-qt5/core/libLumina/test/main.cpp index b2ec9e41..e352e609 100644 --- a/src-qt5/core/libLumina/test/main.cpp +++ b/src-qt5/core/libLumina/test/main.cpp @@ -14,6 +14,7 @@ int main(int argc, char** argv){ qDebug() << " - isPrimary:" << devList[i].isPrimary(); qDebug() << " - isAutomatic:" << devList[i].isAutomatic(); qDebug() << " - Current Geometry:" << devList[i].currentGeometry(); + qDebug() << " - Physical Size (mm):" << devList[i].physicalSizeMM(); qDebug() << " - Available Resolutions:" << devList[i].availableResolutions(); } return 0; -- cgit