mirror of
https://github.com/swaywm/sway.git
synced 2026-04-18 06:46:56 -04:00
Merge 19661d1853 into 801bc76ce3
This commit is contained in:
commit
c5e1318929
13 changed files with 1493 additions and 12 deletions
1367
swaybar/tray/dbusmenu.c
Normal file
1367
swaybar/tray/dbusmenu.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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"
|
||||
|
|
@ -332,8 +333,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) {
|
||||
|
|
@ -364,7 +366,11 @@ static void handle_click(struct swaybar_sni *sni, int x, int y,
|
|||
method = "ContextMenu";
|
||||
}
|
||||
|
||||
if (strncmp(method, "Scroll", strlen("Scroll")) == 0) {
|
||||
if (strcmp(method, "ContextMenu") == 0) {
|
||||
if (sni->menu && !sni->tray->menu) {
|
||||
swaybar_dbusmenu_open(sni, output, seat, serial, x, y);
|
||||
}
|
||||
} else if (strncmp(method, "Scroll", strlen("Scroll")) == 0) {
|
||||
char dir = method[strlen("Scroll")];
|
||||
char *orientation = (dir == 'U' || dir == 'D') ? "vertical" : "horizontal";
|
||||
int sign = (dir == 'U' || dir == 'L') ? -1 : 1;
|
||||
|
|
@ -384,6 +390,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);
|
||||
|
||||
|
|
@ -405,7 +412,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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue