Add layout containers for new outputs
This commit is contained in:
parent
82bc36c681
commit
c102f18499
|
@ -5,6 +5,7 @@
|
||||||
#include "handlers.h"
|
#include "handlers.h"
|
||||||
|
|
||||||
bool handle_output_created(wlc_handle output) {
|
bool handle_output_created(wlc_handle output) {
|
||||||
|
add_output(output);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,46 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wlc/wlc.h>
|
#include <wlc/wlc.h>
|
||||||
|
#include "list.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
|
||||||
|
list_t *outputs;
|
||||||
|
|
||||||
|
void init_layout() {
|
||||||
|
outputs = create_list();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sway_container *get_container(wlc_handle output, int *index) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < outputs->length; ++i) {
|
||||||
|
struct sway_container *c = outputs->items[i];
|
||||||
|
if (c->output == output) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_output(wlc_handle output) {
|
||||||
|
struct sway_container *container = malloc(sizeof(struct sway_container));
|
||||||
|
// TODO: Get default layout from config
|
||||||
|
container->output = output;
|
||||||
|
container->children = create_list();
|
||||||
|
container->layout = LAYOUT_TILE_HORIZ;
|
||||||
|
list_add(outputs, container);
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_output(wlc_handle output) {
|
||||||
|
int index;
|
||||||
|
struct sway_container *c = get_container(output, &index);
|
||||||
|
// TODO: Move all windows in this output somewhere else?
|
||||||
|
// I don't think this will ever be called unless we destroy the output ourselves
|
||||||
|
if (!c) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
list_del(outputs, index);
|
||||||
|
}
|
||||||
|
|
||||||
wlc_handle get_topmost(wlc_handle output, size_t offset) {
|
wlc_handle get_topmost(wlc_handle output, size_t offset) {
|
||||||
size_t memb;
|
size_t memb;
|
||||||
const wlc_handle *views = wlc_output_get_views(output, &memb);
|
const wlc_handle *views = wlc_output_get_views(output, &memb);
|
||||||
|
|
|
@ -4,11 +4,23 @@
|
||||||
#include <wlc/wlc.h>
|
#include <wlc/wlc.h>
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
LAYOUT_TILE_HORIZ,
|
||||||
|
LAYOUT_TILE_VERT,
|
||||||
|
LAYOUT_TABBED,
|
||||||
|
LAYOUT_STACKED
|
||||||
|
} container_layout_t;
|
||||||
|
|
||||||
struct sway_container {
|
struct sway_container {
|
||||||
wlc_handle output; // May be NULL
|
wlc_handle output;
|
||||||
list_t children;
|
list_t *children;
|
||||||
|
container_layout_t layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern list_t *outputs;
|
||||||
|
|
||||||
|
void init_layout();
|
||||||
|
void add_output(wlc_handle output);
|
||||||
wlc_handle get_topmost(wlc_handle output, size_t offset);
|
wlc_handle get_topmost(wlc_handle output, size_t offset);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wlc/wlc.h>
|
#include <wlc/wlc.h>
|
||||||
|
#include "layout.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "handlers.h"
|
#include "handlers.h"
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ void load_config() {
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
load_config();
|
load_config();
|
||||||
|
init_layout();
|
||||||
|
|
||||||
static struct wlc_interface interface = {
|
static struct wlc_interface interface = {
|
||||||
.output = {
|
.output = {
|
||||||
|
|
Loading…
Reference in a new issue