diff options
Diffstat (limited to 'src-qt5/core/libLumina/LuminaRandR-X11.cpp')
-rw-r--r-- | src-qt5/core/libLumina/LuminaRandR-X11.cpp | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/src-qt5/core/libLumina/LuminaRandR-X11.cpp b/src-qt5/core/libLumina/LuminaRandR-X11.cpp index 64712fd0..85251b64 100644 --- a/src-qt5/core/libLumina/LuminaRandR-X11.cpp +++ b/src-qt5/core/libLumina/LuminaRandR-X11.cpp @@ -12,10 +12,35 @@ #include <QDebug> #include <QX11Info> +static QString atomToName(xcb_atom_t atom){ + xcb_get_atom_name_reply_t *nreply = xcb_get_atom_name_reply(QX11Info::connection(), xcb_get_atom_name_unchecked(QX11Info::connection(), atom), NULL); + QString name = QString::fromLocal8Bit(xcb_get_atom_name_name(nreply), xcb_get_atom_name_name_length(nreply)); + free(nreply); + return name; +}; + +//More efficient method for converting lots of atoms to strings +static QStringList atomsToNames(xcb_atom_t *atoms, unsigned int num){ + //qDebug() << "atomsToNames:" << num; + QList< xcb_get_atom_name_cookie_t > cookies; + //qDebug() << " - Get cookies"; + for(unsigned int i=0; i<num; i++){ cookies << xcb_get_atom_name_unchecked(QX11Info::connection(), atoms[i]); } + QStringList names; + //qDebug() << " - Get names"; + for(int i=0; i<cookies.length(); i++){ + xcb_get_atom_name_reply_t *nreply = xcb_get_atom_name_reply(QX11Info::connection(), cookies[i], NULL); + if(nreply==0){ continue; } + names << QString::fromLocal8Bit(xcb_get_atom_name_name(nreply), xcb_get_atom_name_name_length(nreply)); + free(nreply); + } + return names; +}; + class OutputDevice::p_objects{ public: xcb_atom_t monitor_atom; QList<xcb_randr_output_t> outputs; //the actual output devices used by the monitor + }; //Global Listing of Devices @@ -33,9 +58,10 @@ QList<OutputDevice> OutputDevice::availableMonitors(){ while(iter.rem>0){ qDebug() << "Found Monitor:"; //qDebug() << " Index:" << iter.index << "Rem:" << iter.rem; - xcb_get_atom_name_reply_t *nreply = xcb_get_atom_name_reply(QX11Info::connection(), xcb_get_atom_name_unchecked(QX11Info::connection(), iter.data->name), NULL); + QString name = atomToName(iter.data->name); + /*xcb_get_atom_name_reply_t *nreply = xcb_get_atom_name_reply(QX11Info::connection(), xcb_get_atom_name_unchecked(QX11Info::connection(), iter.data->name), NULL); QString name = QString::fromLocal8Bit(xcb_get_atom_name_name(nreply), xcb_get_atom_name_name_length(nreply)); - free(nreply); + free(nreply);*/ qDebug() << " - Name:" << iter.data->name << name; qDebug() << " - Primary:" << (iter.data->primary == 1); @@ -102,8 +128,16 @@ OutputDeviceList::OutputDeviceList(){ qDebug() << "Probing Screen Resources:"; qDebug() << " - Number of Outputs:" << outputnum; qDebug() << " - Number of CRTC's:" << xcb_randr_get_screen_resources_crtcs_length(reply); - qDebug() << " - Number of Modes:" << xcb_randr_get_screen_resources_modes_length(reply); - qDebug() << " - Number of Names:" << xcb_randr_get_screen_resources_names_length(reply); + int mode_len =xcb_randr_get_screen_resources_modes_length(reply); + qDebug() << " - Modes:" << mode_len; + for(int m=0; m<mode_len; m++){ + xcb_randr_mode_info_t mode = xcb_randr_get_screen_resources_modes(reply)[m]; + qDebug() << " -- Mode:" << mode.id; + qDebug() << " - Size:" << mode.width <<"x"<<mode.height; + } + //qDebug() << " -- " << atomsToNames( (xcb_atom_t*) xcb_randr_get_screen_resources_modes(reply), xcb_randr_get_screen_resources_modes_length(reply) ); + qDebug() << " - Names:" << xcb_randr_get_screen_resources_names_length(reply); + //qDebug() << " -- " << atomsToNames( (xcb_atom_t*) xcb_randr_get_screen_resources_names(reply), xcb_randr_get_screen_resources_names_length(reply)); for(int i=0; i<outputnum; i++){ xcb_randr_output_t output = xcb_randr_get_screen_resources_outputs(reply)[i]; //Now display the info about this output @@ -111,16 +145,19 @@ OutputDeviceList::OutputDeviceList(){ xcb_randr_get_output_info_unchecked(QX11Info::connection(), output, QX11Info::appTime()), NULL); qDebug() << "==== Output Information #"+QString::number(i); + + //Modes qDebug() << "Number of Modes:" << xcb_randr_get_output_info_modes_length(info); + + + //Clones qDebug() << "Number of Clones:" << xcb_randr_get_output_info_clones_length(info); //Names int name_len = xcb_randr_get_output_info_name_length(info); - qDebug() << "Number of Names:" << name_len; + qDebug() << "Names:" << atomsToNames( (xcb_atom_t*) xcb_randr_get_output_info_name(info), name_len); for(int n=0; n<name_len; n++){ - xcb_get_atom_name_reply_t *nreply = xcb_get_atom_name_reply(QX11Info::connection(), xcb_get_atom_name_unchecked(QX11Info::connection(), xcb_randr_get_output_info_name(info)[n]), NULL); - QString name = QString::fromLocal8Bit(xcb_get_atom_name_name(nreply), xcb_get_atom_name_name_length(nreply)); - free(nreply); + QString name = atomToName( xcb_randr_get_output_info_name(info)[n] ); qDebug() << " -- " << name; } @@ -133,17 +170,16 @@ OutputDeviceList::OutputDeviceList(){ for(int p=0; p<pinfo_len; p++){ xcb_atom_t atom = xcb_randr_list_output_properties_atoms(pinfo)[p]; //Property Name - xcb_get_atom_name_reply_t *nreply = xcb_get_atom_name_reply(QX11Info::connection(), xcb_get_atom_name_unchecked(QX11Info::connection(), atom), NULL); - QString name = QString::fromLocal8Bit(xcb_get_atom_name_name(nreply), xcb_get_atom_name_name_length(nreply)); - free(nreply); + QString name = atomToName(atom); //Property Value xcb_randr_query_output_property_reply_t *pvalue = xcb_randr_query_output_property_reply(QX11Info::connection(), xcb_randr_query_output_property_unchecked(QX11Info::connection(), output, atom), NULL); - QStringList values; //need to read values - for(int v=0; v<xcb_randr_query_output_property_valid_values_length(pvalue); v++){ - values << QString::number(xcb_randr_query_output_property_valid_values(pvalue)[v] ); - } + QStringList values = atomsToNames ( (xcb_atom_t*) xcb_randr_query_output_property_valid_values(pvalue), xcb_randr_query_output_property_valid_values_length(pvalue) ); //need to read values + /*for(int v=0; v<xcb_randr_query_output_property_valid_values_length(pvalue); v++){ + //values << QString::number(xcb_randr_query_output_property_valid_values(pvalue)[v] ); + values << atomToName( xcb_randr_query_output_property_valid_values(pvalue)[v] ); + }*/ free(pvalue); qDebug() << " -- " << name << "=" << values; |