Merge pull request #18 from keithbowes/modernize

Modernize
This commit is contained in:
Keith Bowes 2020-03-11 08:32:50 -04:00 committed by GitHub
commit 114e265eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 66 additions and 399 deletions

View file

@ -165,7 +165,8 @@ struct wb_cursor *wb_cursor_create(struct wb_server *server) {
cursor->server = server;
const char *xcursor_size = getenv("XCURSOR_SIZE");
cursor->xcursor_manager = wlr_xcursor_manager_create(getenv("XCURSOR_THEME"), xcursor_size ? atoi(xcursor_size) : 24);
cursor->xcursor_manager = wlr_xcursor_manager_create(getenv("XCURSOR_THEME"),
xcursor_size ? strtoul(xcursor_size, (char **) NULL, 10) : 24);
wlr_xcursor_manager_load(cursor->xcursor_manager, 1);
cursor->cursor_motion.notify = handle_cursor_motion;

View file

@ -15,7 +15,7 @@ int main(int argc, char **argv) {
} else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i])) && i < argc) {
startup_cmd = argv[i + 1];
} else if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i])) {
printf(VERSION "\n");
printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
return 0;
} else if (argv[i][0] == '-') {
printf("Usage: %s [--debug] [--exit] [--help] [--startup CMD] [--version]\n", argv[0]);
@ -26,26 +26,26 @@ int main(int argc, char **argv) {
struct wb_server server = {0};
if (init_wb(&server) == false) {
if (!wb_create_backend(&server)) {
printf("Failed to create backend\n");
exit(EXIT_FAILURE);
}
if (!start_wb(&server)) {
if (!wb_start_server(&server)) {
printf("Failed to start server\n");
terminate_wb(&server);
wb_terminate(&server);
exit(EXIT_FAILURE);
}
if (startup_cmd) {
if (fork() == 0) {
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (char *) NULL);
}
}
wl_display_run(server.wl_display);
terminate_wb(&server);
wb_terminate(&server);
return 0;
}

View file

@ -10,7 +10,6 @@ wb_src = files(
wb_dep = [
wayland_server,
wlroots,
pixman,
xkbcommon,
]

View file

@ -1,5 +1,3 @@
#include <wlr/version.h>
#include "waybox/output.h"
struct render_data {
@ -127,12 +125,9 @@ void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_set_mode(wlr_output, mode);
wlr_output_enable(wlr_output, true);
#if WLR_VERSION_NUM > 2049
// wlroots 0.9.0+
if (!wlr_output_commit(wlr_output)) {
return;
}
#endif
}
struct wb_output *output = calloc(1, sizeof(struct wb_output));

View file

@ -27,7 +27,7 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32
wl_list_insert(server->views.prev, &current_view->link);
} else if (modifiers & WLR_MODIFIER_ALT && sym == XKB_KEY_F2) {
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", (char *) NULL);
}
} else {
return false;

View file

@ -1,7 +1,7 @@
#include "waybox/server.h"
#include "waybox/xdg_shell.h"
bool init_wb(struct wb_server* server) {
bool wb_create_backend(struct wb_server* server) {
// create display
server->wl_display = wl_display_create();
if (server->wl_display == NULL) {
@ -27,7 +27,7 @@ bool init_wb(struct wb_server* server) {
return true;
}
bool start_wb(struct wb_server* server) {
bool wb_start_server(struct wb_server* server) {
wl_list_init(&server->outputs);
server->new_output.notify = new_output_notify;
@ -51,7 +51,7 @@ bool start_wb(struct wb_server* server) {
wlr_gamma_control_manager_v1_create(server->wl_display);
wlr_screencopy_manager_v1_create(server->wl_display);
wlr_gtk_primary_selection_device_manager_create(server->wl_display);
wlr_primary_selection_v1_device_manager_create(server->wl_display);
wlr_idle_create(server->wl_display);
wlr_data_device_manager_create(server->wl_display);
@ -61,7 +61,7 @@ bool start_wb(struct wb_server* server) {
return true;
}
bool terminate_wb(struct wb_server* server) {
bool wb_terminate(struct wb_server* server) {
wl_display_destroy_clients(server->wl_display);
wb_cursor_destroy(server->cursor);
wb_seat_destroy(server->seat);

View file

@ -57,7 +57,8 @@ static void xdg_surface_unmap(struct wl_listener *listener, void *data) {
focus_view(current_view, current_view->xdg_surface->surface);
}
/* Otherwise, focus the next view, if any. */
else if (next_view->xdg_surface->surface && wlr_surface_is_xdg_surface(next_view->xdg_surface->surface)) {
else if (next_view->xdg_surface->surface &&
wlr_surface_is_xdg_surface(next_view->xdg_surface->surface)) {
focus_view(next_view, next_view->xdg_surface->surface);
}
}