diff --git a/.gitignore b/.gitignore index 27380c2..08225a6 100644 --- a/.gitignore +++ b/.gitignore @@ -139,7 +139,5 @@ m4/lt~obsolete.m4 # can automatically generate from config.status script # (which is called by configure script)) # Makefile -xdg-shell-protocol.* -diyac -.vscode -wlr-layer-shell-unstable-v1-protocol* \ No newline at end of file +build +.vscode \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 1ed69ea..0000000 --- a/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols) -WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner) -LIBS=\ - $(shell pkg-config --cflags --libs wlroots) \ - $(shell pkg-config --cflags --libs wayland-server) \ - $(shell pkg-config --cflags --libs xkbcommon) - -OBJS=\ - diyac.c \ - cursor.c \ - output.c \ - seat.c \ - node.c \ - view.c \ - foreign.c \ - xdg.c \ - xdg-shell-protocol.c \ - layer.c \ - session.c \ - wlr-layer-shell-unstable-v1-protocol.c - -# wayland-scanner is a tool which generates C headers and rigging for Wayland -# protocols, which are specified in XML. wlroots requires you to rig these up -# to your build system yourself and provide them in the include path. -xdg-shell-protocol.h: - $(WAYLAND_SCANNER) server-header \ - $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ - -xdg-shell-protocol.c: xdg-shell-protocol.h - $(WAYLAND_SCANNER) private-code \ - $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ - -wlr-layer-shell-unstable-v1-protocol.c: wlr-layer-shell-unstable-v1-protocol.h - $(WAYLAND_SCANNER) private-code \ - protocol/wlr-layer-shell-unstable-v1.xml $@ - -wlr-layer-shell-unstable-v1-protocol.h: - $(WAYLAND_SCANNER) server-header \ - protocol/wlr-layer-shell-unstable-v1.xml $@ - -diyac: $(OBJS) - echo "Object is $(OBJS)" - $(CC) $(CFLAGS) \ - -g -Werror -I. \ - -DWLR_USE_UNSTABLE \ - -o $@ $(OBJS) \ - $(LIBS) - -clean: - rm -f diyac xdg-shell-protocol.* wlr-layer-shell-unstable-v1-protocol.* - -.DEFAULT_GOAL=diyac -.PHONY: clean \ No newline at end of file diff --git a/cursor.c b/cursor.c index 82d1f58..4aac2d5 100644 --- a/cursor.c +++ b/cursor.c @@ -13,7 +13,7 @@ void diyac_cursor_focus(struct diyac_server *server) struct diyac_node_descriptor *desc = diyac_node_at(server, server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy); struct diyac_layer_surface *layer; - struct diyac_view *root = NULL; + // struct diyac_view *root = NULL; if (!desc) { return; @@ -55,6 +55,7 @@ void diyac_reset_cursor_mode(struct diyac_server *server) static void process_cursor_move(struct diyac_server *server, uint32_t time) { + (void) time; struct diyac_view *toplevel = server->grabbed_view; /* Move the grabbed toplevel to the new position. */ if(!toplevel->output) @@ -84,6 +85,7 @@ static void process_cursor_move(struct diyac_server *server, uint32_t time) static void process_cursor_resize(struct diyac_server *server, uint32_t time) { + (void) time; /* * Resizing the grabbed toplevel can be a little bit complicated, because we * could be resizing from any corner or edge. This not only resizes the @@ -252,7 +254,7 @@ static void server_cursor_button(struct wl_listener *listener, void *data) wlr_seat_pointer_notify_button(seat->wlr_seat, event->time_msec, event->button, event->state); - if (event->state == WLR_BUTTON_RELEASED) + if (event->state == WL_POINTER_BUTTON_STATE_RELEASED) { /* If you released any buttons, we exit interactive move/resize mode. */ diyac_reset_cursor_mode(seat->server); @@ -278,6 +280,7 @@ static void server_cursor_axis(struct wl_listener *listener, void *data) static void server_cursor_frame(struct wl_listener *listener, void *data) { + (void) data; /* This event is forwarded by the cursor when a pointer emits an frame * event. Frame events are sent after regular pointer events to group * multiple events together. For instance, two axis events may happen at the diff --git a/diyac.c b/diyac.c index 95f0651..760edfe 100644 --- a/diyac.c +++ b/diyac.c @@ -24,9 +24,15 @@ void help() { + printf("diyac - a simple Wayland compositor\n"); printf("Usage: diyac [-x] [startup command]\n"); printf("Options:\n"); printf(" -x exit with the session\n"); + printf(" -v increase log level\n"); + printf(" -h show this help message\n"); +#ifdef __COMPOSITOR_VERSION__ + printf("Version: %s\n", __COMPOSITOR_VERSION__); +#endif } /** diff --git a/foreign.c b/foreign.c index b5378be..d7ffcad 100644 --- a/foreign.c +++ b/foreign.c @@ -29,6 +29,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) static void handle_request_activate(struct wl_listener *listener, void *data) { + (void) data; struct diyac_view *view = wl_container_of(listener, view, toplevel.activate); // struct wlr_foreign_toplevel_handle_v1_activated_event *event = data; /* In a multi-seat world we would select seat based on event->seat here. */ @@ -39,6 +40,7 @@ static void handle_request_activate(struct wl_listener *listener, void *data) static void handle_request_close(struct wl_listener *listener, void *data) { + (void) data; struct diyac_view *view = wl_container_of(listener, view, toplevel.close); wlr_xdg_toplevel_send_close(view->xdg_toplevel); } @@ -46,6 +48,7 @@ handle_request_close(struct wl_listener *listener, void *data) static void handle_destroy(struct wl_listener *listener, void *data) { + (void) data; struct diyac_view *view = wl_container_of(listener, view, toplevel.destroy); struct foreign_toplevel *toplevel = &view->toplevel; wl_list_remove(&toplevel->maximize.link); diff --git a/layer.c b/layer.c index af31f89..0a3b1cf 100644 --- a/layer.c +++ b/layer.c @@ -53,6 +53,7 @@ static void process_keyboard_interactivity(struct diyac_layer_surface *layer) } static void layer_surface_commit(struct wl_listener *listener, void *data) { + (void) data; struct diyac_layer_surface *layer = wl_container_of(listener, layer, surface_commit); struct wlr_layer_surface_v1 *layer_surface = @@ -94,6 +95,7 @@ static void layer_surface_commit(struct wl_listener *listener, void *data) } static void layer_surface_unmap(struct wl_listener *listener, void *data) { + (void) data; struct diyac_layer_surface *layer = wl_container_of(listener, layer, unmap); struct wlr_layer_surface_v1 *layer_surface = layer->scene_layer_surface->layer_surface; @@ -109,6 +111,7 @@ static void layer_surface_unmap(struct wl_listener *listener, void *data) static void layer_surface_map(struct wl_listener *listener, void *data) { + (void) data; struct diyac_layer_surface *layer = wl_container_of(listener, layer, map); struct wlr_output *wlr_output = layer->scene_layer_surface->layer_surface->output; @@ -127,6 +130,7 @@ static void layer_surface_map(struct wl_listener *listener, void *data) } static void layer_surface_node_destroy(struct wl_listener *listener, void *data) { + (void) data; struct diyac_layer_surface *layer = wl_container_of(listener, layer, node_destroy); @@ -142,6 +146,7 @@ static void layer_surface_node_destroy(struct wl_listener *listener, void *data) } static void layer_surface_output_destroy(struct wl_listener *listener, void *data) { + (void) data; struct diyac_layer_surface *layer = wl_container_of(listener, layer, output_destroy); layer->scene_layer_surface->layer_surface->output = NULL; @@ -150,6 +155,7 @@ static void layer_surface_output_destroy(struct wl_listener *listener, void *dat static void popup_handle_destroy(struct wl_listener *listener, void *data) { + (void)data; struct diyac_popup *popup = wl_container_of(listener, popup, destroy); wl_list_remove(&popup->destroy.link); wl_list_remove(&popup->new_popup.link); @@ -165,6 +171,7 @@ popup_handle_destroy(struct wl_listener *listener, void *data) static void popup_handle_commit(struct wl_listener *listener, void *data) { + (void)data; struct diyac_popup *popup = wl_container_of(listener, popup, commit); struct wlr_box popup_box ; diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..e805d66 --- /dev/null +++ b/meson.build @@ -0,0 +1,73 @@ +project('diyac', + ['c'], + version: '0.1.0', + license: 'MIT', + meson_version: '>=0.58.0', + default_options: ['c_std=gnu11', 'warning_level=3']) + +lib_so_version = '0' + +add_project_arguments( + [ + '-Wno-pedantic', + '-Werror=implicit-function-declaration', + '-Werror=return-type', + '-DWLR_USE_UNSTABLE', + '-D__COMPOSITOR_VERSION__="@0@"'.format(meson.project_version()) + ], + language: 'c') + +wlroots = dependency('wlroots') +wayland_server = dependency('wayland-server', version: '>=1.10.0') +xkbcommon = dependency('xkbcommon') + +# wayland_scanner is required, but we can find it without pkg-config +wayland_scanner = find_program('wayland-scanner') + +wayland_protocols = dependency('wayland-protocols', version: '>=1.16') + +wl_protocol_dir = wayland_protocols.get_variable('pkgdatadir') + + +wayland_targets=[] + +wl_protocols = [ + wl_protocol_dir / 'stable/xdg-shell/xdg-shell', + 'protocol/wlr-layer-shell-unstable-v1', +] + +foreach proto : wl_protocols + xml = ''.join([proto,'.xml']) + header = ''.join([proto.split('/').get(-1),'.h']) + cfile = ''.join([proto.split('/').get(-1),'.c']) + wayland_targets += custom_target(header,output:header,input:xml, + command: [ wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@' ] ) + wayland_targets += custom_target(cfile,output:cfile,input:xml, + command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ] ) +endforeach + + +incdir = include_directories([ +]) + +src = [ + 'diyac.c', + 'cursor.c', + 'output.c', + 'seat.c', + 'node.c', + 'view.c', + 'foreign.c', + 'xdg.c', + 'layer.c', + 'session.c', + wayland_targets +] + +buil_dep = [wlroots, wayland_server, xkbcommon] + +executable( + 'diyac', + src, + dependencies: buil_dep, + include_directories : incdir) \ No newline at end of file diff --git a/node.c b/node.c index 5faae26..843e8ce 100644 --- a/node.c +++ b/node.c @@ -5,6 +5,7 @@ static void destroy_notify(struct wl_listener *listener, void *data) { + (void)data; struct diyac_node_descriptor *node_descriptor = wl_container_of(listener, node_descriptor, destroy); wl_list_remove(&node_descriptor->destroy.link); diff --git a/output.c b/output.c index e0f8c82..a54ac29 100644 --- a/output.c +++ b/output.c @@ -11,6 +11,7 @@ static void output_frame(struct wl_listener *listener, void *data) { + (void) data; /* This function is called every time an output is ready to display a frame, * generally at the output's refresh rate (e.g. 60Hz). */ struct diyac_output *output = wl_container_of(listener, output, frame); @@ -39,6 +40,7 @@ static void output_request_state(struct wl_listener *listener, void *data) static void output_destroy(struct wl_listener *listener, void *data) { + (void)data; struct diyac_output *output = wl_container_of(listener, output, destroy); if(output->lock_handle) { diff --git a/seat.c b/seat.c index 1b6e02f..c22ceaf 100644 --- a/seat.c +++ b/seat.c @@ -10,6 +10,7 @@ static void configure_keyboard(struct diyac_seat* seat, struct diyac_input* input, bool force) { + (void) seat; struct wlr_input_device *device = input->device; assert(device->type == WLR_INPUT_DEVICE_KEYBOARD); struct diyac_keyboard *keyboard = (struct diyac_keyboard *)input; @@ -41,6 +42,7 @@ static void configure_keyboard(struct diyac_seat* seat, struct diyac_input* inpu static void keyboard_handle_modifiers( struct wl_listener *listener, void *data) { + (void) data; /* This event is raised when a modifier key, such as shift or alt, is * pressed. We simply communicate this to the client. */ struct diyac_keyboard *keyboard = @@ -128,6 +130,7 @@ static void keyboard_handle_key( static void input_handle_destroy(struct wl_listener *listener, void *data) { + (void) data; /* This event is raised by the keyboard base wlr_input_device to signal * the destruction of the wlr_keyboard. It will no longer receive events * and should be destroyed. diff --git a/session.c b/session.c index 23f5fbd..8a563ed 100644 --- a/session.c +++ b/session.c @@ -39,6 +39,7 @@ static void session_lock_update_geometry(struct diyac_output *output, bool align static void handle_surface_map(struct wl_listener *listener, void *data) { + (void) data; struct diyac_output_lock_handle *handle = wl_container_of(listener, handle, surface_map); if (!g_server->lock->focused) { @@ -49,6 +50,7 @@ static void handle_surface_map(struct wl_listener *listener, void *data) static void handle_surface_destroy(struct wl_listener *listener, void *data) { + (void) data; struct diyac_output_lock_handle *handle = wl_container_of(listener, handle, surface_destroy); if (g_server->lock->focused == handle->surface->surface) @@ -123,6 +125,7 @@ static void session_lock_destroy(struct diyac_session_lock *lock) static void handle_unlock(struct wl_listener *listener, void *data) { + (void) data; struct diyac_session_lock *lock = wl_container_of(listener, lock, unlock); wlr_log(WLR_INFO, "handle_unlock: Lock session is unlocked"); session_lock_destroy(lock); @@ -131,6 +134,7 @@ static void handle_unlock(struct wl_listener *listener, void *data) static void handle_session_lock_destroy(struct wl_listener *listener, void *data) { + (void) data; struct diyac_session_lock *lock = wl_container_of(listener, lock, destroy); lock->abandoned = true; wlr_log(WLR_INFO, "handle_session_lock_destroy: Lock session is destroyed without unlocking, session abandoned"); @@ -141,6 +145,7 @@ static void handle_session_lock_destroy(struct wl_listener *listener, void *data static void handle_new_session_lock(struct wl_listener *listener, void *data) { + (void) listener; struct wlr_session_lock_v1 *lock = data; if (g_server->lock) { @@ -200,6 +205,8 @@ static void handle_commit(struct wl_listener *listener, void *data) static void handle_lock_manager_destroy(struct wl_listener *listener, void *data) { + (void) data; + (void) listener; if (g_server->lock) { session_lock_destroy(g_server->lock); @@ -245,9 +252,9 @@ void diyac_session_lock_output(struct diyac_output *output) handle->background = wlr_scene_rect_create(handle->tree, 0, 0, black); if (!handle->background) { + wlr_scene_node_destroy(&handle->tree->node); free(handle); wlr_log(WLR_ERROR, "diyac_session_lock_output:Unable to create lock background"); - wlr_scene_node_destroy(&handle->tree->node); exit(EXIT_FAILURE); } handle->surface = NULL; diff --git a/view.c b/view.c index 00e9d4a..b5cc9df 100644 --- a/view.c +++ b/view.c @@ -183,8 +183,8 @@ void diyac_focus_topmost_view(struct diyac_server *server, bool raise) struct diyac_view *diyac_topmost_focusable_view(struct diyac_server *server) { - struct wlr_surface *prev = - server->seat.wlr_seat->keyboard_state.focused_surface; + //struct wlr_surface *prev = + // server->seat.wlr_seat->keyboard_state.focused_surface; struct diyac_view *view; struct wl_list *node_list; struct wlr_scene_node *node; diff --git a/xdg.c b/xdg.c index 5fd4e40..7f74b7a 100644 --- a/xdg.c +++ b/xdg.c @@ -55,6 +55,7 @@ static void begin_interactive(struct diyac_view *toplevel, } static void xdg_toplevel_commit(struct wl_listener *listener, void *data) { + (void)data; struct diyac_view *toplevel = wl_container_of(listener, toplevel, commit); uint32_t serial = toplevel->configuration_serial; @@ -84,6 +85,7 @@ static void xdg_toplevel_commit(struct wl_listener *listener, void *data) } static void xdg_toplevel_map(struct wl_listener *listener, void *data) { + (void)data; wlr_log(WLR_INFO, "xdg_toplevel_map: %p", listener); /* Called when the surface is mapped, or ready to display on-screen. */ struct diyac_view *toplevel = wl_container_of(listener, toplevel, map); @@ -120,6 +122,7 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data) static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) { + (void)data; /* Called when the surface is unmapped, and should no longer be shown. */ struct diyac_view *toplevel = wl_container_of(listener, toplevel, unmap); toplevel->mapped = false; @@ -158,6 +161,7 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) static void xdg_toplevel_request_move( struct wl_listener *listener, void *data) { + (void)data; /* This event is raised when a client would like to begin an interactive * move, typically because the user clicked on their client-side * decorations. Note that a more sophisticated compositor should check the @@ -184,6 +188,7 @@ static void xdg_toplevel_request_resize( static void xdg_toplevel_request_maximize( struct wl_listener *listener, void *data) { + (void)data; /* This event is raised when a client would like to maximize itself, * typically because the user clicked on the maximize button on * client-side decorations. diyac doesn't support maximization, but @@ -197,6 +202,7 @@ static void xdg_toplevel_request_maximize( static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data) { + (void)data; struct diyac_view *toplevel = wl_container_of(listener, toplevel, request_fullscreen); diyac_view_set_fullscreen(toplevel, toplevel->xdg_toplevel->requested.fullscreen); @@ -204,6 +210,7 @@ static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void * static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *data) { + (void)data; struct diyac_view *toplevel = wl_container_of(listener, toplevel, request_minimize); diyac_view_set_mimimize(toplevel, toplevel->xdg_toplevel->requested.minimized); @@ -211,6 +218,7 @@ static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *da static void xdg_toplevel_destroy(struct wl_listener *listener, void *data) { + (void)data; /* Called when the xdg_toplevel is destroyed. */ struct diyac_view *toplevel = wl_container_of(listener, toplevel, destroy); if (toplevel->toplevel.handle) @@ -243,6 +251,7 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data) static void handle_xdg_popup_destroy(struct wl_listener *listener, void *data) { + (void)data; struct diyac_popup *popup = wl_container_of(listener, popup, destroy); wl_list_remove(&popup->destroy.link); wl_list_remove(&popup->new_popup.link); @@ -262,9 +271,9 @@ static void popup_unconstrain(struct diyac_popup *popup) { return; } - struct diyac_server *server = view->server; - struct wlr_output_layout *output_layout = server->output_layout; - struct wlr_output *wlr_output = view->output->wlr_output; + // struct diyac_server *server = view->server; + //struct wlr_output_layout *output_layout = server->output_layout; + //struct wlr_output *wlr_output = view->output->wlr_output; struct wlr_box usable = { .x = 0, .y = 0, @@ -287,6 +296,7 @@ static void popup_unconstrain(struct diyac_popup *popup) static void handle_xdg_popup_commit(struct wl_listener *listener, void *data) { + (void)data; struct diyac_popup *popup = wl_container_of(listener, popup, commit); struct wlr_box popup_box; wlr_xdg_surface_get_geometry(popup->wlr_popup->base, &popup_box); @@ -294,7 +304,7 @@ static void handle_xdg_popup_commit(struct wl_listener *listener, void *data) if (!wlr_box_empty(&popup_box)) // if (popup->wlr_popup->base->initial_commit) { - struct diyac_view *view = popup->parent; + // struct diyac_view *view = popup->parent; // wlr_output_commit(view->output->wlr_output); /* Prevent getting called over and over again */ wl_list_remove(&popup->commit.link); @@ -366,12 +376,14 @@ static void xdg_popup_create(struct diyac_view *view, struct wlr_xdg_popup *wlr_ static void xdg_set_appid_notify(struct wl_listener *listener, void *data) { + (void)data; struct diyac_view *view = wl_container_of(listener, view, set_app_id); diyac_view_update_app_id(view); } static void xdg_set_title_notify(struct wl_listener *listener, void *data) { + (void)data; struct diyac_view *view = wl_container_of(listener, view, set_title); diyac_view_update_title(view); }