Create sway_workspace struct.

This commit is contained in:
Ryan Dwyer 2018-04-17 09:31:34 +10:00
parent bfd5834f4c
commit c685ef081f
8 changed files with 28 additions and 26 deletions

View File

@ -45,6 +45,7 @@ enum sway_container_border {
struct sway_root; struct sway_root;
struct sway_output; struct sway_output;
struct sway_workspace;
struct sway_view; struct sway_view;
struct sway_container { struct sway_container {
@ -52,6 +53,7 @@ struct sway_container {
// TODO: Encapsulate state for other node types as well like C_CONTAINER // TODO: Encapsulate state for other node types as well like C_CONTAINER
struct sway_root *sway_root; struct sway_root *sway_root;
struct sway_output *sway_output; struct sway_output *sway_output;
struct sway_workspace *sway_workspace;
struct sway_view *sway_view; struct sway_view *sway_view;
}; };
@ -75,9 +77,6 @@ struct sway_container {
// does not include borders or gaps. // does not include borders or gaps.
double width, height; double width, height;
// For C_WORKSPACE only
struct sway_view *fullscreen;
list_t *children; list_t *children;
struct sway_container *parent; struct sway_container *parent;

View File

@ -3,6 +3,13 @@
#include "sway/tree/container.h" #include "sway/tree/container.h"
struct sway_view;
struct sway_workspace {
struct sway_container *swayc;
struct sway_view *fullscreen;
};
extern char *prev_workspace_name; extern char *prev_workspace_name;
char *workspace_next_name(const char *output_name); char *workspace_next_name(const char *output_name);

View File

@ -22,6 +22,7 @@
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/layout.h" #include "sway/tree/layout.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"
#include "sway/tree/workspace.h"
struct sway_container *output_by_name(const char *name) { struct sway_container *output_by_name(const char *name) {
for (int i = 0; i < root_container.children->length; ++i) { for (int i = 0; i < root_container.children->length; ++i) {
@ -275,9 +276,9 @@ static void render_output(struct sway_output *output, struct timespec *when,
struct sway_container *workspace = output_get_active_workspace(output); struct sway_container *workspace = output_get_active_workspace(output);
if (workspace->fullscreen) { if (workspace->sway_workspace->fullscreen) {
wlr_output_set_fullscreen_surface(wlr_output, wlr_output_set_fullscreen_surface(wlr_output,
workspace->fullscreen->surface); workspace->sway_workspace->fullscreen->surface);
} else { } else {
wlr_output_set_fullscreen_surface(wlr_output, NULL); wlr_output_set_fullscreen_surface(wlr_output, NULL);
render_layer(output, render_layer(output,

View File

@ -18,6 +18,7 @@
#include "sway/output.h" #include "sway/output.h"
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#include "log.h" #include "log.h"
static void seat_device_destroy(struct sway_seat_device *seat_device) { static void seat_device_destroy(struct sway_seat_device *seat_device) {
@ -457,7 +458,8 @@ void seat_set_focus_warp(struct sway_seat *seat,
new_workspace = container_parent(new_workspace, C_WORKSPACE); new_workspace = container_parent(new_workspace, C_WORKSPACE);
} }
if (last_workspace == new_workspace && last_workspace->fullscreen if (last_workspace == new_workspace
&& last_workspace->sway_workspace->fullscreen
&& !container->sway_view->is_fullscreen) { && !container->sway_view->is_fullscreen) {
return; return;
} }

View File

@ -197,6 +197,7 @@ static struct sway_container *container_workspace_destroy(
} }
} }
free(workspace->sway_workspace);
_container_destroy(workspace); _container_destroy(workspace);
output_damage_whole(output->sway_output); output_damage_whole(output->sway_output);

View File

@ -572,7 +572,7 @@ void arrange_windows(struct sway_container *container,
return; return;
case C_WORKSPACE: case C_WORKSPACE:
{ {
if (container->fullscreen) { if (container->sway_workspace->fullscreen) {
return; return;
} }
struct sway_container *output = struct sway_container *output =
@ -847,22 +847,6 @@ struct sway_container *container_get_in_direction(
} }
} }
// TODO WLR fullscreen
/*
if (container->type == C_VIEW && swayc_is_fullscreen(container)) {
wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output");
container = container_parent(container, C_OUTPUT);
get_layout_center_position(container, &abs_pos);
struct sway_container *output =
swayc_adjacent_output(container, dir, &abs_pos, true);
return get_swayc_in_output_direction(output, dir);
}
if (container->type == C_WORKSPACE && container->fullscreen) {
sway_log(L_DEBUG, "Moving to fullscreen view");
return container->fullscreen;
}
*/
struct sway_container *wrap_candidate = NULL; struct sway_container *wrap_candidate = NULL;
while (true) { while (true) {
bool can_move = false; bool can_move = false;

View File

@ -7,6 +7,7 @@
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/layout.h" #include "sway/tree/layout.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"
#include "sway/tree/workspace.h"
void view_init(struct sway_view *view, enum sway_view_type type, void view_init(struct sway_view *view, enum sway_view_type type,
const struct sway_view_impl *impl) { const struct sway_view_impl *impl) {
@ -90,10 +91,10 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
view->is_fullscreen = fullscreen; view->is_fullscreen = fullscreen;
if (fullscreen) { if (fullscreen) {
workspace->fullscreen = view; workspace->sway_workspace->fullscreen = view;
view_configure(view, 0, 0, output->wlr_output->width, output->wlr_output->height); view_configure(view, 0, 0, output->wlr_output->width, output->wlr_output->height);
} else { } else {
workspace->fullscreen = NULL; workspace->sway_workspace->fullscreen = NULL;
arrange_windows(workspace, -1, -1); arrange_windows(workspace, -1, -1);
} }
@ -105,7 +106,7 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
void view_close(struct sway_view *view) { void view_close(struct sway_view *view) {
if (view->is_fullscreen) { if (view->is_fullscreen) {
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
ws->fullscreen = NULL; ws->sway_workspace->fullscreen = NULL;
} }
if (view->impl->close) { if (view->impl->close) {

View File

@ -59,6 +59,13 @@ struct sway_container *workspace_create(struct sway_container *output,
workspace->layout = container_get_default_layout(output); workspace->layout = container_get_default_layout(output);
workspace->workspace_layout = workspace->layout; workspace->workspace_layout = workspace->layout;
struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace));
if (!swayws) {
return NULL;
}
swayws->swayc = workspace;
workspace->sway_workspace = swayws;
container_add_child(output, workspace); container_add_child(output, workspace);
container_sort_workspaces(output); container_sort_workspaces(output);
container_create_notify(workspace); container_create_notify(workspace);