Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github_28344065
scrcpy
提交
277d4070
S
scrcpy
项目概览
github_28344065
/
scrcpy
与 Fork 源项目一致
从无法访问的项目Fork
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
scrcpy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
277d4070
编写于
3月 02, 2018
作者:
R
Romain Vimont
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hidpi test
上级
f5530f51
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
1 deletion
+52
-1
app/src/scrcpy.c
app/src/scrcpy.c
+18
-0
app/src/screen.c
app/src/screen.c
+23
-1
app/src/screen.h
app/src/screen.h
+11
-0
未找到文件。
app/src/scrcpy.c
浏览文件 @
277d4070
...
...
@@ -35,6 +35,21 @@ static struct input_manager input_manager = {
.
screen
=
&
screen
,
};
static
void
hidpi_fix_coordinates
(
Sint32
*
x
,
Sint32
*
y
)
{
struct
screen_sizes
sizes
=
screen_get_sizes
(
&
screen
);
Uint16
ww
=
sizes
.
window_size
.
width
;
Uint16
wh
=
sizes
.
window_size
.
height
;
Uint16
dw
=
sizes
.
drawable_size
.
width
;
Uint16
dh
=
sizes
.
drawable_size
.
height
;
printf
(
"window=%dx%d; drawable=%dx%d
\n
"
,
(
int
)
ww
,
(
int
)
wh
,
(
int
)
dw
,
(
int
)
dh
);
if
(
dw
&&
dw
!=
ww
)
{
*
x
=
((
Sint64
)
*
x
)
*
ww
/
dw
;
}
if
(
dh
&&
dh
!=
wh
)
{
*
y
=
((
Sint64
)
*
y
)
*
wh
/
dh
;
}
}
static
void
event_loop
(
void
)
{
SDL_Event
event
;
while
(
SDL_WaitEvent
(
&
event
))
{
...
...
@@ -72,14 +87,17 @@ static void event_loop(void) {
input_manager_process_key
(
&
input_manager
,
&
event
.
key
);
break
;
case
SDL_MOUSEMOTION
:
hidpi_fix_coordinates
(
&
event
.
motion
.
x
,
&
event
.
motion
.
y
);
input_manager_process_mouse_motion
(
&
input_manager
,
&
event
.
motion
);
break
;
case
SDL_MOUSEWHEEL
:
{
hidpi_fix_coordinates
(
&
event
.
wheel
.
x
,
&
event
.
wheel
.
y
);
input_manager_process_mouse_wheel
(
&
input_manager
,
&
event
.
wheel
);
break
;
}
case
SDL_MOUSEBUTTONDOWN
:
case
SDL_MOUSEBUTTONUP
:
{
hidpi_fix_coordinates
(
&
event
.
button
.
y
,
&
event
.
button
.
y
);
input_manager_process_mouse_button
(
&
input_manager
,
&
event
.
button
);
break
;
}
...
...
app/src/screen.c
浏览文件 @
277d4070
...
...
@@ -45,6 +45,27 @@ static struct size get_native_window_size(SDL_Window *window) {
return
size
;
}
// get the size of the window underlying drawable in pixels
// may differ from get_native_window_size() if hi-dpi is enabled
static
struct
size
get_native_drawable_size
(
SDL_Window
*
window
)
{
int
width
;
int
height
;
SDL_GL_GetDrawableSize
(
window
,
&
width
,
&
height
);
struct
size
size
;
size
.
width
=
width
;
size
.
height
=
height
;
return
size
;
}
// return both the native window size and native drawable size
struct
screen_sizes
screen_get_sizes
(
const
struct
screen
*
screen
)
{
struct
screen_sizes
sizes
;
sizes
.
window_size
=
get_native_window_size
(
screen
->
window
);
sizes
.
drawable_size
=
get_native_drawable_size
(
screen
->
window
);
return
sizes
;
}
// get the windowed window size
static
struct
size
get_window_size
(
const
struct
screen
*
screen
)
{
if
(
screen
->
fullscreen
)
{
...
...
@@ -141,7 +162,8 @@ SDL_bool screen_init_rendering(struct screen *screen, const char *device_name, s
struct
size
window_size
=
get_initial_optimal_size
(
frame_size
);
screen
->
window
=
SDL_CreateWindow
(
device_name
,
SDL_WINDOWPOS_UNDEFINED
,
SDL_WINDOWPOS_UNDEFINED
,
window_size
.
width
,
window_size
.
height
,
SDL_WINDOW_HIDDEN
|
SDL_WINDOW_RESIZABLE
);
window_size
.
width
,
window_size
.
height
,
SDL_WINDOW_HIDDEN
|
SDL_WINDOW_RESIZABLE
|
SDL_WINDOW_ALLOW_HIGHDPI
);
if
(
!
screen
->
window
)
{
LOGC
(
"Could not create window: %s"
,
SDL_GetError
());
return
SDL_FALSE
;
...
...
app/src/screen.h
浏览文件 @
277d4070
...
...
@@ -34,6 +34,15 @@ struct screen {
.fullscreen = SDL_FALSE, \
}
// the window and drawable size may differ if hi-dpi is enabled
struct
screen_sizes
{
// the size of the window client area, as reported by SDL_GetWindowSize()
struct
size
window_size
;
// the size of the window underlying drawable, as reported by
// SDL_GL_GetDrawableSize()
struct
size
drawable_size
;
};
// init SDL and set appropriate hints
SDL_bool
sdl_init_and_configure
(
void
);
...
...
@@ -66,4 +75,6 @@ void screen_resize_to_fit(struct screen *screen);
// resize window to 1:1 (pixel-perfect)
void
screen_resize_to_pixel_perfect
(
struct
screen
*
screen
);
struct
screen_sizes
screen_get_sizes
(
const
struct
screen
*
screen
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录