Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
8e7481fb
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,发现更多精彩内容 >>
未验证
提交
8e7481fb
编写于
3月 21, 2020
作者:
J
Jim
提交者:
GitHub
3月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2497 from keith-packard/linux-capture-randr-monitors
linux-capture: Use RandR monitors for screen information
上级
f44bfc23
96924553
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
8 deletion
+94
-8
plugins/linux-capture/xhelpers.c
plugins/linux-capture/xhelpers.c
+77
-1
plugins/linux-capture/xhelpers.h
plugins/linux-capture/xhelpers.h
+1
-1
plugins/linux-capture/xshm-input.c
plugins/linux-capture/xshm-input.c
+16
-6
未找到文件。
plugins/linux-capture/xhelpers.c
浏览文件 @
8e7481fb
...
...
@@ -104,6 +104,22 @@ bool randr_is_active(xcb_connection_t *xcb)
return
true
;
}
static
bool
randr_has_monitors
(
xcb_connection_t
*
xcb
)
{
xcb_randr_query_version_cookie_t
ver_c
;
xcb_randr_query_version_reply_t
*
ver_r
;
ver_c
=
xcb_randr_query_version
(
xcb
,
XCB_RANDR_MAJOR_VERSION
,
XCB_RANDR_MINOR_VERSION
);
ver_r
=
xcb_randr_query_version_reply
(
xcb
,
ver_c
,
0
);
if
(
!
ver_r
)
return
0
;
bool
ret
=
ver_r
->
major_version
>
1
||
ver_r
->
minor_version
>=
5
;
free
(
ver_r
);
return
ret
;
}
int
randr_screen_count
(
xcb_connection_t
*
xcb
)
{
if
(
!
xcb
)
...
...
@@ -111,6 +127,19 @@ int randr_screen_count(xcb_connection_t *xcb)
xcb_screen_t
*
screen
;
screen
=
xcb_setup_roots_iterator
(
xcb_get_setup
(
xcb
)).
data
;
if
(
randr_has_monitors
(
xcb
))
{
xcb_randr_get_monitors_cookie_t
mon_c
;
xcb_randr_get_monitors_reply_t
*
mon_r
;
mon_c
=
xcb_randr_get_monitors
(
xcb
,
screen
->
root
,
true
);
mon_r
=
xcb_randr_get_monitors_reply
(
xcb
,
mon_c
,
0
);
if
(
!
mon_r
)
return
0
;
int
count
=
xcb_randr_get_monitors_monitors_length
(
mon_r
);
free
(
mon_r
);
return
count
;
}
xcb_randr_get_screen_resources_cookie_t
res_c
;
xcb_randr_get_screen_resources_reply_t
*
res_r
;
...
...
@@ -124,11 +153,58 @@ int randr_screen_count(xcb_connection_t *xcb)
int
randr_screen_geo
(
xcb_connection_t
*
xcb
,
int_fast32_t
screen
,
int_fast32_t
*
x
,
int_fast32_t
*
y
,
int_fast32_t
*
w
,
int_fast32_t
*
h
,
xcb_screen_t
**
rscreen
)
int_fast32_t
*
h
,
xcb_screen_t
**
rscreen
,
char
**
name
)
{
xcb_screen_t
*
xscreen
;
xscreen
=
xcb_setup_roots_iterator
(
xcb_get_setup
(
xcb
)).
data
;
if
(
randr_has_monitors
(
xcb
))
{
xcb_randr_get_monitors_cookie_t
mon_c
;
xcb_randr_get_monitors_reply_t
*
mon_r
;
mon_c
=
xcb_randr_get_monitors
(
xcb
,
xscreen
->
root
,
true
);
mon_r
=
xcb_randr_get_monitors_reply
(
xcb
,
mon_c
,
0
);
if
(
!
mon_r
)
return
0
;
int
monitors
=
xcb_randr_get_monitors_monitors_length
(
mon_r
);
if
(
screen
<
0
||
screen
>=
monitors
)
{
free
(
mon_r
);
goto
fail
;
}
xcb_randr_monitor_info_iterator_t
mon_i
;
mon_i
=
xcb_randr_get_monitors_monitors_iterator
(
mon_r
);
int
s
;
for
(
s
=
0
;
s
<
screen
;
s
++
)
xcb_randr_monitor_info_next
(
&
mon_i
);
xcb_randr_monitor_info_t
*
mon
=
mon_i
.
data
;
*
x
=
mon
->
x
;
*
y
=
mon
->
y
;
*
w
=
mon
->
width
;
*
h
=
mon
->
height
;
if
(
rscreen
)
*
rscreen
=
xscreen
;
if
(
mon
->
name
&&
name
)
{
xcb_get_atom_name_cookie_t
atom_c
;
xcb_get_atom_name_reply_t
*
atom_r
;
atom_c
=
xcb_get_atom_name
(
xcb
,
mon
->
name
);
atom_r
=
xcb_get_atom_name_reply
(
xcb
,
atom_c
,
0
);
if
(
atom_r
)
{
*
name
=
strndup
(
xcb_get_atom_name_name
(
atom_r
),
xcb_get_atom_name_name_length
(
atom_r
));
free
(
atom_r
);
}
}
free
(
mon_r
);
return
0
;
}
xcb_randr_get_screen_resources_cookie_t
res_c
;
xcb_randr_get_screen_resources_reply_t
*
res_r
;
...
...
plugins/linux-capture/xhelpers.h
浏览文件 @
8e7481fb
...
...
@@ -94,7 +94,7 @@ int randr_screen_count(xcb_connection_t *xcb);
*/
int
randr_screen_geo
(
xcb_connection_t
*
xcb
,
int_fast32_t
screen
,
int_fast32_t
*
x
,
int_fast32_t
*
y
,
int_fast32_t
*
w
,
int_fast32_t
*
h
,
xcb_screen_t
**
rscreen
);
int_fast32_t
*
h
,
xcb_screen_t
**
rscreen
,
char
**
name
);
/**
* Get screen geometry for a X11 screen
...
...
plugins/linux-capture/xshm-input.c
浏览文件 @
8e7481fb
...
...
@@ -104,7 +104,7 @@ static int_fast32_t xshm_update_geometry(struct xshm_data *data)
if
(
data
->
use_randr
)
{
if
(
randr_screen_geo
(
data
->
xcb
,
data
->
screen_id
,
&
data
->
x_org
,
&
data
->
y_org
,
&
data
->
width
,
&
data
->
height
,
&
data
->
xcb_screen
)
<
0
)
{
&
data
->
xcb_screen
,
NULL
)
<
0
)
{
return
-
1
;
}
}
else
if
(
data
->
use_xinerama
)
{
...
...
@@ -308,21 +308,31 @@ static bool xshm_server_changed(obs_properties_t *props, obs_property_t *p,
:
xcb_setup_roots_length
(
xcb_get_setup
(
xcb
));
for
(
int_fast32_t
i
=
0
;
i
<
count
;
++
i
)
{
char
*
name
;
char
name_tmp
[
12
];
int_fast32_t
x
,
y
,
w
,
h
;
x
=
y
=
w
=
h
=
0
;
name
=
NULL
;
if
(
randr
)
randr_screen_geo
(
xcb
,
i
,
&
x
,
&
y
,
&
w
,
&
h
,
NULL
);
randr_screen_geo
(
xcb
,
i
,
&
x
,
&
y
,
&
w
,
&
h
,
NULL
,
&
name
);
else
if
(
xinerama
)
xinerama_screen_geo
(
xcb
,
i
,
&
x
,
&
y
,
&
w
,
&
h
);
else
x11_screen_geo
(
xcb
,
i
,
&
w
,
&
h
);
if
(
name
==
NULL
)
{
sprintf
(
name_tmp
,
"%"
PRIuFAST32
,
i
);
name
=
name_tmp
;
}
dstr_printf
(
&
screen_info
,
"Screen %"
PRIuFAST32
" (%"
PRIuFAST32
"x%"
PRIuFAST32
" @ %"
PRIuFAST32
",%"
PRIuFAST32
")"
,
i
,
w
,
h
,
x
,
y
);
"Screen %s (%"
PRIuFAST32
"x%"
PRIuFAST32
" @ %"
PRIuFAST32
",%"
PRIuFAST32
")"
,
name
,
w
,
h
,
x
,
y
);
if
(
name
!=
name_tmp
)
free
(
name
);
if
(
h
>
0
&&
w
>
0
)
obs_property_list_add_int
(
screens
,
screen_info
.
array
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录