Skip to content

Commit 66b4528

Browse files
authored
Merge pull request anbox#1352 from pingplug/master
platform/sdl: improve user experience when resize window
2 parents c8eb992 + 7776a6b commit 66b4528

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/anbox/platform/sdl/window.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
#endif
2828

2929
namespace {
30-
constexpr const int window_resize_border{30};
31-
constexpr const int top_drag_area{50};
30+
constexpr const int window_resize_border{10};
31+
constexpr const int top_drag_area{42};
3232
constexpr const int button_size{32};
3333
constexpr const int button_margin{5};
34-
constexpr const int button_padding{4};
34+
constexpr const int button_padding{0};
3535
}
3636

3737
namespace anbox {
@@ -121,6 +121,17 @@ SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt,
121121
const auto border_size = graphics::dp_to_pixel(window_resize_border);
122122
const auto top_drag_area_height = graphics::dp_to_pixel(top_drag_area);
123123
const auto button_area_width = graphics::dp_to_pixel(button_size + button_padding * 2 + button_margin * 2);
124+
const auto flags = SDL_GetWindowFlags(window);
125+
126+
if (flags & SDL_WINDOW_FULLSCREEN)
127+
return SDL_HITTEST_NORMAL;
128+
129+
if (!(flags & SDL_WINDOW_RESIZABLE)) {
130+
if (pt->y < border_size)
131+
return SDL_HITTEST_DRAGGABLE;
132+
else
133+
return SDL_HITTEST_NORMAL;
134+
}
124135

125136
if (pt->y < top_drag_area_height) {
126137
if (pt->x > w - button_area_width && pt->x < w) {
@@ -131,9 +142,14 @@ SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt,
131142
return SDL_HITTEST_NORMAL;
132143
}
133144
return SDL_HITTEST_DRAGGABLE;
134-
} else if (pt->x < border_size && pt->y < border_size)
145+
}
146+
147+
if (flags & SDL_WINDOW_MAXIMIZED)
148+
return SDL_HITTEST_NORMAL;
149+
150+
if (pt->x < border_size && pt->y < border_size)
135151
return SDL_HITTEST_RESIZE_TOPLEFT;
136-
else if (pt->x > window_resize_border && pt->x < w - border_size && pt->y < border_size)
152+
else if (pt->x > border_size && pt->x < w - border_size && pt->y < border_size)
137153
return SDL_HITTEST_RESIZE_TOP;
138154
else if (pt->x > w - border_size && pt->y < border_size)
139155
return SDL_HITTEST_RESIZE_TOPRIGHT;

0 commit comments

Comments
 (0)