Skip to content

Use windows style screen name #93

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove unused deviceIndex
Screen name won't be indentical after szDevice name prepend,
so remove unused deviceIndex.

Signed-off-by: maybetaken <[email protected]>
  • Loading branch information
maybetaken committed Jan 26, 2024
commit e566c178fe879ad25692797e6d3b7ec255127f35
15 changes: 2 additions & 13 deletions src/plugins/platforms/windows/qwindowsscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,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 @@ -415,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