Prevent passing WM keys, improve multihead support
This commit is contained in:
parent
e62e294366
commit
dd115cece3
|
@ -57,24 +57,27 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
|
||||||
// Lowercase if necessary
|
// Lowercase if necessary
|
||||||
sym = tolower(sym);
|
sym = tolower(sym);
|
||||||
|
|
||||||
if (state == WLC_KEY_STATE_PRESSED) {
|
int i;
|
||||||
int i;
|
for (i = 0; i < mode->bindings->length; ++i) {
|
||||||
for (i = 0; i < mode->bindings->length; ++i) {
|
struct sway_binding *binding = mode->bindings->items[i];
|
||||||
struct sway_binding *binding = mode->bindings->items[i];
|
|
||||||
|
|
||||||
if ((modifiers->mods & binding->modifiers) == binding->modifiers) {
|
if ((modifiers->mods & binding->modifiers) == binding->modifiers) {
|
||||||
bool match = true;
|
bool match = true;
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < binding->keys->length; ++j) {
|
for (j = 0; j < binding->keys->length; ++j) {
|
||||||
xkb_keysym_t *k = binding->keys->items[j];
|
xkb_keysym_t *k = binding->keys->items[j];
|
||||||
if (sym != *k) {
|
if (sym != *k) {
|
||||||
match = false;
|
match = false;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
cmd_success = handle_command(config, binding->command);
|
// TODO: --released
|
||||||
|
if (state == WLC_KEY_STATE_PRESSED) {
|
||||||
|
cmd_success = !handle_command(config, binding->command);
|
||||||
|
} else {
|
||||||
|
cmd_success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
#include "container.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
|
||||||
swayc_t root_container;
|
swayc_t root_container;
|
||||||
|
@ -35,10 +36,16 @@ void arrange_windows(swayc_t *container, int width, int height) {
|
||||||
height = container->height;
|
height = container->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int x = 0, y = 0;
|
||||||
switch (container->type) {
|
switch (container->type) {
|
||||||
case C_ROOT:
|
case C_ROOT:
|
||||||
for (i = 0; i < container->children->length; ++i) {
|
for (i = 0; i < container->children->length; ++i) {
|
||||||
arrange_windows(container->children->items[i], -1, -1);
|
swayc_t *child = container->children->items[i];
|
||||||
|
sway_log(L_DEBUG, "Arranging output at %d", x);
|
||||||
|
child->x = x;
|
||||||
|
child->y = y;
|
||||||
|
arrange_windows(child, child->width, child->height);
|
||||||
|
x += child->width;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case C_VIEW:
|
case C_VIEW:
|
||||||
|
@ -85,7 +92,6 @@ void arrange_windows(swayc_t *container, int width, int height) {
|
||||||
total_weight += child->weight;
|
total_weight += child->weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = 0, y = 0;
|
|
||||||
switch (container->layout) {
|
switch (container->layout) {
|
||||||
case L_HORIZ:
|
case L_HORIZ:
|
||||||
default:
|
default:
|
||||||
|
@ -307,6 +313,13 @@ swayc_t *create_container(swayc_t *parent, wlc_handle handle) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_output_widths(swayc_t *container, void *_width) {
|
||||||
|
int *width = _width;
|
||||||
|
if (container->type == C_OUTPUT) {
|
||||||
|
*width += container->width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void add_output(wlc_handle output) {
|
void add_output(wlc_handle output) {
|
||||||
sway_log(L_DEBUG, "Adding output %d", output);
|
sway_log(L_DEBUG, "Adding output %d", output);
|
||||||
const struct wlc_size* size = wlc_output_get_resolution(output);
|
const struct wlc_size* size = wlc_output_get_resolution(output);
|
||||||
|
@ -317,6 +330,9 @@ void add_output(wlc_handle output) {
|
||||||
container->height = size->h;
|
container->height = size->h;
|
||||||
add_child(&root_container, container);
|
add_child(&root_container, container);
|
||||||
|
|
||||||
|
int total_width = 0;
|
||||||
|
container_map(&root_container, add_output_widths, &total_width);
|
||||||
|
|
||||||
swayc_t *workspace = create_container(container, -1);
|
swayc_t *workspace = create_container(container, -1);
|
||||||
workspace->type = C_WORKSPACE;
|
workspace->type = C_WORKSPACE;
|
||||||
workspace->name = workspace_next_name();
|
workspace->name = workspace_next_name();
|
||||||
|
@ -324,6 +340,7 @@ void add_output(wlc_handle output) {
|
||||||
workspace->height = size->h;
|
workspace->height = size->h;
|
||||||
workspace->layout = L_HORIZ; // TODO: Get default layout from config
|
workspace->layout = L_HORIZ; // TODO: Get default layout from config
|
||||||
add_child(container, workspace);
|
add_child(container, workspace);
|
||||||
|
sway_log(L_DEBUG, "Added workspace %s for output %d", workspace->name, output);
|
||||||
|
|
||||||
workspace_switch(workspace);
|
workspace_switch(workspace);
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,18 @@
|
||||||
|
|
||||||
swayc_t *active_workspace = NULL;
|
swayc_t *active_workspace = NULL;
|
||||||
|
|
||||||
|
int ws_num = 1;
|
||||||
|
|
||||||
char *workspace_next_name(void) {
|
char *workspace_next_name(void) {
|
||||||
//TODO change this i guess. seems pretty bad
|
int l = 1;
|
||||||
char *name = malloc(sizeof("1"));
|
if (ws_num >= 10) {
|
||||||
return strcpy(name, "1");
|
l = 2;
|
||||||
|
} else if (ws_num >= 100) {
|
||||||
|
l = 3;
|
||||||
|
}
|
||||||
|
char *name = malloc(l + 1);
|
||||||
|
sprintf(name, "%d", ws_num++);
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
swayc_t *workspace_create(const char* name) {
|
swayc_t *workspace_create(const char* name) {
|
||||||
|
@ -45,7 +53,6 @@ bool workspace_destroy(swayc_t *workspace) {
|
||||||
sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name);
|
sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name);
|
||||||
free_swayc(workspace);
|
free_swayc(workspace);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_mask(swayc_t *view, void *data) {
|
void set_mask(swayc_t *view, void *data) {
|
||||||
|
|
Loading…
Reference in a new issue