Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use windows style screen name #93

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/plugins/platforms/windows/qwindowsscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
setMonitorDataFromSetupApi(*data, pathGroup);
}
if (data->name.isEmpty())
data->name = data->deviceName;
data->name.append(u"Internal Display");
data->name.prepend(u": ");
data->name.prepend(data->deviceName);
if (data->deviceName == u"WinDisc") {
data->flags |= QWindowsScreenData::LockScreen;
} else {
Expand Down Expand Up @@ -342,16 +344,7 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM
QWindowsScreenData data;
if (monitorData(hMonitor, &data)) {
auto *result = reinterpret_cast<WindowsScreenDataList *>(p);
auto it = std::find_if(result->rbegin(), result->rend(),
[&data](QWindowsScreenData i){ return i.name == data.name; });
if (it != result->rend()) {
int previousIndex = 1;
if (it->deviceIndex.has_value())
previousIndex = it->deviceIndex.value();
else
(*it).deviceIndex = 1;
data.deviceIndex = previousIndex + 1;
}

// QWindowSystemInterface::handleScreenAdded() documentation specifies that first
// added screen will be the primary screen, so order accordingly.
// Note that the side effect of this policy is that there is no way to change primary
Expand Down Expand Up @@ -413,9 +406,7 @@ QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) :

QString QWindowsScreen::name() const
{
return m_data.deviceIndex.has_value()
? (u"%1 (%2)"_s).arg(m_data.name, QString::number(m_data.deviceIndex.value()))
: m_data.name;
return m_data.name;
}

QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const
Expand Down
1 change: 0 additions & 1 deletion src/plugins/platforms/windows/qwindowsscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct QWindowsScreenData
HMONITOR hMonitor = nullptr;
QString deviceName;
QString devicePath;
std::optional<int> deviceIndex = std::nullopt;
};

class QWindowsScreen : public QPlatformScreen, public QNativeInterface::QWindowsScreen
Expand Down