summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp195
1 files changed, 0 insertions, 195 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 079001f..2df7421 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,205 +34,10 @@
#include <wayland-util.h>
#include "AglShellGrpcClient.h"
-#include "agl-shell-desktop-client-protocol.h"
-
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-#ifndef MAX
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
static int running = 1;
const char *app_id_to_activate = NULL;
-struct display;
-
-struct window_output {
- struct display *display;
- struct wl_output *output;
- char *name;
- struct wl_list link; /** display::output_list */
-};
-
-struct display {
- struct wl_display *display;
- struct wl_registry *registry;
- struct agl_shell_desktop *agl_shell_desktop;
-
- struct wl_list output_list; /** window_output::link */
-};
-
-static void
-display_handle_geometry(void *data, struct wl_output *wl_output,
- int x, int y, int physical_width, int physical_height,
- int subpixel, const char *make, const char *model, int transform)
-{
-}
-
-static void
-display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
- int width, int height, int refresh)
-{
-}
-
-static void
-display_handle_done(void *data, struct wl_output *wl_output)
-{
-}
-
-static void
-display_handle_scale(void *data, struct wl_output *wl_output, int32_t factor)
-{
-}
-
-static void
-display_handle_name(void *data, struct wl_output *wl_output, const char *name)
-{
- struct window_output *woutput = static_cast<struct window_output *>(data);
- woutput->name = strdup(name);
-
- fprintf(stderr, "Adding output '%s'\n", name);
-}
-
-static void
-display_handle_description(void *data, struct wl_output *wl_output, const char *description)
-{
-}
-
-static const struct wl_output_listener output_listener = {
- display_handle_geometry,
- display_handle_mode,
- display_handle_done,
- display_handle_scale,
- display_handle_name,
- display_handle_description,
-};
-
-
-static void
-display_add_output(struct display *display, uint32_t id, uint32_t version)
-{
- struct window_output *w_output;
-
- w_output = static_cast<struct window_output *>(calloc(1, sizeof(*w_output)));
- w_output->display = display;
-
- if (version < 4)
- w_output->output =
- static_cast<struct wl_output *>(wl_registry_bind(display->registry, id, &wl_output_interface, MAX(version, 3)));
- else
- w_output->output =
- static_cast<struct wl_output *>(wl_registry_bind(display->registry, id, &wl_output_interface, MIN(version, 4)));
-
- wl_list_insert(&display->output_list, &w_output->link);
- wl_output_add_listener(w_output->output, &output_listener, w_output);
-}
-
-static void
-destroy_output(struct window_output *w_output)
-{
- free(w_output->name);
- wl_list_remove(&w_output->link);
- free(w_output);
-}
-
-static void app(void *data, struct agl_shell_desktop *agl_shell_desktop,
- const char *appid)
-{
- /* UNUSED */
-}
-
-static void state_app(void *data, struct agl_shell_desktop *agl_shell_desktop,
- const char *app_id, const char *app_data, uint32_t state,
- uint32_t role)
-{
- if (strcmp(app_id, app_id_to_activate) == 0 &&
- state == AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED) {
- running = 0;
- }
-}
-
-static const struct agl_shell_desktop_listener desktop_shell_listener = {
- app,
- state_app,
-};
-
-static void
-registry_handle_global(void *data, struct wl_registry *registry,
- uint32_t id, const char *interface, uint32_t version)
-{
- struct display *d = static_cast<struct display *>(data);
-
- if (strcmp(interface, "agl_shell_desktop") == 0) {
- d->agl_shell_desktop =
- static_cast<struct agl_shell_desktop *>(wl_registry_bind(registry, id, &agl_shell_desktop_interface, 1));
- agl_shell_desktop_add_listener(d->agl_shell_desktop,
- &desktop_shell_listener, d);
- } else if (strcmp(interface, "wl_output") == 0) {
- if (version < 4)
- fprintf(stderr, "Failed to bind to version 4. "
- "Current version %d\n", version);
- display_add_output(d, id, version);
- }
-}
-
-static void
-registry_handle_global_remove(void *data, struct wl_registry *registry,
- uint32_t name)
-{
-
-}
-
-static const struct wl_registry_listener registry_listener = {
- registry_handle_global,
- registry_handle_global_remove
-};
-
-static struct display *
-create_display(void)
-{
- struct display *display;
-
- display = static_cast<struct display *>(malloc(sizeof *display));
- if (display == NULL) {
- fprintf(stderr, "out of memory\n");
- exit(1);
- }
-
- wl_list_init(&display->output_list);
- display->display = wl_display_connect(NULL);
- assert(display->display);
-
- display->registry = wl_display_get_registry(display->display);
-
- wl_registry_add_listener(display->registry, &registry_listener, display);
- wl_display_roundtrip(display->display);
-
- if (display->agl_shell_desktop == NULL) {
- fprintf(stderr, "No agl_shell_desktop extension present\n");
- }
-
- wl_display_roundtrip(display->display);
- return display;
-}
-
-static void
-destroy_display(struct display *display)
-{
- struct window_output *w_output, *w_output_next;
-
- wl_list_for_each_safe(w_output, w_output_next, &display->output_list, link)
- destroy_output(w_output);
-
- wl_registry_destroy(display->registry);
-
- wl_display_flush(display->display);
- wl_display_disconnect(display->display);
-
- free(display);
-}
-
static void
run_in_thread(GrpcClient *client)
{