Merge branch 'basic-functionality'

This commit is contained in:
Keith Bowes 2020-02-26 14:18:13 -05:00
commit 9ebbc7624c
3 changed files with 13 additions and 19 deletions

View file

@ -2,13 +2,13 @@
#include "waybox/cursor.h" #include "waybox/cursor.h"
#include "waybox/xdg_shell.h" #include "waybox/xdg_shell.h"
static void process_cursor_move(struct wb_server *server, uint32_t time) { static void process_cursor_move(struct wb_server *server) {
/* Move the grabbed view to the new position. */ /* Move the grabbed view to the new position. */
server->grabbed_view->x = server->cursor->cursor->x - server->grab_x; server->grabbed_view->x = server->cursor->cursor->x - server->grab_x;
server->grabbed_view->y = server->cursor->cursor->y - server->grab_y; server->grabbed_view->y = server->cursor->cursor->y - server->grab_y;
} }
static void process_cursor_resize(struct wb_server *server, uint32_t time) { static void process_cursor_resize(struct wb_server *server) {
struct wb_view *view = server->grabbed_view; struct wb_view *view = server->grabbed_view;
double dx = server->cursor->cursor->x - server->grab_x; double dx = server->cursor->cursor->x - server->grab_x;
double dy = server->cursor->cursor->y - server->grab_y; double dy = server->cursor->cursor->y - server->grab_y;
@ -42,10 +42,10 @@ static void process_cursor_resize(struct wb_server *server, uint32_t time) {
static void process_cursor_motion(struct wb_server *server, uint32_t time) { static void process_cursor_motion(struct wb_server *server, uint32_t time) {
/* If the mode is non-passthrough, delegate to those functions. */ /* If the mode is non-passthrough, delegate to those functions. */
if (server->cursor->cursor_mode == WB_CURSOR_MOVE) { if (server->cursor->cursor_mode == WB_CURSOR_MOVE) {
process_cursor_move(server, time); process_cursor_move(server);
return; return;
} else if (server->cursor->cursor_mode == WB_CURSOR_RESIZE) { } else if (server->cursor->cursor_mode == WB_CURSOR_RESIZE) {
process_cursor_resize(server, time); process_cursor_resize(server);
return; return;
} }

View file

@ -5,23 +5,19 @@
#include "waybox/server.h" #include "waybox/server.h"
int main(int argc, char **argv){ int main(int argc, char **argv) {
char *startup_cmd = NULL; char *startup_cmd = NULL;
if (argc > 0) { if (argc > 0) {
int i; int i;
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++) {
{
if (!strcmp("--debug", argv[i]) || !strcmp("-v", argv[i]) || !strcmp("--exit", argv[i])) { if (!strcmp("--debug", argv[i]) || !strcmp("-v", argv[i]) || !strcmp("--exit", argv[i])) {
printf("Warning: option %s is currently unimplemented\n", argv[i]); printf("Warning: option %s is currently unimplemented\n", argv[i]);
} } else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i])) && i < argc) {
else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i])) && i < argc) {
startup_cmd = argv[i + 1]; startup_cmd = argv[i + 1];
} } else if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i])) {
else if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i])) {
printf(VERSION "\n"); printf(VERSION "\n");
return 0; return 0;
} } else if (argv[i][0] == '-') {
else if (argv[i][0] == '-') {
printf("Usage: %s [--debug] [--exit] [--help] [--startup CMD] [--version]\n", argv[0]); printf("Usage: %s [--debug] [--exit] [--help] [--startup CMD] [--version]\n", argv[0]);
return strcmp("--help", argv[i]) != 0 && strcmp("-h", argv[i]) != 0; return strcmp("--help", argv[i]) != 0 && strcmp("-h", argv[i]) != 0;
} }

View file

@ -12,8 +12,7 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32
if (modifiers & WLR_MODIFIER_CTRL && sym == XKB_KEY_Escape) { if (modifiers & WLR_MODIFIER_CTRL && sym == XKB_KEY_Escape) {
wl_display_terminate(server->wl_display); wl_display_terminate(server->wl_display);
} } else if (modifiers & WLR_MODIFIER_ALT && sym == XKB_KEY_Tab) {
else if (modifiers & WLR_MODIFIER_ALT && sym == XKB_KEY_Tab) {
/* Cycle to the next view */ /* Cycle to the next view */
if (wl_list_length(&server->views) < 2) { if (wl_list_length(&server->views) < 2) {
return false; return false;
@ -26,14 +25,13 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32
/* Move the previous view to the end of the list */ /* Move the previous view to the end of the list */
wl_list_remove(&current_view->link); wl_list_remove(&current_view->link);
wl_list_insert(server->views.prev, &current_view->link); wl_list_insert(server->views.prev, &current_view->link);
} } else if (modifiers & WLR_MODIFIER_ALT && sym == XKB_KEY_F2) {
else if (modifiers & WLR_MODIFIER_ALT && sym == XKB_KEY_F2)
{
if (fork() == 0) { if (fork() == 0) {
execl("/bin/sh", "/bin/sh", "-c", "(obrun || bemenu-run || synapse || gmrun || gnome-do || dmenu_run) 2>/dev/null", NULL); execl("/bin/sh", "/bin/sh", "-c", "(obrun || bemenu-run || synapse || gmrun || gnome-do || dmenu_run) 2>/dev/null", NULL);
} }
} else {
return false;
} }
else return false;
return true; return true;
} }