Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
e93d44dd
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e93d44dd
编写于
3月 18, 2020
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
UI: Get actual projector monitor name on windows
上级
113af534
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
91 addition
and
9 deletion
+91
-9
UI/platform-windows.cpp
UI/platform-windows.cpp
+84
-0
UI/platform.hpp
UI/platform.hpp
+1
-0
UI/window-basic-main.cpp
UI/window-basic-main.cpp
+6
-9
未找到文件。
UI/platform-windows.cpp
浏览文件 @
e93d44dd
...
...
@@ -19,6 +19,7 @@
#include <sstream>
#include "obs-config.h"
#include "obs-app.hpp"
#include "qt-wrappers.hpp"
#include "platform.hpp"
#include <util/windows/win-version.h>
...
...
@@ -330,3 +331,86 @@ RunOnceMutex GetRunOnceMutex(bool &already_running)
RunOnceMutex
rom
(
h
?
new
RunOnceMutexData
(
h
)
:
nullptr
);
return
rom
;
}
struct
MonitorData
{
const
wchar_t
*
id
;
MONITORINFOEX
info
;
bool
found
;
};
static
BOOL
CALLBACK
GetMonitorCallback
(
HMONITOR
monitor
,
HDC
,
LPRECT
,
LPARAM
param
)
{
MonitorData
*
data
=
(
MonitorData
*
)
param
;
if
(
GetMonitorInfoW
(
monitor
,
&
data
->
info
))
{
if
(
wcscmp
(
data
->
info
.
szDevice
,
data
->
id
)
==
0
)
{
data
->
found
=
true
;
return
false
;
}
}
return
true
;
}
#define GENERIC_MONITOR_NAME QStringLiteral("Generic PnP Monitor")
QString
GetMonitorName
(
const
QString
&
id
)
{
MonitorData
data
=
{};
data
.
id
=
(
const
wchar_t
*
)
id
.
utf16
();
data
.
info
.
cbSize
=
sizeof
(
data
.
info
);
EnumDisplayMonitors
(
nullptr
,
nullptr
,
GetMonitorCallback
,
(
LPARAM
)
&
data
);
if
(
!
data
.
found
)
{
return
GENERIC_MONITOR_NAME
;
}
UINT32
numPath
,
numMode
;
if
(
!
GetDisplayConfigBufferSizes
(
QDC_ONLY_ACTIVE_PATHS
,
&
numPath
,
&
numMode
)
==
ERROR_SUCCESS
)
{
return
GENERIC_MONITOR_NAME
;
}
std
::
vector
<
DISPLAYCONFIG_PATH_INFO
>
paths
(
numPath
);
std
::
vector
<
DISPLAYCONFIG_MODE_INFO
>
modes
(
numMode
);
if
(
!
QueryDisplayConfig
(
QDC_ONLY_ACTIVE_PATHS
,
&
numPath
,
paths
.
data
(),
&
numMode
,
modes
.
data
(),
nullptr
)
==
ERROR_SUCCESS
)
{
return
GENERIC_MONITOR_NAME
;
}
DISPLAYCONFIG_TARGET_DEVICE_NAME
target
;
bool
found
=
false
;
paths
.
resize
(
numPath
);
for
(
size_t
i
=
0
;
i
<
numPath
;
++
i
)
{
const
DISPLAYCONFIG_PATH_INFO
&
path
=
paths
[
i
];
DISPLAYCONFIG_SOURCE_DEVICE_NAME
s
;
s
.
header
.
type
=
DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME
;
s
.
header
.
size
=
sizeof
(
s
);
s
.
header
.
adapterId
=
path
.
sourceInfo
.
adapterId
;
s
.
header
.
id
=
path
.
sourceInfo
.
id
;
if
(
DisplayConfigGetDeviceInfo
(
&
s
.
header
)
==
ERROR_SUCCESS
&&
wcscmp
(
data
.
info
.
szDevice
,
s
.
viewGdiDeviceName
)
==
0
)
{
target
.
header
.
type
=
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME
;
target
.
header
.
size
=
sizeof
(
target
);
target
.
header
.
adapterId
=
path
.
sourceInfo
.
adapterId
;
target
.
header
.
id
=
path
.
targetInfo
.
id
;
found
=
DisplayConfigGetDeviceInfo
(
&
target
.
header
)
==
ERROR_SUCCESS
;
break
;
}
}
if
(
!
found
)
{
return
GENERIC_MONITOR_NAME
;
}
return
QString
::
fromWCharArray
(
target
.
monitorFriendlyDeviceName
);
}
UI/platform.hpp
浏览文件 @
e93d44dd
...
...
@@ -60,6 +60,7 @@ public:
};
RunOnceMutex
GetRunOnceMutex
(
bool
&
already_running
);
QString
GetMonitorName
(
const
QString
&
id
);
#endif
#ifdef __APPLE__
...
...
UI/window-basic-main.cpp
浏览文件 @
e93d44dd
...
...
@@ -29,6 +29,7 @@
#include <QColorDialog>
#include <QSizePolicy>
#include <QScrollBar>
#include <QTextStream>
#include <util/dstr.h>
#include <util/util.hpp>
...
...
@@ -4173,15 +4174,11 @@ void OBSBasic::AddProjectorMenuMonitors(QMenu *parent, QObject *target,
QRect
screenGeometry
=
screen
->
geometry
();
QString
name
=
""
;
#ifdef _WIN32
DISPLAY_DEVICE
ddev
;
ddev
.
cb
=
sizeof
(
ddev
);
BPtr
<
wchar_t
>
wideName
;
os_utf8_to_wcs_ptr
(
screen
->
name
().
toStdString
().
c_str
(),
0
,
&
wideName
);
EnumDisplayDevices
(
wideName
,
0
,
&
ddev
,
1
);
BPtr
<
char
>
newName
;
os_wcs_to_utf8_ptr
(
ddev
.
DeviceString
,
0
,
&
newName
);
name
=
newName
;
QTextStream
fullname
(
&
name
);
fullname
<<
GetMonitorName
(
screen
->
name
());
fullname
<<
" ("
;
fullname
<<
(
i
+
1
);
fullname
<<
")"
;
#elif defined(__APPLE__)
name
=
screen
->
name
();
#elif QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录