mirror of
https://github.com/swaywm/sway.git
synced 2026-06-16 14:34:04 -04:00
Merge d18bf0f261 into 47ec005a58
This commit is contained in:
commit
af55e39143
17 changed files with 1499 additions and 22 deletions
1383
swaybar/tray/dbusmenu.c
Normal file
1383
swaybar/tray/dbusmenu.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,4 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -7,6 +6,7 @@
|
|||
#include "swaybar/tray/host.h"
|
||||
#include "swaybar/tray/item.h"
|
||||
#include "swaybar/tray/tray.h"
|
||||
#include "swaybar/tray/dbusmenu.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "stringop.h"
|
||||
|
|
@ -55,7 +55,9 @@ static int handle_sni_unregistered(sd_bus_message *msg, void *data,
|
|||
int idx = list_seq_find(tray->items, cmp_sni_id, id);
|
||||
if (idx != -1) {
|
||||
sway_log(SWAY_INFO, "Unregistering Status Notifier Item '%s'", id);
|
||||
destroy_sni(tray->items->items[idx]);
|
||||
struct swaybar_sni *sni = tray->items->items[idx];
|
||||
swaybar_dbusmenu_destroy(sni->tray->menu);
|
||||
destroy_sni(sni);
|
||||
list_del(tray->items, idx);
|
||||
set_bar_dirty(tray->bar);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "swaybar/config.h"
|
||||
#include "swaybar/image.h"
|
||||
#include "swaybar/input.h"
|
||||
#include "swaybar/tray/dbusmenu.h"
|
||||
#include "swaybar/tray/host.h"
|
||||
#include "swaybar/tray/icon.h"
|
||||
#include "swaybar/tray/item.h"
|
||||
|
|
@ -18,8 +19,6 @@
|
|||
#include "stringop.h"
|
||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
// TODO menu
|
||||
|
||||
static bool sni_ready(struct swaybar_sni *sni) {
|
||||
return sni->status && (sni->status[0] == 'N' ? // NeedsAttention
|
||||
sni->attention_icon_name || sni->attention_icon_pixmap :
|
||||
|
|
@ -333,8 +332,9 @@ void destroy_sni(struct swaybar_sni *sni) {
|
|||
free(sni);
|
||||
}
|
||||
|
||||
static void handle_click(struct swaybar_sni *sni, int x, int y,
|
||||
uint32_t button, int delta) {
|
||||
static void handle_click(struct swaybar_sni *sni, struct swaybar_output *output,
|
||||
struct swaybar_seat *seat, uint32_t serial, int x, int y, uint32_t button,
|
||||
int delta) {
|
||||
const char *method = NULL;
|
||||
struct tray_binding *binding = NULL;
|
||||
wl_list_for_each(binding, &sni->tray->bar->config->tray_bindings, link) {
|
||||
|
|
@ -365,7 +365,11 @@ static void handle_click(struct swaybar_sni *sni, int x, int y,
|
|||
method = "ContextMenu";
|
||||
}
|
||||
|
||||
if (has_prefix(method, "Scroll")) {
|
||||
if (has_prefix(method, "ContextMenu")) {
|
||||
if (sni->menu && !sni->tray->menu) {
|
||||
swaybar_dbusmenu_open(sni, output, seat, serial, x, y);
|
||||
}
|
||||
} else if (has_prefix(method, "Scroll")) {
|
||||
char dir = method[strlen("Scroll")];
|
||||
char *orientation = (dir == 'U' || dir == 'D') ? "vertical" : "horizontal";
|
||||
int sign = (dir == 'U' || dir == 'L') ? -1 : 1;
|
||||
|
|
@ -385,6 +389,7 @@ static int cmp_sni_id(const void *item, const void *cmp_to) {
|
|||
|
||||
static enum hotspot_event_handling icon_hotspot_callback(
|
||||
struct swaybar_output *output, struct swaybar_hotspot *hotspot,
|
||||
struct swaybar_seat *seat, uint32_t serial,
|
||||
double x, double y, uint32_t button, bool released, void *data) {
|
||||
sway_log(SWAY_DEBUG, "Clicked on %s", (char *)data);
|
||||
|
||||
|
|
@ -406,7 +411,8 @@ static enum hotspot_event_handling icon_hotspot_callback(
|
|||
(int) output->output_height - config->gaps.bottom - y);
|
||||
|
||||
sway_log(SWAY_DEBUG, "Guessing click position at (%d, %d)", global_x, global_y);
|
||||
handle_click(sni, global_x, global_y, button, 1); // TODO get delta from event
|
||||
// TODO get delta from event
|
||||
handle_click(sni, output, seat, serial, global_x, global_y, button, 1);
|
||||
return HOTSPOT_IGNORE;
|
||||
} else {
|
||||
sway_log(SWAY_DEBUG, "but it doesn't exist");
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static int cmp_output(const void *item, const void *cmp_to) {
|
|||
|
||||
uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) {
|
||||
struct swaybar_config *config = output->bar->config;
|
||||
if (config->tray_outputs) {
|
||||
if (config->tray_outputs && !config->tray_hidden) {
|
||||
if (list_seq_find(config->tray_outputs, cmp_output, output) == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "list.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue