Skip to content

Commit a175cc9

Browse files
committed
ssd: Back to using server-side decoration
Anbox uses client-side decoration really badly. Some games don't have a title bar and click misplaced. And because of the lack of some things like _GTK_FRAME_EXTENTS in GTK+, the zoom area must be within the real window range. This makes buttons that occupy the border of the window difficult to click (Although a patch has made border smaller). So, I forked Anbox and made it use server-side decoration again. NOTE: You must use this fork with a customed Android image. (You can get source here: https://github.com/thdaemon/platform_manifests)
1 parent 6a3f886 commit a175cc9

File tree

1 file changed

+1
-63
lines changed

1 file changed

+1
-63
lines changed

src/anbox/platform/sdl/window.cpp

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Window::Window(const std::shared_ptr<Renderer> &renderer,
5959
// initializing GL here will cause a surface to be created and the
6060
// renderer will attempt to create one too which will not work as
6161
// only a single surface per EGLNativeWindowType is supported.
62-
std::uint32_t flags = SDL_WINDOW_BORDERLESS;
62+
std::uint32_t flags = 0;
6363
if (resizable)
6464
flags |= SDL_WINDOW_RESIZABLE;
6565

@@ -72,10 +72,6 @@ Window::Window(const std::shared_ptr<Renderer> &renderer,
7272
BOOST_THROW_EXCEPTION(std::runtime_error(message));
7373
}
7474

75-
if (utils::get_env_value("ANBOX_NO_SDL_WINDOW_HIT_TEST", "false") == "false")
76-
if (SDL_SetWindowHitTest(window_, &Window::on_window_hit, this) < 0)
77-
BOOST_THROW_EXCEPTION(std::runtime_error("Failed to register for window hit test"));
78-
7975
SDL_SysWMinfo info;
8076
SDL_VERSION(&info.version);
8177
SDL_GetWindowWMInfo(window_, &info);
@@ -112,61 +108,6 @@ Window::~Window() {
112108
if (window_) SDL_DestroyWindow(window_);
113109
}
114110

115-
SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data) {
116-
auto platform_window = reinterpret_cast<Window*>(data);
117-
118-
int w = 0, h = 0;
119-
SDL_GetWindowSize(window, &w, &h);
120-
121-
const auto border_size = graphics::dp_to_pixel(window_resize_border);
122-
const auto top_drag_area_height = graphics::dp_to_pixel(top_drag_area);
123-
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-
}
135-
136-
if (pt->y < top_drag_area_height) {
137-
if (pt->x > w - button_area_width && pt->x < w) {
138-
platform_window->close();
139-
return SDL_HITTEST_NORMAL;
140-
} else if (pt->x > w - button_area_width * 2 && pt->x < w - button_area_width) {
141-
platform_window->switch_window_state();
142-
return SDL_HITTEST_NORMAL;
143-
}
144-
return SDL_HITTEST_DRAGGABLE;
145-
}
146-
147-
if (flags & SDL_WINDOW_MAXIMIZED)
148-
return SDL_HITTEST_NORMAL;
149-
150-
if (pt->x < border_size && pt->y < border_size)
151-
return SDL_HITTEST_RESIZE_TOPLEFT;
152-
else if (pt->x > border_size && pt->x < w - border_size && pt->y < border_size)
153-
return SDL_HITTEST_RESIZE_TOP;
154-
else if (pt->x > w - border_size && pt->y < border_size)
155-
return SDL_HITTEST_RESIZE_TOPRIGHT;
156-
else if (pt->x > w - border_size && pt->y > border_size && pt->y < h - border_size)
157-
return SDL_HITTEST_RESIZE_RIGHT;
158-
else if (pt->x > w - border_size && pt->y > h - border_size)
159-
return SDL_HITTEST_RESIZE_BOTTOMRIGHT;
160-
else if (pt->x < w - border_size && pt->x > border_size && pt->y > h - border_size)
161-
return SDL_HITTEST_RESIZE_BOTTOM;
162-
else if (pt->x < border_size && pt->y > h - border_size)
163-
return SDL_HITTEST_RESIZE_BOTTOMLEFT;
164-
else if (pt->x < border_size && pt->y < h - border_size && pt->y > border_size)
165-
return SDL_HITTEST_RESIZE_LEFT;
166-
167-
return SDL_HITTEST_NORMAL;
168-
}
169-
170111
void Window::close() {
171112
if (observer_)
172113
observer_->window_deleted(id_);
@@ -202,9 +143,6 @@ void Window::process_event(const SDL_Event &event) {
202143
case SDL_WINDOWEVENT_HIDDEN:
203144
break;
204145
case SDL_WINDOWEVENT_CLOSE:
205-
if (observer_)
206-
observer_->window_deleted(id_);
207-
208146
close();
209147
break;
210148
default:

0 commit comments

Comments
 (0)