2016-01-24 02:34:20 +01:00
|
|
|
#ifndef _SWAYBAR_BAR_H
|
|
|
|
#define _SWAYBAR_BAR_H
|
2018-03-28 23:04:20 -04:00
|
|
|
#include <wayland-client.h>
|
2018-10-28 10:25:47 +00:00
|
|
|
#include "config.h"
|
2018-10-17 20:21:27 +01:00
|
|
|
#include "input.h"
|
2018-03-28 23:04:20 -04:00
|
|
|
#include "pool-buffer.h"
|
2018-09-17 16:04:09 +02:00
|
|
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
|
|
|
#include "xdg-output-unstable-v1-client-protocol.h"
|
2016-01-23 20:55:01 +01:00
|
|
|
|
2018-03-28 23:04:20 -04:00
|
|
|
struct swaybar_config;
|
|
|
|
struct swaybar_output;
|
2018-10-28 10:25:47 +00:00
|
|
|
#if HAVE_TRAY
|
|
|
|
struct swaybar_tray;
|
|
|
|
#endif
|
2018-03-28 23:04:20 -04:00
|
|
|
struct swaybar_workspace;
|
2018-10-13 16:04:37 +10:00
|
|
|
struct loop;
|
2018-03-28 23:04:20 -04:00
|
|
|
|
|
|
|
struct swaybar {
|
2018-09-30 15:09:09 +01:00
|
|
|
char *id;
|
2018-10-12 20:23:01 +01:00
|
|
|
char *mode;
|
|
|
|
bool mode_pango_markup;
|
2018-09-30 15:09:09 +01:00
|
|
|
|
2018-10-12 20:32:48 +01:00
|
|
|
// only relevant when bar is in "hide" mode
|
|
|
|
bool visible_by_modifier;
|
|
|
|
bool visible_by_urgency;
|
2019-04-24 00:25:49 -04:00
|
|
|
bool visible_by_mode;
|
2018-10-12 20:32:48 +01:00
|
|
|
bool visible;
|
|
|
|
|
2018-03-28 23:04:20 -04:00
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_compositor *compositor;
|
|
|
|
struct zwlr_layer_shell_v1 *layer_shell;
|
2018-09-17 16:04:09 +02:00
|
|
|
struct zxdg_output_manager_v1 *xdg_output_manager;
|
2018-03-28 23:04:20 -04:00
|
|
|
struct wl_shm *shm;
|
2016-01-23 20:55:01 +01:00
|
|
|
|
2018-03-28 23:04:20 -04:00
|
|
|
struct swaybar_config *config;
|
2018-03-29 15:16:12 -04:00
|
|
|
struct status_line *status;
|
2018-03-28 23:04:20 -04:00
|
|
|
|
2018-10-13 16:04:37 +10:00
|
|
|
struct loop *eventloop;
|
|
|
|
|
2018-03-28 23:56:02 -04:00
|
|
|
int ipc_event_socketfd;
|
|
|
|
int ipc_socketfd;
|
|
|
|
|
2018-10-06 19:02:12 +01:00
|
|
|
struct wl_list outputs; // swaybar_output::link
|
2019-09-02 21:41:11 -04:00
|
|
|
struct wl_list unused_outputs; // swaybar_output::link
|
2019-04-23 23:40:00 -04:00
|
|
|
struct wl_list seats; // swaybar_seat::link
|
2018-10-28 10:25:47 +00:00
|
|
|
|
|
|
|
#if HAVE_TRAY
|
|
|
|
struct swaybar_tray *tray;
|
|
|
|
#endif
|
2019-02-14 15:43:34 +00:00
|
|
|
|
|
|
|
bool running;
|
2016-01-23 20:55:01 +01:00
|
|
|
};
|
|
|
|
|
2018-03-28 23:04:20 -04:00
|
|
|
struct swaybar_output {
|
2018-10-06 19:02:12 +01:00
|
|
|
struct wl_list link; // swaybar::outputs
|
2018-03-28 23:04:20 -04:00
|
|
|
struct swaybar *bar;
|
|
|
|
struct wl_output *output;
|
2018-09-17 16:04:09 +02:00
|
|
|
struct zxdg_output_v1 *xdg_output;
|
2018-03-28 23:04:20 -04:00
|
|
|
struct wl_surface *surface;
|
|
|
|
struct zwlr_layer_surface_v1 *layer_surface;
|
2019-02-23 21:59:36 -08:00
|
|
|
struct wl_region *input_region;
|
2018-04-05 15:39:57 -04:00
|
|
|
uint32_t wl_name;
|
2018-03-28 23:04:20 -04:00
|
|
|
|
2018-10-06 19:02:12 +01:00
|
|
|
struct wl_list workspaces; // swaybar_workspace::link
|
|
|
|
struct wl_list hotspots; // swaybar_hotspot::link
|
2018-03-29 00:21:05 -04:00
|
|
|
|
2016-01-24 00:23:09 +01:00
|
|
|
char *name;
|
2019-01-13 12:06:35 -05:00
|
|
|
char *identifier;
|
2016-11-02 18:48:43 +01:00
|
|
|
bool focused;
|
2016-01-23 20:55:01 +01:00
|
|
|
|
2018-03-28 23:04:20 -04:00
|
|
|
uint32_t width, height;
|
2018-04-03 21:06:28 -04:00
|
|
|
int32_t scale;
|
2018-09-20 20:37:08 -07:00
|
|
|
enum wl_output_subpixel subpixel;
|
2018-03-28 23:04:20 -04:00
|
|
|
struct pool_buffer buffers[2];
|
|
|
|
struct pool_buffer *current_buffer;
|
2018-09-28 16:17:15 +01:00
|
|
|
bool dirty;
|
|
|
|
bool frame_scheduled;
|
2018-12-07 12:39:35 +00:00
|
|
|
|
|
|
|
uint32_t output_height, output_width, output_x, output_y;
|
2016-01-23 20:55:01 +01:00
|
|
|
};
|
|
|
|
|
2018-03-29 00:21:05 -04:00
|
|
|
struct swaybar_workspace {
|
2018-10-06 19:02:12 +01:00
|
|
|
struct wl_list link; // swaybar_output::workspaces
|
2018-03-29 00:21:05 -04:00
|
|
|
int num;
|
|
|
|
char *name;
|
2018-11-17 16:11:28 +00:00
|
|
|
char *label;
|
2018-03-29 00:21:05 -04:00
|
|
|
bool focused;
|
|
|
|
bool visible;
|
|
|
|
bool urgent;
|
|
|
|
};
|
|
|
|
|
2018-09-30 15:09:09 +01:00
|
|
|
bool bar_setup(struct swaybar *bar, const char *socket_path);
|
2018-03-28 23:04:20 -04:00
|
|
|
void bar_run(struct swaybar *bar);
|
|
|
|
void bar_teardown(struct swaybar *bar);
|
2016-07-10 22:47:10 -05:00
|
|
|
|
2018-12-07 12:40:45 +00:00
|
|
|
void set_bar_dirty(struct swaybar *bar);
|
|
|
|
|
2018-10-12 20:32:48 +01:00
|
|
|
/*
|
|
|
|
* Determines whether the bar should be visible and changes it to be so.
|
|
|
|
* If the current visibility of the bar is the different to what it should be,
|
|
|
|
* then it adds or destroys the layer surface as required,
|
|
|
|
* as well as sending the cont or stop signal to the status command.
|
|
|
|
* If the current visibility of the bar is already what it should be,
|
|
|
|
* then this function is a no-op, unless moving_layer is true, which occurs
|
|
|
|
* when the bar changes from "hide" to "dock" mode or vice versa, and the bar
|
|
|
|
* needs to be destroyed and re-added in order to change its layer.
|
|
|
|
*
|
|
|
|
* Returns true if the bar is now visible, otherwise false.
|
|
|
|
*/
|
|
|
|
bool determine_bar_visibility(struct swaybar *bar, bool moving_layer);
|
2018-04-24 22:04:19 +01:00
|
|
|
void free_workspaces(struct wl_list *list);
|
|
|
|
|
2019-09-02 21:41:11 -04:00
|
|
|
void status_in(int fd, short mask, void *data);
|
|
|
|
|
|
|
|
void destroy_layer_surface(struct swaybar_output *output);
|
|
|
|
|
2018-03-28 23:04:20 -04:00
|
|
|
#endif
|