Refactor cage into separate source files

This makes Cage much easier to maintain. Not only is it easier where to
look and to maintain a mental model of the code, there is also more
encapsulation, better abstractions and better extendability.
This commit is contained in:
Jente Hidskes 2018-12-31 00:12:33 +01:00
parent e1525a20c8
commit 2cf40f7a9b
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
11 changed files with 1084 additions and 657 deletions

47
view.h Normal file
View file

@ -0,0 +1,47 @@
#ifndef CG_VIEW_H
#define CG_VIEW_H
#include <stdbool.h>
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_xdg_shell.h>
#include "server.h"
enum cg_view_type {
CAGE_XDG_SHELL_VIEW,
};
struct cg_view {
struct cg_server *server;
struct wl_list link; // server::views
struct wlr_surface *wlr_surface;
int x, y;
enum cg_view_type type;
union {
struct wlr_xdg_surface *xdg_surface;
};
struct wl_listener destroy;
struct wl_listener map;
// TODO: allow applications to go to fullscreen from maximized?
// struct wl_listener request_fullscreen;
void (*activate)(struct cg_view *view, bool activate);
void (*maximize)(struct cg_view *view, int output_width, int output_height);
void (*get_geometry)(struct cg_view *view, struct wlr_box *geom);
bool (*is_primary)(struct cg_view *view);
};
void view_activate(struct cg_view *view, bool activate);
void view_maximize(struct cg_view *view);
void view_center(struct cg_view *view);
bool view_is_primary(struct cg_view *view);
void view_map(struct cg_view *view, struct wlr_surface *surface);
void view_destroy(struct cg_view *view);
struct cg_view *cg_view_create(struct cg_server *server);
struct cg_view *cg_view_from_wlr_surface(struct cg_server *server, struct wlr_surface *surface);
#endif