1 /* See LICENSE file for copyright and license details. */ 2 #include <stdbool.h> 3 #include <wayland-client.h> 4 #include <cairo/cairo.h> 5 #include "wlr-layer-shell-unstable-v1-client-protocol.h" 6 #include <xkbcommon/xkbcommon.h> 7 8 #define MAX_MONITOR_NAME_LEN 255 9 10 #define FG(dc, col) ((col)[(dc)->invert ? ColBG : ColFG]) 11 #define BG(dc, col) ((col)[(dc)->invert ? ColFG : ColBG]) 12 13 enum { ColBG, ColFG, ColBorder, ColLast }; 14 15 struct dmenu_panel; 16 17 struct monitor_info { 18 int32_t physical_width; 19 int32_t physical_height; 20 int32_t logical_width; 21 int32_t logical_height; 22 double scale; 23 24 char name[MAX_MONITOR_NAME_LEN]; 25 26 enum wl_output_subpixel subpixel; 27 28 struct zxdg_output_v1 *xdg_output; 29 30 struct wl_output *output; 31 struct dmenu_panel *panel; 32 }; 33 34 extern struct monitor_info *monitors[]; 35 36 struct display_info { 37 struct zxdg_output_manager_v1 *xdg_output_manager; 38 struct wl_display * display; 39 struct wl_compositor *compositor; 40 struct wl_seat *seat; 41 42 }; 43 44 struct keyboard_info { 45 struct wl_keyboard *kbd; 46 struct xkb_context *xkb_context; 47 struct xkb_keymap *xkb_keymap; 48 struct xkb_state *xkb_state; 49 bool control; 50 bool shift; 51 }; 52 53 struct surface { 54 cairo_t *cairo; 55 struct wl_buffer *buffer; 56 struct wl_surface *surface; 57 struct wl_shm *shm; 58 void *shm_data; 59 struct zwlr_layer_shell_v1 *layer_shell; 60 struct zwlr_layer_surface_v1 *layer_surface; 61 }; 62 63 struct dmenu_panel { 64 struct keyboard_info keyboard; 65 /* struct monitor_info monitor; */ 66 int selected_monitor; 67 char *selected_monitor_name; 68 69 struct monitor_info *monitor; 70 struct display_info display_info; 71 72 struct surface surface; 73 74 void (*on_keyevent)(struct dmenu_panel *,enum wl_keyboard_key_state, 75 xkb_keysym_t, bool, bool); 76 77 void (*draw)(cairo_t *, int32_t, int32_t, int32_t); 78 79 int32_t width; 80 int32_t height; 81 82 bool running; 83 }; 84 85 void dmenu_init_panel(struct dmenu_panel *, int32_t, bool); 86 void dmenu_draw(struct dmenu_panel *); 87 void dmenu_show(struct dmenu_panel *); 88 void dmenu_close(struct dmenu_panel *); 89 90 91 void pango_printf(cairo_t *cairo, const char *font, 92 double scale, bool markup, const char *fmt, ...); 93 void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, 94 int *baseline, double scale, bool markup, const char *fmt, ...); 95 void eprintf(const char *fmt, ...); 96 void weprintf(const char *fmt, ...); 97 int32_t round_to_int(double val); 98 99 extern const char *progname; 100