quick commit
This commit is contained in:
@@ -561,7 +561,9 @@ void TrayService::request_menu_layout(const std::string &id,
|
||||
&on_menu_layout_finished, data);
|
||||
}
|
||||
|
||||
bool TrayService::activate_menu_item(const std::string &id, int itemId) {
|
||||
bool TrayService::activate_menu_item(const std::string &id, int itemId,
|
||||
int32_t x, int32_t y, uint32_t button,
|
||||
uint32_t timestampMs) {
|
||||
auto it = items.find(id);
|
||||
if (it == items.end() || !connection) {
|
||||
return false;
|
||||
@@ -572,21 +574,36 @@ bool TrayService::activate_menu_item(const std::string &id, int itemId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Some tray items update state lazily and require AboutToShow(itemId)
|
||||
// before handling a click.
|
||||
call_about_to_show(connection, item.publicData.busName,
|
||||
item.publicData.menuPath, itemId);
|
||||
const guint32 nowMs = static_cast<guint32>(g_get_real_time() / 1000);
|
||||
const guint32 ts = timestampMs ? timestampMs : nowMs;
|
||||
|
||||
std::cerr << "[TrayService] MenuEvent id=" << id << " item=" << itemId
|
||||
<< " x=" << x << " y=" << y << " button=" << button
|
||||
<< " tsMs=" << ts << std::endl;
|
||||
|
||||
// dbusmenu Event signature: (i s v u)
|
||||
// For "clicked", the payload is typically an a{sv} dictionary.
|
||||
// IMPORTANT: the 'v' argument must be a variant container, so we wrap.
|
||||
// Some handlers (e.g., media players) look for both "timestamp" and
|
||||
// "time" keys; send both alongside coords/button when available.
|
||||
GVariantBuilder dict;
|
||||
g_variant_builder_init(&dict, G_VARIANT_TYPE("a{sv}"));
|
||||
g_variant_builder_add(&dict, "{sv}", "timestamp",
|
||||
g_variant_new_uint32(ts));
|
||||
g_variant_builder_add(&dict, "{sv}", "time", g_variant_new_uint32(ts));
|
||||
|
||||
if (x != -1 && y != -1) {
|
||||
g_variant_builder_add(&dict, "{sv}", "x", g_variant_new_int32(x));
|
||||
g_variant_builder_add(&dict, "{sv}", "y", g_variant_new_int32(y));
|
||||
}
|
||||
if (button > 0) {
|
||||
g_variant_builder_add(
|
||||
&dict, "{sv}", "button",
|
||||
g_variant_new_int32(static_cast<int32_t>(button)));
|
||||
}
|
||||
|
||||
GVariant *payloadDict = g_variant_builder_end(&dict);
|
||||
GVariant *payload = g_variant_new_variant(payloadDict);
|
||||
GVariant *params = g_variant_new(
|
||||
"(isvu)", itemId, "clicked", payload,
|
||||
static_cast<guint32>(g_get_monotonic_time() / 1000));
|
||||
GVariant *params = g_variant_new("(isvu)", itemId, "clicked",
|
||||
payload, ts);
|
||||
|
||||
auto data = new SimpleCallData();
|
||||
data->debugLabel = "MenuEvent(" + id + "," + std::to_string(itemId) + ")";
|
||||
|
||||
Reference in New Issue
Block a user