refactor: cleanup + improve focus
This commit is contained in:
48
xdg.c
48
xdg.c
@@ -95,7 +95,7 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
}
|
||||
struct diyac_view * root = diyac_get_root_view(toplevel);
|
||||
wl_list_remove(&toplevel->link);
|
||||
if(root)
|
||||
if(root && root->mapped)
|
||||
{
|
||||
diyac_focus_view(root, true);
|
||||
}
|
||||
@@ -141,21 +141,13 @@ static void xdg_toplevel_request_maximize(
|
||||
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_maximize);
|
||||
// wlr_wl_output* output = get_wl_output_from_surface(struct wlr_wl_backend *wl,
|
||||
// struct wl_surface *surface);
|
||||
/*
|
||||
struct wlr_output *output = wlr_output_layout_output_at(
|
||||
toplevel->server->output_layout, toplevel->server->seat.cursor->x,
|
||||
toplevel->server->seat.cursor->y);
|
||||
if (!output)
|
||||
if (!toplevel->mapped)
|
||||
{
|
||||
wlr_log(WLR_ERROR,
|
||||
"No output available to assign layer surface");
|
||||
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
||||
wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, false);
|
||||
// the view has not yet be mapped, don't maximize it
|
||||
wlr_log(WLR_INFO, "The view has not yet be mapped, ignore maximize request");
|
||||
return;
|
||||
}
|
||||
struct diyac_output * target_output = output->data;
|
||||
*/
|
||||
wlr_log(WLR_INFO, "Request maximize");
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
if (toplevel->state == DIYAC_VIEW_MAXIMIZE)
|
||||
@@ -166,6 +158,7 @@ static void xdg_toplevel_request_maximize(
|
||||
}
|
||||
else
|
||||
{
|
||||
wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, true);
|
||||
toplevel->state = DIYAC_VIEW_MAXIMIZE;
|
||||
}
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
@@ -177,9 +170,18 @@ static void xdg_toplevel_request_fullscreen(
|
||||
{
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_fullscreen);
|
||||
if (!toplevel->mapped)
|
||||
{
|
||||
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
|
||||
// the view has not yet be mapped, don't maximize it
|
||||
wlr_log(WLR_INFO, "The view has not yet be mapped, ignore fullscreen request");
|
||||
return;
|
||||
}
|
||||
wlr_log(WLR_INFO, "Request fullscreen");
|
||||
/*
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
|
||||
/*
|
||||
|
||||
if (toplevel->state == DIYAC_VIEW_FULL_SCREEN)
|
||||
{
|
||||
toplevel->state = DIYAC_VIEW_NORMAL;
|
||||
@@ -209,7 +211,6 @@ static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *da
|
||||
toplevel->state = DIYAC_VIEW_MINIMIZE;
|
||||
}
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||
@@ -247,8 +248,6 @@ static void popup_unconstrain(struct diyac_popup *popup)
|
||||
struct diyac_server *server = view->server;
|
||||
struct wlr_output_layout *output_layout = server->output_layout;
|
||||
struct wlr_output *wlr_output = view->output->wlr_output;
|
||||
struct wlr_box output_box;
|
||||
wlr_output_layout_get_box(output_layout, wlr_output, &output_box);
|
||||
|
||||
struct wlr_box geo_box = diyac_view_get_geometry(view);
|
||||
struct wlr_box output_toplevel_box = {
|
||||
@@ -257,13 +256,6 @@ static void popup_unconstrain(struct diyac_popup *popup)
|
||||
.width = view->output->usable_area.width,
|
||||
.height = view->output->usable_area.height,
|
||||
};
|
||||
wlr_log(WLR_INFO, "Un constrain popup geometry: current x %d, y %d, popup [%d, %d, %d, %d] output_box: [%d, %d, %d, %d], caculate_box: [%d, %d, %d, %d]",
|
||||
view->original.x, view->original.y,
|
||||
geo_box.x, geo_box.y, geo_box.width, geo_box.height,
|
||||
output_box.x, output_box.y, output_box.width, output_box.height,
|
||||
output_toplevel_box.x, output_toplevel_box.y, output_toplevel_box.width, output_toplevel_box.height
|
||||
);
|
||||
|
||||
wlr_xdg_popup_unconstrain_from_box(popup->wlr_popup, &output_toplevel_box);
|
||||
}
|
||||
|
||||
@@ -283,10 +275,6 @@ static void handle_xdg_popup_commit(struct wl_listener *listener, void *data)
|
||||
popup->commit.notify = NULL;
|
||||
// force commit output
|
||||
}
|
||||
else
|
||||
{
|
||||
wlr_log(WLR_INFO, "ignore commit 2");
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_xdg_popup_new(struct wl_listener *listener, void *data)
|
||||
@@ -299,7 +287,6 @@ static void handle_xdg_popup_new(struct wl_listener *listener, void *data)
|
||||
|
||||
static void xdg_popup_create(struct diyac_view *view, struct wlr_xdg_popup *wlr_popup)
|
||||
{
|
||||
wlr_log(WLR_INFO, "xdg_popup_create: Creating new dialog");
|
||||
struct wlr_xdg_surface *parent =
|
||||
wlr_xdg_surface_try_from_wlr_surface(wlr_popup->parent);
|
||||
if (!parent)
|
||||
@@ -360,7 +347,6 @@ static void xdg_set_appid_notify(struct wl_listener *listener, void *data)
|
||||
|
||||
static void xdg_new_popup_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
wlr_log(WLR_INFO, "xdg_new_popup_notify: Creating new dialog");
|
||||
struct diyac_view *view =
|
||||
wl_container_of(listener, view, new_popup);
|
||||
struct wlr_xdg_popup *wlr_popup = data;
|
||||
@@ -389,7 +375,7 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
|
||||
xdg_surface->data = wlr_scene_xdg_surface_create(
|
||||
parent_tree, xdg_surface);
|
||||
return;*/
|
||||
wlr_log(WLR_INFO, "diyac_new_xdg_surface: Creating new dialog using another method");
|
||||
wlr_log(WLR_INFO, "diyac_new_xdg_surface: Creating new dialog using view popup");
|
||||
return;
|
||||
}
|
||||
assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
|
||||
|
Reference in New Issue
Block a user