-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tray D-Bus Menu #8405
Open
grazzolini
wants to merge
6
commits into
swaywm:master
Choose a base branch
from
grazzolini:tray-dbus-menu
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tray D-Bus Menu #8405
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1868bfd
ci: checkout wlroots 0.17
emersion 3fc5ba6
Fix build with wlroots DRM backend disabled
emersion fffe886
Tray: Implement dbusmenu
56ade4f
Tray: don't invoke dbus menu when tray is disabled
FlorianFranzen 0eb4afc
* Tray dbus menu patches
grazzolini 19661d1
Apply suggestions from code review
grazzolini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef _SWAYBAR_TRAY_DBUSMENU_H | ||
#define _SWAYBAR_TRAY_DBUSMENU_H | ||
|
||
#include "swaybar/bar.h" | ||
#include "swaybar/tray/item.h" | ||
|
||
void swaybar_dbusmenu_open(struct swaybar_sni *sni, | ||
struct swaybar_output *output, struct swaybar_seat *seat, uint32_t serial, | ||
int x, int y); | ||
|
||
bool dbusmenu_pointer_button(void *data, struct wl_pointer *wl_pointer, | ||
uint32_t serial, uint32_t time_, uint32_t button, uint32_t state); | ||
|
||
bool dbusmenu_pointer_motion(struct swaybar_seat *seat, struct wl_pointer *wl_pointer, | ||
uint32_t time_, wl_fixed_t surface_x, wl_fixed_t surface_y); | ||
|
||
bool dbusmenu_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 dbusmenu_pointer_leave(void *data, struct wl_pointer *wl_pointer, uint32_t serial, | ||
struct wl_surface *surface); | ||
|
||
bool dbusmenu_pointer_frame(struct swaybar_seat *data, struct wl_pointer *wl_pointer); | ||
|
||
bool dbusmenu_pointer_axis(struct swaybar_seat *data, struct wl_pointer *wl_pointer); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,10 @@ | |
#include "swaybar/input.h" | ||
#include "swaybar/ipc.h" | ||
|
||
#if HAVE_TRAY | ||
#include "swaybar/tray/dbusmenu.h" | ||
#endif | ||
|
||
void free_hotspots(struct wl_list *list) { | ||
struct swaybar_hotspot *hotspot, *tmp; | ||
wl_list_for_each_safe(hotspot, tmp, list, link) { | ||
|
@@ -131,11 +135,27 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, | |
pointer->serial = serial; | ||
update_cursor(seat); | ||
} | ||
|
||
#if HAVE_TRAY | ||
struct swaybar_config *config = seat->bar->config; | ||
if (!config->tray_hidden && dbusmenu_pointer_enter(data, wl_pointer, serial, | ||
surface, surface_x, surface_y)) { | ||
return; | ||
} | ||
#endif | ||
} | ||
|
||
static void wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, | ||
uint32_t serial, struct wl_surface *surface) { | ||
#if HAVE_TRAY | ||
struct swaybar_seat *seat = data; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this line be outside of the apart from that, nice that you've picked it up! was subscribed on the old PR and have seen this now :) |
||
struct swaybar_config *config = seat->bar->config; | ||
if (!config->tray_hidden && dbusmenu_pointer_leave(data, wl_pointer, serial, | ||
surface)) { | ||
return; | ||
} | ||
#endif | ||
|
||
seat->pointer.current = NULL; | ||
} | ||
|
||
|
@@ -144,6 +164,13 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, | |
struct swaybar_seat *seat = data; | ||
seat->pointer.x = wl_fixed_to_double(surface_x); | ||
seat->pointer.y = wl_fixed_to_double(surface_y); | ||
#if HAVE_TRAY | ||
struct swaybar_config *config = seat->bar->config; | ||
if (!config->tray_hidden && dbusmenu_pointer_motion(data, wl_pointer, time, | ||
surface_x, surface_y)) { | ||
return; | ||
} | ||
#endif | ||
} | ||
|
||
static bool check_bindings(struct swaybar *bar, uint32_t button, | ||
|
@@ -160,14 +187,15 @@ static bool check_bindings(struct swaybar *bar, uint32_t button, | |
} | ||
|
||
static bool process_hotspots(struct swaybar_output *output, | ||
struct swaybar_seat *seat, uint32_t serial, | ||
double x, double y, uint32_t button, uint32_t state) { | ||
bool released = state == WL_POINTER_BUTTON_STATE_RELEASED; | ||
struct swaybar_hotspot *hotspot; | ||
wl_list_for_each(hotspot, &output->hotspots, link) { | ||
if (x >= hotspot->x && y >= hotspot->y | ||
&& x < hotspot->x + hotspot->width | ||
&& y < hotspot->y + hotspot->height) { | ||
if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, x, y, | ||
if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, seat, serial, x, y, | ||
button, released, hotspot->data)) { | ||
return true; | ||
} | ||
|
@@ -180,13 +208,20 @@ static bool process_hotspots(struct swaybar_output *output, | |
static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer, | ||
uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { | ||
struct swaybar_seat *seat = data; | ||
#if HAVE_TRAY | ||
struct swaybar_config *config = seat->bar->config; | ||
if (!config->tray_hidden && dbusmenu_pointer_button(seat, wl_pointer, serial, | ||
time, button, state)) { | ||
return; | ||
} | ||
#endif | ||
struct swaybar_pointer *pointer = &seat->pointer; | ||
struct swaybar_output *output = pointer->current; | ||
if (!sway_assert(output, "button with no active output")) { | ||
return; | ||
} | ||
|
||
if (process_hotspots(output, pointer->x, pointer->y, button, state)) { | ||
if (process_hotspots(output, seat, serial, pointer->x, pointer->y, button, state)) { | ||
return; | ||
} | ||
|
||
|
@@ -240,7 +275,7 @@ static void process_discrete_scroll(struct swaybar_seat *seat, | |
struct swaybar_output *output, struct swaybar_pointer *pointer, | ||
uint32_t axis, wl_fixed_t value) { | ||
uint32_t button = wl_axis_to_button(axis, value); | ||
if (process_hotspots(output, pointer->x, pointer->y, button, WL_POINTER_BUTTON_STATE_PRESSED)) { | ||
if (process_hotspots(output, seat, 0, pointer->x, pointer->y, button, WL_POINTER_BUTTON_STATE_PRESSED)) { | ||
// (Currently hotspots don't do anything on release events, so no need to emit one) | ||
return; | ||
} | ||
|
@@ -297,6 +332,13 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, | |
return; | ||
} | ||
|
||
#if HAVE_TRAY | ||
struct swaybar_config *config = seat->bar->config; | ||
if (!config->tray_hidden && dbusmenu_pointer_axis(data, wl_pointer)) { | ||
return; | ||
} | ||
#endif | ||
|
||
// If there's a while since the last scroll event, | ||
// set 'value' to zero as if to reset the "virtual scroll wheel" | ||
if (seat->axis[axis].discrete_steps == 0 && | ||
|
@@ -313,6 +355,13 @@ static void wl_pointer_frame(void *data, struct wl_pointer *wl_pointer) { | |
struct swaybar_pointer *pointer = &seat->pointer; | ||
struct swaybar_output *output = pointer->current; | ||
|
||
#if HAVE_TRAY | ||
struct swaybar_config *config = seat->bar->config; | ||
if (!config->tray_hidden && dbusmenu_pointer_frame(data, wl_pointer)) { | ||
return; | ||
} | ||
#endif | ||
|
||
if (output == NULL) { | ||
return; | ||
} | ||
|
@@ -420,7 +469,7 @@ static void wl_touch_up(void *data, struct wl_touch *wl_touch, | |
} | ||
if (time - slot->time < 500) { | ||
// Tap, treat it like a pointer click | ||
process_hotspots(slot->output, slot->x, slot->y, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); | ||
process_hotspots(slot->output, seat, serial, slot->x, slot->y, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); | ||
// (Currently hotspots don't do anything on release events, so no need to emit one) | ||
} | ||
slot->output = NULL; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those #includes seems to be a leftover from the rebase and should be dropped from the PR.
More generally, any unrelated change should be entirely dropped from the PR's commit history via rebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can squash later the commits, once the PR is fully ready to be merged. But I'll remove these includes.