Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Obs Studio
提交
d1de03c0
O
Obs Studio
项目概览
小白菜888
/
Obs Studio
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Obs Studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d1de03c0
编写于
5月 03, 2017
作者:
C
cg2121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
frontend-tools: Add automatic scene switcher for Linux
上级
4684294b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
223 addition
and
18 deletion
+223
-18
UI/frontend-plugins/frontend-tools/CMakeLists.txt
UI/frontend-plugins/frontend-tools/CMakeLists.txt
+10
-10
UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp
...ontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp
+211
-0
UI/frontend-plugins/frontend-tools/frontend-tools.c
UI/frontend-plugins/frontend-tools/frontend-tools.c
+2
-8
未找到文件。
UI/frontend-plugins/frontend-tools/CMakeLists.txt
浏览文件 @
d1de03c0
...
...
@@ -5,16 +5,10 @@ if(APPLE)
include_directories
(
${
COCOA
}
)
endif
()
if
(
WIN32 OR APPLE
)
set
(
frontend-tools_HEADERS
auto-scene-switcher.hpp
)
set
(
frontend-tools_SOURCES
auto-scene-switcher.cpp
)
set
(
frontend-tools_UI
forms/auto-scene-switcher.ui
)
if
(
UNIX
)
find_package
(
X11 REQUIRED
)
link_libraries
(
${
X11_LIBRARIES
}
)
include_directories
(
${
X11_INCLUDE_DIR
}
)
endif
()
configure_file
(
...
...
@@ -24,16 +18,19 @@ configure_file(
set
(
frontend-tools_HEADERS
${
frontend-tools_HEADERS
}
"
${
CMAKE_BINARY_DIR
}
/config/frontend-tools-config.h"
auto-scene-switcher.hpp
output-timer.hpp
tool-helpers.hpp
)
set
(
frontend-tools_SOURCES
${
frontend-tools_SOURCES
}
auto-scene-switcher.cpp
frontend-tools.c
output-timer.cpp
)
set
(
frontend-tools_UI
${
frontend-tools_UI
}
forms/auto-scene-switcher.ui
forms/output-timer.ui
)
...
...
@@ -64,6 +61,9 @@ elseif(APPLE)
set
(
frontend-tools_PLATFORM_LIBS
${
COCOA
}
)
else
()
set
(
frontend-tools_PLATFORM_SOURCES
auto-scene-switcher-nix.cpp
)
endif
()
qt5_wrap_ui
(
frontend-tools_UI_HEADERS
...
...
UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp
0 → 100644
浏览文件 @
d1de03c0
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#undef Bool
#undef CursorShape
#undef Expose
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef None
#undef Status
#undef Unsorted
#include <util/platform.h>
#include "auto-scene-switcher.hpp"
using
namespace
std
;
static
Display
*
xdisplay
=
0
;
Display
*
disp
()
{
if
(
!
xdisplay
)
xdisplay
=
XOpenDisplay
(
NULL
);
return
xdisplay
;
}
void
cleanupDisplay
()
{
if
(
!
xdisplay
)
return
;
XCloseDisplay
(
xdisplay
);
xdisplay
=
0
;
}
static
bool
ewmhIsSupported
()
{
Display
*
display
=
disp
();
Atom
netSupportingWmCheck
=
XInternAtom
(
display
,
"_NET_SUPPORTING_WM_CHECK"
,
true
);
Atom
actualType
;
int
format
=
0
;
unsigned
long
num
=
0
,
bytes
=
0
;
unsigned
char
*
data
=
NULL
;
Window
ewmh_window
=
0
;
int
status
=
XGetWindowProperty
(
display
,
DefaultRootWindow
(
display
),
netSupportingWmCheck
,
0L
,
1L
,
false
,
XA_WINDOW
,
&
actualType
,
&
format
,
&
num
,
&
bytes
,
&
data
);
if
(
status
==
Success
)
{
if
(
num
>
0
)
{
ewmh_window
=
((
Window
*
)
data
)[
0
];
}
if
(
data
)
{
XFree
(
data
);
data
=
NULL
;
}
}
if
(
ewmh_window
)
{
status
=
XGetWindowProperty
(
display
,
ewmh_window
,
netSupportingWmCheck
,
0L
,
1L
,
false
,
XA_WINDOW
,
&
actualType
,
&
format
,
&
num
,
&
bytes
,
&
data
);
if
(
status
!=
Success
||
num
==
0
||
ewmh_window
!=
((
Window
*
)
data
)[
0
])
{
ewmh_window
=
0
;
}
if
(
status
==
Success
&&
data
)
{
XFree
(
data
);
}
}
return
ewmh_window
!=
0
;
}
static
std
::
vector
<
Window
>
getTopLevelWindows
()
{
std
::
vector
<
Window
>
res
;
res
.
resize
(
0
);
if
(
!
ewmhIsSupported
())
{
return
res
;
}
Atom
netClList
=
XInternAtom
(
disp
(),
"_NET_CLIENT_LIST"
,
true
);
Atom
actualType
;
int
format
;
unsigned
long
num
,
bytes
;
Window
*
data
=
0
;
for
(
int
i
=
0
;
i
<
ScreenCount
(
disp
());
++
i
)
{
Window
rootWin
=
RootWindow
(
disp
(),
i
);
int
status
=
XGetWindowProperty
(
disp
(),
rootWin
,
netClList
,
0L
,
~
0L
,
false
,
AnyPropertyType
,
&
actualType
,
&
format
,
&
num
,
&
bytes
,
(
uint8_t
**
)
&
data
);
if
(
status
!=
Success
)
{
continue
;
}
for
(
unsigned
long
i
=
0
;
i
<
num
;
++
i
)
res
.
emplace_back
(
data
[
i
]);
XFree
(
data
);
}
return
res
;
}
static
std
::
string
GetWindowTitle
(
size_t
i
)
{
Window
w
=
getTopLevelWindows
().
at
(
i
);
std
::
string
windowTitle
;
char
*
name
;
int
status
=
XFetchName
(
disp
(),
w
,
&
name
);
if
(
status
>=
Success
&&
name
!=
nullptr
)
{
std
::
string
str
(
name
);
windowTitle
=
str
;
}
XFree
(
name
);
return
windowTitle
;
}
void
GetWindowList
(
vector
<
string
>
&
windows
)
{
windows
.
resize
(
0
);
for
(
size_t
i
=
0
;
i
<
getTopLevelWindows
().
size
();
++
i
){
if
(
GetWindowTitle
(
i
)
!=
""
)
windows
.
emplace_back
(
GetWindowTitle
(
i
));
}
}
void
GetCurrentWindowTitle
(
string
&
title
)
{
if
(
!
ewmhIsSupported
())
{
return
;
}
Atom
active
=
XInternAtom
(
disp
(),
"_NET_ACTIVE_WINDOW"
,
true
);
Atom
actualType
;
int
format
;
unsigned
long
num
,
bytes
;
Window
*
data
=
0
;
char
*
name
;
Window
rootWin
=
RootWindow
(
disp
(),
0
);
XGetWindowProperty
(
disp
(),
rootWin
,
active
,
0L
,
~
0L
,
false
,
AnyPropertyType
,
&
actualType
,
&
format
,
&
num
,
&
bytes
,
(
uint8_t
**
)
&
data
);
int
status
=
XFetchName
(
disp
(),
data
[
0
],
&
name
);
if
(
status
>=
Success
&&
name
!=
nullptr
)
{
std
::
string
str
(
name
);
title
=
str
;
}
XFree
(
name
);
}
UI/frontend-plugins/frontend-tools/frontend-tools.c
浏览文件 @
d1de03c0
...
...
@@ -4,10 +4,8 @@
OBS_DECLARE_MODULE
()
OBS_MODULE_USE_DEFAULT_LOCALE
(
"frontend-tools"
,
"en-US"
)
#if defined(_WIN32) || defined(__APPLE__)
void
InitSceneSwitcher
();
void
FreeSceneSwitcher
();
#endif
#if defined(_WIN32) && BUILD_CAPTIONS
void
InitCaptions
();
...
...
@@ -19,23 +17,19 @@ void FreeOutputTimer();
bool
obs_module_load
(
void
)
{
#if defined(_WIN32) || defined(__APPLE__)
InitSceneSwitcher
();
#endif
#if defined(_WIN32) && BUILD_CAPTIONS
InitCaptions
();
#endif
InitSceneSwitcher
();
InitOutputTimer
();
return
true
;
}
void
obs_module_unload
(
void
)
{
#if defined(_WIN32) || defined(__APPLE__)
FreeSceneSwitcher
();
#endif
#if defined(_WIN32) && BUILD_CAPTIONS
FreeCaptions
();
#endif
FreeSceneSwitcher
();
FreeOutputTimer
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录