mirror of
https://github.com/swaywm/sway.git
synced 2025-11-06 13:29:50 -05:00
Revert "Refactor tree"
This commit is contained in:
parent
6b7841b11f
commit
d0c7f66e95
39 changed files with 588 additions and 593 deletions
|
|
@ -1,137 +0,0 @@
|
|||
#ifndef _SWAY_CONTAINER_H
|
||||
#define _SWAY_CONTAINER_H
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include "list.h"
|
||||
|
||||
extern struct sway_container root_container;
|
||||
|
||||
struct sway_view;
|
||||
struct sway_seat;
|
||||
|
||||
/**
|
||||
* Different kinds of containers.
|
||||
*
|
||||
* This enum is in order. A container will never be inside of a container below
|
||||
* it on this list.
|
||||
*/
|
||||
enum sway_container_type {
|
||||
C_ROOT,
|
||||
C_OUTPUT,
|
||||
C_WORKSPACE,
|
||||
C_CONTAINER,
|
||||
C_VIEW,
|
||||
|
||||
C_TYPES,
|
||||
};
|
||||
|
||||
enum sway_container_layout {
|
||||
L_NONE,
|
||||
L_HORIZ,
|
||||
L_VERT,
|
||||
L_STACKED,
|
||||
L_TABBED,
|
||||
L_FLOATING,
|
||||
|
||||
// Keep last
|
||||
L_LAYOUTS,
|
||||
};
|
||||
|
||||
enum sway_container_border {
|
||||
B_NONE,
|
||||
B_PIXEL,
|
||||
B_NORMAL,
|
||||
};
|
||||
|
||||
struct sway_root;
|
||||
struct sway_output;
|
||||
struct sway_view;
|
||||
|
||||
struct sway_container {
|
||||
union {
|
||||
// TODO: Encapsulate state for other node types as well like C_CONTAINER
|
||||
struct sway_root *sway_root;
|
||||
struct sway_output *sway_output;
|
||||
struct sway_view *sway_view;
|
||||
};
|
||||
|
||||
/**
|
||||
* A unique ID to identify this container. Primarily used in the
|
||||
* get_tree JSON output.
|
||||
*/
|
||||
size_t id;
|
||||
|
||||
char *name;
|
||||
|
||||
enum sway_container_type type;
|
||||
enum sway_container_layout layout;
|
||||
enum sway_container_layout prev_layout;
|
||||
enum sway_container_layout workspace_layout;
|
||||
|
||||
// TODO convert to layout coordinates
|
||||
double x, y;
|
||||
|
||||
// does not include borders or gaps.
|
||||
double width, height;
|
||||
|
||||
list_t *children;
|
||||
|
||||
struct sway_container *parent;
|
||||
|
||||
list_t *marks; // list of char*
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
};
|
||||
|
||||
// TODO only one container create function and pass the type?
|
||||
struct sway_container *container_output_create(
|
||||
struct sway_output *sway_output);
|
||||
|
||||
struct sway_container *container_workspace_create(
|
||||
struct sway_container *output, const char *name);
|
||||
|
||||
struct sway_container *container_view_create(
|
||||
struct sway_container *sibling, struct sway_view *sway_view);
|
||||
|
||||
struct sway_container *container_output_destroy(struct sway_container *output);
|
||||
|
||||
struct sway_container *container_view_destroy(struct sway_container *view);
|
||||
|
||||
struct sway_container *container_set_layout(struct sway_container *container,
|
||||
enum sway_container_layout layout);
|
||||
|
||||
void container_descendents(struct sway_container *root,
|
||||
enum sway_container_type type,
|
||||
void (*func)(struct sway_container *item, void *data), void *data);
|
||||
|
||||
/**
|
||||
* Finds a container based on test criteria. Returns the first container that
|
||||
* passes the test.
|
||||
*/
|
||||
struct sway_container *container_find(struct sway_container *container,
|
||||
bool (*test)(struct sway_container *view, void *data), void *data);
|
||||
|
||||
/**
|
||||
* Finds a parent container with the given struct sway_containerype.
|
||||
*/
|
||||
struct sway_container *container_parent(struct sway_container *container,
|
||||
enum sway_container_type type);
|
||||
|
||||
/**
|
||||
* Find a container at the given coordinates.
|
||||
*/
|
||||
struct sway_container *container_at(struct sway_container *parent,
|
||||
double lx, double ly, struct wlr_surface **surface,
|
||||
double *sx, double *sy);
|
||||
|
||||
/**
|
||||
* Apply the function for each child of the container breadth first.
|
||||
*/
|
||||
void container_for_each_descendent(struct sway_container *container,
|
||||
void (*f)(struct sway_container *container, void *data), void *data);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#ifndef _SWAY_LAYOUT_H
|
||||
#define _SWAY_LAYOUT_H
|
||||
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include "sway/tree/container.h"
|
||||
|
||||
enum movement_direction {
|
||||
MOVE_LEFT,
|
||||
MOVE_RIGHT,
|
||||
MOVE_UP,
|
||||
MOVE_DOWN,
|
||||
MOVE_PARENT,
|
||||
MOVE_CHILD,
|
||||
MOVE_NEXT,
|
||||
MOVE_PREV,
|
||||
MOVE_FIRST
|
||||
};
|
||||
|
||||
struct sway_container;
|
||||
|
||||
struct sway_root {
|
||||
struct wlr_output_layout *output_layout;
|
||||
|
||||
struct wl_listener output_layout_change;
|
||||
|
||||
struct wl_list unmanaged_views; // sway_view::unmanaged_view_link
|
||||
|
||||
struct {
|
||||
struct wl_signal new_container;
|
||||
} events;
|
||||
};
|
||||
|
||||
void layout_init(void);
|
||||
|
||||
void container_add_child(struct sway_container *parent, struct sway_container *child);
|
||||
|
||||
struct sway_container *container_add_sibling(struct sway_container *parent,
|
||||
struct sway_container *child);
|
||||
|
||||
struct sway_container *container_remove_child(struct sway_container *child);
|
||||
|
||||
enum sway_container_layout container_get_default_layout(struct sway_container *output);
|
||||
|
||||
void container_sort_workspaces(struct sway_container *output);
|
||||
|
||||
void arrange_windows(struct sway_container *container,
|
||||
double width, double height);
|
||||
|
||||
struct sway_container *container_get_in_direction(struct sway_container
|
||||
*container, struct sway_seat *seat, enum movement_direction dir);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
#ifndef _SWAY_VIEW_H
|
||||
#define _SWAY_VIEW_H
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_xdg_shell_v6.h>
|
||||
#include <wlr/xwayland.h>
|
||||
|
||||
struct sway_container;
|
||||
struct sway_view;
|
||||
|
||||
struct sway_xdg_surface_v6 {
|
||||
struct sway_view *view;
|
||||
|
||||
struct wl_listener commit;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
struct wl_listener request_maximize;
|
||||
struct wl_listener destroy;
|
||||
|
||||
int pending_width, pending_height;
|
||||
};
|
||||
|
||||
struct sway_xwayland_surface {
|
||||
struct sway_view *view;
|
||||
|
||||
struct wl_listener commit;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
struct wl_listener request_maximize;
|
||||
struct wl_listener request_configure;
|
||||
struct wl_listener unmap_notify;
|
||||
struct wl_listener map_notify;
|
||||
struct wl_listener destroy;
|
||||
|
||||
int pending_width, pending_height;
|
||||
};
|
||||
|
||||
struct sway_wl_shell_surface {
|
||||
struct sway_view *view;
|
||||
|
||||
struct wl_listener commit;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
struct wl_listener request_maximize;
|
||||
struct wl_listener destroy;
|
||||
|
||||
int pending_width, pending_height;
|
||||
};
|
||||
|
||||
enum sway_view_type {
|
||||
SWAY_WL_SHELL_VIEW,
|
||||
SWAY_XDG_SHELL_V6_VIEW,
|
||||
SWAY_XWAYLAND_VIEW,
|
||||
// Keep last
|
||||
SWAY_VIEW_TYPES,
|
||||
};
|
||||
|
||||
enum sway_view_prop {
|
||||
VIEW_PROP_TITLE,
|
||||
VIEW_PROP_APP_ID,
|
||||
VIEW_PROP_CLASS,
|
||||
VIEW_PROP_INSTANCE,
|
||||
};
|
||||
|
||||
struct sway_view {
|
||||
enum sway_view_type type;
|
||||
struct sway_container *swayc;
|
||||
struct wlr_surface *surface;
|
||||
int width, height;
|
||||
|
||||
union {
|
||||
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
|
||||
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
||||
struct wlr_wl_shell_surface *wlr_wl_shell_surface;
|
||||
};
|
||||
|
||||
union {
|
||||
struct sway_xdg_surface_v6 *sway_xdg_surface_v6;
|
||||
struct sway_xwayland_surface *sway_xwayland_surface;
|
||||
struct sway_wl_shell_surface *sway_wl_shell_surface;
|
||||
};
|
||||
|
||||
struct {
|
||||
const char *(*get_prop)(struct sway_view *view,
|
||||
enum sway_view_prop prop);
|
||||
void (*set_size)(struct sway_view *view,
|
||||
int width, int height);
|
||||
void (*set_position)(struct sway_view *view,
|
||||
double ox, double oy);
|
||||
void (*set_activated)(struct sway_view *view, bool activated);
|
||||
void (*close)(struct sway_view *view);
|
||||
} iface;
|
||||
|
||||
// only used for unmanaged views (shell specific)
|
||||
struct wl_list unmanaged_view_link; // sway_root::unmanaged views
|
||||
};
|
||||
|
||||
const char *view_get_title(struct sway_view *view);
|
||||
|
||||
const char *view_get_app_id(struct sway_view *view);
|
||||
|
||||
const char *view_get_class(struct sway_view *view);
|
||||
|
||||
const char *view_get_instance(struct sway_view *view);
|
||||
|
||||
void view_set_size(struct sway_view *view, int width, int height);
|
||||
|
||||
void view_set_position(struct sway_view *view, double ox, double oy);
|
||||
|
||||
void view_set_activated(struct sway_view *view, bool activated);
|
||||
|
||||
void view_close(struct sway_view *view);
|
||||
|
||||
void view_update_outputs(struct sway_view *view, const struct wlr_box *before);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef _SWAY_WORKSPACE_H
|
||||
#define _SWAY_WORKSPACE_H
|
||||
|
||||
#include "sway/tree/container.h"
|
||||
|
||||
extern char *prev_workspace_name;
|
||||
|
||||
char *workspace_next_name(const char *output_name);
|
||||
|
||||
struct sway_container *workspace_create(const char *name);
|
||||
|
||||
bool workspace_switch(struct sway_container *workspace);
|
||||
|
||||
struct sway_container *workspace_by_number(const char* name);
|
||||
|
||||
struct sway_container *workspace_by_name(const char*);
|
||||
|
||||
struct sway_container *workspace_output_next(struct sway_container *current);
|
||||
|
||||
struct sway_container *workspace_next(struct sway_container *current);
|
||||
|
||||
struct sway_container *workspace_output_prev(struct sway_container *current);
|
||||
|
||||
struct sway_container *workspace_prev(struct sway_container *current);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue