Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github_28344065
scrcpy
提交
beb524b9
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,体验更适合开发者的 AI 搜索 >>
提交
beb524b9
编写于
5月 07, 2020
作者:
R
Romain Vimont
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix resize_to_fit scaling
上级
084dd5e8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
12 deletion
+23
-12
app/src/input_manager.c
app/src/input_manager.c
+3
-2
app/src/screen.c
app/src/screen.c
+13
-10
app/src/screen.h
app/src/screen.h
+7
-0
未找到文件。
app/src/input_manager.c
浏览文件 @
beb524b9
...
...
@@ -527,8 +527,9 @@ input_manager_process_mouse_button(struct input_manager *im,
// double-click on black borders resize to fit the device screen
if
(
event
->
button
==
SDL_BUTTON_LEFT
&&
event
->
clicks
==
2
)
{
int
x
=
event
->
x
;
int
y
=
event
->
y
;
int32_t
x
=
event
->
x
;
int32_t
y
=
event
->
y
;
screen_hidpi_scale_coords
(
im
->
screen
,
&
x
,
&
y
);
SDL_Rect
*
r
=
&
im
->
screen
->
rect
;
bool
outside
=
x
<
r
->
x
||
x
>=
r
->
x
+
r
->
w
||
y
<
r
->
y
||
y
>=
r
->
y
+
r
->
h
;
...
...
app/src/screen.c
浏览文件 @
beb524b9
...
...
@@ -611,16 +611,7 @@ screen_convert_to_frame_coords(struct screen *screen, int32_t x, int32_t y) {
int32_t
w
=
screen
->
content_size
.
width
;
int32_t
h
=
screen
->
content_size
.
height
;
// take the HiDPI scaling (dw/ww and dh/wh) into account
int
ww
,
wh
,
dw
,
dh
;
SDL_GetWindowSize
(
screen
->
window
,
&
ww
,
&
wh
);
SDL_GL_GetDrawableSize
(
screen
->
window
,
&
dw
,
&
dh
);
LOGI
(
"window_size = %dx%d, drawable_size = %dx%d"
,
ww
,
wh
,
dw
,
dh
);
// scale for HiDPI (64 bits for intermediate multiplications)
x
=
(
int64_t
)
x
*
dw
/
ww
;
y
=
(
int64_t
)
y
*
dh
/
wh
;
screen_hidpi_scale_coords
(
screen
,
&
x
,
&
y
);
x
=
(
int64_t
)
(
x
-
screen
->
rect
.
x
)
*
w
/
screen
->
rect
.
w
;
y
=
(
int64_t
)
(
y
-
screen
->
rect
.
y
)
*
h
/
screen
->
rect
.
h
;
...
...
@@ -653,3 +644,15 @@ screen_convert_to_frame_coords(struct screen *screen, int32_t x, int32_t y) {
}
return
result
;
}
void
screen_hidpi_scale_coords
(
struct
screen
*
screen
,
int32_t
*
x
,
int32_t
*
y
)
{
// take the HiDPI scaling (dw/ww and dh/wh) into account
int
ww
,
wh
,
dw
,
dh
;
SDL_GetWindowSize
(
screen
->
window
,
&
ww
,
&
wh
);
SDL_GL_GetDrawableSize
(
screen
->
window
,
&
dw
,
&
dh
);
// scale for HiDPI (64 bits for intermediate multiplications)
*
x
=
(
int64_t
)
*
x
*
dw
/
ww
;
*
y
=
(
int64_t
)
*
y
*
dh
/
wh
;
}
app/src/screen.h
浏览文件 @
beb524b9
...
...
@@ -127,4 +127,11 @@ screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
struct
point
screen_convert_to_frame_coords
(
struct
screen
*
screen
,
int32_t
x
,
int32_t
y
);
// Convert coordinates from window to drawable.
// Events are expressed in window coordinates, but content is expressed in
// drawable coordinates. They are the same if HiDPI scaling is 1, but differ
// otherwise.
void
screen_hidpi_scale_coords
(
struct
screen
*
screen
,
int32_t
*
x
,
int32_t
*
y
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录