mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
tray: implement d-bus menu
This commit is contained in:
parent
ae4ff7226f
commit
1e92def4b1
11 changed files with 1145 additions and 36 deletions
|
|
@ -48,8 +48,8 @@ struct swaybar_hotspot {
|
|||
struct wl_list link; // swaybar_output::hotspots
|
||||
int x, y, width, height;
|
||||
enum hotspot_event_handling (*callback)(struct swaybar_output *output,
|
||||
struct swaybar_hotspot *hotspot, double x, double y, uint32_t button,
|
||||
void *data);
|
||||
struct swaybar_hotspot *hotspot, struct wl_seat *seat, uint32_t serial,
|
||||
double x, double y, uint32_t button, void *data);
|
||||
void (*destroy)(void *data);
|
||||
void *data;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "swaybar/tray/tray.h"
|
||||
#include "list.h"
|
||||
|
||||
struct swaybar_menu;
|
||||
struct swaybar_output;
|
||||
|
||||
struct swaybar_pixmap {
|
||||
|
|
@ -21,6 +22,7 @@ struct swaybar_sni_slot {
|
|||
const char *type;
|
||||
void *dest;
|
||||
sd_bus_slot *slot;
|
||||
int menu_id;
|
||||
};
|
||||
|
||||
struct swaybar_sni {
|
||||
|
|
@ -35,7 +37,7 @@ struct swaybar_sni {
|
|||
char *watcher_id;
|
||||
char *service;
|
||||
char *path;
|
||||
char *interface;
|
||||
const char *interface;
|
||||
|
||||
char *status;
|
||||
char *icon_name;
|
||||
|
|
@ -43,10 +45,13 @@ struct swaybar_sni {
|
|||
char *attention_icon_name;
|
||||
list_t *attention_icon_pixmap; // struct swaybar_pixmap *
|
||||
bool item_is_menu;
|
||||
char *menu;
|
||||
char *menu_path;
|
||||
char *icon_theme_path; // non-standard KDE property
|
||||
|
||||
struct wl_list slots; // swaybar_sni_slot::link
|
||||
|
||||
struct swaybar_menu_item *menu;
|
||||
char **menu_icon_theme_paths;
|
||||
};
|
||||
|
||||
struct swaybar_sni *create_sni(char *id, struct swaybar_tray *tray);
|
||||
|
|
|
|||
102
include/swaybar/tray/menu.h
Normal file
102
include/swaybar/tray/menu.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#ifndef _SWAYBAR_TRAY_MENU_H
|
||||
#define _SWAYBAR_TRAY_MENU_H
|
||||
|
||||
#include <cairo.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "pool-buffer.h"
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
|
||||
struct swaybar_tray;
|
||||
struct swaybar_output;
|
||||
struct swaybar_sni;
|
||||
struct wl_seat;
|
||||
|
||||
|
||||
/* MENU */
|
||||
|
||||
struct swaybar_menu_item {
|
||||
struct swaybar_sni *sni;
|
||||
struct swaybar_menu_item *parent;
|
||||
|
||||
int32_t id;
|
||||
|
||||
bool is_separator; // instead of type
|
||||
char *label;
|
||||
bool enabled;
|
||||
bool visible;
|
||||
char *icon_name;
|
||||
cairo_surface_t *icon;
|
||||
cairo_surface_t *icon_data;
|
||||
|
||||
enum {
|
||||
MENU_NONE,
|
||||
MENU_CHECKMARK,
|
||||
MENU_RADIO
|
||||
} toggle_type;
|
||||
int toggle_state;
|
||||
|
||||
list_t *children; // struct swaybar_menu_item *
|
||||
};
|
||||
|
||||
void destroy_menu(struct swaybar_menu_item *menu);
|
||||
|
||||
|
||||
/* POPUP */
|
||||
|
||||
struct swaybar_popup_hotspot {
|
||||
int y;
|
||||
struct swaybar_menu_item *item;
|
||||
};
|
||||
|
||||
struct swaybar_popup_surface {
|
||||
struct swaybar_menu_item *item;
|
||||
struct swaybar_popup_surface *child;
|
||||
list_t *hotspots; // struct swaybar_popup_hotspot *
|
||||
|
||||
struct xdg_popup *xdg_popup;
|
||||
struct xdg_surface *xdg_surface;
|
||||
struct wl_surface *surface;
|
||||
struct pool_buffer buffers[2];
|
||||
struct pool_buffer *current_buffer;
|
||||
};
|
||||
|
||||
struct swaybar_popup {
|
||||
struct swaybar_tray *tray;
|
||||
struct swaybar_sni *sni;
|
||||
struct swaybar_output *output;
|
||||
struct wl_seat *seat;
|
||||
struct xdg_wm_base *wm_base;
|
||||
|
||||
struct swaybar_popup_surface *popup_surface;
|
||||
struct swaybar_popup_surface *pointer_focus;
|
||||
struct swaybar_popup_hotspot **last_hover;
|
||||
|
||||
// used to track clicks across callbacks
|
||||
uint32_t serial;
|
||||
int x, y;
|
||||
};
|
||||
|
||||
void open_popup(struct swaybar_sni *sni, struct swaybar_output *output,
|
||||
struct wl_seat *seat, uint32_t serial, int x, int y);
|
||||
void destroy_popup(struct swaybar_popup *popup);
|
||||
|
||||
|
||||
/* INPUT HOOKS
|
||||
* These functions are called at the start of their respective counterparts in
|
||||
* input.c, returning true if the event occurs on the popup instead of the bar
|
||||
*/
|
||||
|
||||
bool popup_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
wl_fixed_t surface_x, wl_fixed_t surface_y);
|
||||
bool popup_pointer_leave(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t serial, struct wl_surface *surface);
|
||||
bool popup_pointer_motion(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y);
|
||||
bool popup_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t serial, uint32_t time, uint32_t button, uint32_t state);
|
||||
bool popup_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t time, uint32_t axis, wl_fixed_t value);
|
||||
|
||||
#endif
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
struct swaybar;
|
||||
struct swaybar_output;
|
||||
struct swaybar_popup;
|
||||
struct swaybar_watcher;
|
||||
|
||||
struct swaybar_tray {
|
||||
|
|
@ -30,6 +31,8 @@ struct swaybar_tray {
|
|||
|
||||
list_t *basedirs; // char *
|
||||
list_t *themes; // struct swaybar_theme *
|
||||
|
||||
struct swaybar_popup *popup;
|
||||
};
|
||||
|
||||
struct swaybar_tray *create_tray(struct swaybar *bar);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue