diff options
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r-- | src-qt5/core/libLumina/LuminaRandR-X11.cpp | 45 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaSingleApplication.cpp | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow.cpp | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow.h | 4 | ||||
-rw-r--r-- | src-qt5/core/libLumina/test/main.cpp | 4 |
5 files changed, 50 insertions, 11 deletions
diff --git a/src-qt5/core/libLumina/LuminaRandR-X11.cpp b/src-qt5/core/libLumina/LuminaRandR-X11.cpp index edd90afa..ab3a49f0 100644 --- a/src-qt5/core/libLumina/LuminaRandR-X11.cpp +++ b/src-qt5/core/libLumina/LuminaRandR-X11.cpp @@ -130,11 +130,43 @@ inline xcb_randr_mode_t modeForResolution(QSize res, QList<xcb_randr_mode_t> mod return det_mode; } +inline void adjustScreenTotal(xcb_randr_crtc_t output, QRect geom, bool addingoutput){ + QRect total, mmTotal; + xcb_randr_get_screen_resources_reply_t *srreply = xcb_randr_get_screen_resources_reply(QX11Info::connection(), + xcb_randr_get_screen_resources_unchecked(QX11Info::connection(), QX11Info::appRootWindow()), NULL); + if(srreply!=0){ + for(int i=0; i<xcb_randr_get_screen_resources_crtcs_length(srreply); i++){ + xcb_randr_crtc_t crtc = xcb_randr_get_screen_resources_crtcs(srreply)[i]; + if(output == crtc){ + //Found the output we are (going) to treat differently + if(addingoutput){ + total = total.united(geom); + } + //ignore the output if we just removed it + }else{ + //Get the current geometry of this crtc (if available) and add it to the total + xcb_randr_get_crtc_info_reply_t *cinfo = xcb_randr_get_crtc_info_reply(QX11Info::connection(), + xcb_randr_get_crtc_info_unchecked(QX11Info::connection(), crtc, QX11Info::appTime()), + NULL); + if(cinfo!=0){ + total = total.united( QRect(cinfo->x, cinfo->y, cinfo->width, cinfo->height) ); + //QSize dpi( qRound((cinfo->width * 25.4)/cinfo->), qRound((p_obj.geometry.height() * 25.4)/p_obj.physicalSizeMM.height() ) ); + free(cinfo); //done with crtc_info + } + } + } + free(srreply); + } + QSize newRes = total.size(); + QSize newMM = mmTotal.size(); + xcb_randr_set_screen_size(QX11Info::connection(), QX11Info::appRootWindow(), newRes.width(), newRes.height(), newMM.width(), newMM.height()); +} + inline bool showOutput(QRect geom, p_objects *p_obj){ //if no geom provided, will add as the right-most screen at optimal resolution qDebug() << "Enable Monitor:" << geom; xcb_randr_mode_t mode = modeForResolution(geom.size(), p_obj->modes); - if(mode==XCB_NONE){ return false; } //invalid resolution for this monitor + if(mode==XCB_NONE){ qDebug() << "[ERROR] Invalid resolution supplied!"; return false; } //invalid resolution for this monitor //qDebug() << " - Found Mode:" << mode; if(p_obj->crtc == 0){ //Need to scan for an available crtc to use (turning on a monitor for the first time) @@ -158,6 +190,10 @@ inline bool showOutput(QRect geom, p_objects *p_obj){ } free(reply); } +if(p_obj->crtc == 0){ qDebug() << "[ERROR] No Available CRTC devices for display"; return false; } + //Now need to update the overall session size (if necessary) + adjustScreenTotal(p_obj->crtc, geom, true); //adding output at this geometry + //qDebug() << " - Using crtc:" << p_obj->crtc; //qDebug() << " - Using mode:" << mode; xcb_randr_output_t outList[1]{ p_obj->output }; @@ -166,8 +202,8 @@ inline bool showOutput(QRect geom, p_objects *p_obj){ XCB_CURRENT_TIME, XCB_CURRENT_TIME, geom.x(), geom.y(), mode, XCB_RANDR_ROTATION_ROTATE_0, 1, outList); //Now check the result of the configuration xcb_randr_set_crtc_config_reply_t *reply = xcb_randr_set_crtc_config_reply(QX11Info::connection(), cookie, NULL); - if(reply==0){ return false; } - bool ok = (reply->status == XCB_RANDR_SET_CONFIG_SUCCESS); + bool ok = false; + if(reply!=0){ ok = (reply->status == XCB_RANDR_SET_CONFIG_SUCCESS); } free(reply); return ok; } @@ -247,6 +283,9 @@ bool OutputDevice::disable(){ if(reply==0){ return false; } bool ok = (reply->status == XCB_RANDR_SET_CONFIG_SUCCESS); free(reply); + if(ok){ + adjustScreenTotal(p_obj.crtc, QRect(), false); //adding output at this geometry + } return ok; } return false; diff --git a/src-qt5/core/libLumina/LuminaSingleApplication.cpp b/src-qt5/core/libLumina/LuminaSingleApplication.cpp index e3816add..a97753c5 100644 --- a/src-qt5/core/libLumina/LuminaSingleApplication.cpp +++ b/src-qt5/core/libLumina/LuminaSingleApplication.cpp @@ -15,7 +15,7 @@ LSingleApplication::LSingleApplication(int &argc, char **argv, QString appname) : QApplication(argc, argv){ //Load the proper translation systems - this->setAttribute(Qt::AA_UseHighDpiPixmaps); + this->setAttribute(Qt::AA_UseHighDpiPixmaps); if(appname!="lumina-desktop"){ cTrans = LUtils::LoadTranslation(this, appname); }//save the translator for later //Initialize a couple convenience internal variables cfile = QDir::tempPath()+"/.LSingleApp-%1-%2-%3"; @@ -25,7 +25,7 @@ LSingleApplication::LSingleApplication(int &argc, char **argv, QString appname) cfile = cfile.arg( username, appname, QString::number(QX11Info::appScreen()) ); lockfile = new QLockFile(cfile+"-lock"); lockfile->setStaleLockTime(0); //long-lived processes - for(int i=1; i<argc; i++){ + for(int i=1; i<argc; i++){ QString path = QString::fromLocal8Bit(argv[i]); //do few quick conversions for relative paths and such as necessary // (Remember: this is only used for secondary processes, not the primary) diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp index 688a1d07..41c04ee1 100644 --- a/src-qt5/core/libLumina/RootSubWindow.cpp +++ b/src-qt5/core/libLumina/RootSubWindow.cpp @@ -10,7 +10,7 @@ #include <QVBoxLayout> #include <QVBoxLayout> -#define WIN_BORDER 3 +#define WIN_BORDER 3 // === PUBLIC === RootSubWindow::RootSubWindow(QWidget *root, NativeWindow *win) : QFrame(root){ @@ -274,7 +274,7 @@ void RootSubWindow::mousePressEvent(QMouseEvent *ev){ activeState = getStateAtPoint(ev->pos(), true); //also have it set the offset variable } setMouseCursor(activeState, true); //this one is an override cursor - + } void RootSubWindow::mouseMoveEvent(QMouseEvent *ev){ diff --git a/src-qt5/core/libLumina/RootSubWindow.h b/src-qt5/core/libLumina/RootSubWindow.h index 8c5ef2b8..779f783b 100644 --- a/src-qt5/core/libLumina/RootSubWindow.h +++ b/src-qt5/core/libLumina/RootSubWindow.h @@ -30,7 +30,7 @@ public: WId id(); private: - //Window status + //Window status enum ModState{Normal, Move, ResizeTop, ResizeTopRight, ResizeRight, ResizeBottomRight, ResizeBottom, ResizeBottomLeft, ResizeLeft, ResizeTopLeft}; ModState activeState; ModState currentCursor; @@ -64,7 +64,7 @@ public slots: //Mouse Interactivity void startMoving(); void startResizing(); - + private slots: void propertiesChanged(QList<NativeWindow::Property>, QList<QVariant>); diff --git a/src-qt5/core/libLumina/test/main.cpp b/src-qt5/core/libLumina/test/main.cpp index 056f1d28..f78efbd1 100644 --- a/src-qt5/core/libLumina/test/main.cpp +++ b/src-qt5/core/libLumina/test/main.cpp @@ -5,8 +5,8 @@ int main(int argc, char** argv){ - QString toggle = "HDMI-2"; - QRect toggleGeom(1920,0, 1920,1080); + QString toggle = "DVI-I-1"; + QRect toggleGeom(7680,0, 1024,768); int toggleOK = -1; //-1: automatic, 0: enable monitor, 1: disable monitor QApplication A(argc, argv); |