void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id, int desired_output) { /* initialize bar with default values */ bar_init(bar); bar->output->registry = registry_poll(); if (!bar->output->registry->desktop_shell) { sway_abort("swaybar requires the compositor to support the desktop-shell extension."); } /* connect to sway ipc */ bar->ipc_socketfd = ipc_open_socket(socket_path); bar->ipc_event_socketfd = ipc_open_socket(socket_path); ipc_bar_init(bar, desired_output, bar_id); struct output_state *output = bar->output->registry->outputs->items[desired_output]; bar->output->window = window_setup(bar->output->registry, output->width, 30, false); if (!bar->output->window) { sway_abort("Failed to create window."); } desktop_shell_set_panel(bar->output->registry->desktop_shell, output->output, bar->output->window->surface); desktop_shell_set_panel_position(bar->output->registry->desktop_shell, bar->config->position); /* set font */ bar->output->window->font = bar->config->font; /* set window height */ set_window_height(bar->output->window, bar->config->height); /* spawn status command */ spawn_status_cmd_proc(bar); }
void consort_shell_set_panel_window (ConsortShell *shell, gpointer panel_window) { GdkWindow *window; ConsortShellPrivate *priv; struct element *panel; struct desktop *desktop; priv = CONSORT_SHELL_GET_PRIVATE (shell); desktop = priv->desktop; panel = malloc(sizeof *panel); memset(panel, 0, sizeof *panel); window = gtk_widget_get_window (GTK_WINDOW (panel_window)); gdk_wayland_window_set_use_custom_surface (window); panel->surface = gdk_wayland_window_get_wl_surface (window); desktop_shell_set_user_data(desktop->shell, desktop); desktop_shell_set_panel(desktop->shell, desktop->output, panel->surface); }
static void panel_create (struct desktop *desktop) { struct element *panel; GdkWindow *gdk_window; panel = malloc (sizeof *panel); memset (panel, 0, sizeof *panel); panel->window = maynard_panel_new (); g_signal_connect (panel->window, "app-menu-toggled", G_CALLBACK (launcher_grid_toggle), desktop); g_signal_connect (panel->window, "system-toggled", G_CALLBACK (system_toggled_cb), desktop); g_signal_connect (panel->window, "volume-toggled", G_CALLBACK (volume_toggled_cb), desktop); g_signal_connect (panel->window, "favorite-launched", G_CALLBACK (favorite_launched_cb), desktop); desktop->initial_panel_timeout_id = g_timeout_add_seconds (2, panel_hide_timeout_cb, desktop); /* set it up as the panel */ gdk_window = gtk_widget_get_window (panel->window); gdk_wayland_window_set_use_custom_surface (gdk_window); panel->surface = gdk_wayland_window_get_wl_surface (gdk_window); desktop_shell_set_user_data (desktop->shell, desktop); desktop_shell_set_panel (desktop->shell, desktop->output, panel->surface); desktop_shell_set_panel_position (desktop->shell, DESKTOP_SHELL_PANEL_POSITION_LEFT); gtk_widget_show_all (panel->window); desktop->panel = panel; }