MessageTray: pass keyboard events to tray icons
Synthetize XKeyEvents for clicks emulated by StButton using Return or Space. https://bugzilla.gnome.org/show_bug.cgi?id=687425
This commit is contained in:
parent
42c1285ead
commit
59ecd610b1
@ -637,11 +637,7 @@ const KeyboardSource = new Lang.Class({
|
|||||||
this.keepTrayOnSummaryClick = true;
|
this.keepTrayOnSummaryClick = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSummaryClick: function() {
|
handleSummaryClick: function(button) {
|
||||||
let event = Clutter.get_current_event();
|
|
||||||
if (event.type() != Clutter.EventType.BUTTON_RELEASE)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
this.open();
|
this.open();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -1831,7 +1831,7 @@ const MessageTray = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onSummaryItemClicked: function(summaryItem, button) {
|
_onSummaryItemClicked: function(summaryItem, button) {
|
||||||
if (summaryItem.source.handleSummaryClick()) {
|
if (summaryItem.source.handleSummaryClick(button)) {
|
||||||
if (summaryItem.source.keepTrayOnSummaryClick)
|
if (summaryItem.source.keepTrayOnSummaryClick)
|
||||||
this._setClickedSummaryItem(null);
|
this._setClickedSummaryItem(null);
|
||||||
else
|
else
|
||||||
|
@ -565,19 +565,17 @@ const Source = new Lang.Class({
|
|||||||
this.notify(notification);
|
this.notify(notification);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSummaryClick: function() {
|
handleSummaryClick: function(button) {
|
||||||
if (!this.trayIcon)
|
if (!this.trayIcon)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let event = Clutter.get_current_event();
|
let event = Clutter.get_current_event();
|
||||||
if (event.type() != Clutter.EventType.BUTTON_RELEASE)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Left clicks are passed through only where there aren't unacknowledged
|
// Left clicks are passed through only where there aren't unacknowledged
|
||||||
// notifications, so it possible to open them in summary mode; right
|
// notifications, so it possible to open them in summary mode; right
|
||||||
// clicks are always forwarded, as the right click menu is not useful for
|
// clicks are always forwarded, as the right click menu is not useful for
|
||||||
// tray icons
|
// tray icons
|
||||||
if (event.get_button() == 1 &&
|
if (button == 1 &&
|
||||||
this.notifications.length > 0)
|
this.notifications.length > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@ void
|
|||||||
shell_tray_icon_click (ShellTrayIcon *icon,
|
shell_tray_icon_click (ShellTrayIcon *icon,
|
||||||
ClutterEvent *event)
|
ClutterEvent *event)
|
||||||
{
|
{
|
||||||
|
XKeyEvent xkevent;
|
||||||
XButtonEvent xbevent;
|
XButtonEvent xbevent;
|
||||||
XCrossingEvent xcevent;
|
XCrossingEvent xcevent;
|
||||||
GdkWindow *remote_window;
|
GdkWindow *remote_window;
|
||||||
@ -187,8 +188,10 @@ shell_tray_icon_click (ShellTrayIcon *icon,
|
|||||||
int x_root, y_root;
|
int x_root, y_root;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
Window xwindow, xrootwindow;
|
Window xwindow, xrootwindow;
|
||||||
|
ClutterEventType event_type = clutter_event_type (event);
|
||||||
|
|
||||||
g_return_if_fail (clutter_event_type (event) == CLUTTER_BUTTON_RELEASE);
|
g_return_if_fail (event_type == CLUTTER_BUTTON_RELEASE ||
|
||||||
|
event_type == CLUTTER_KEY_RELEASE);
|
||||||
|
|
||||||
gdk_error_trap_push ();
|
gdk_error_trap_push ();
|
||||||
|
|
||||||
@ -215,7 +218,8 @@ shell_tray_icon_click (ShellTrayIcon *icon,
|
|||||||
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xcevent);
|
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xcevent);
|
||||||
|
|
||||||
/* Now do the click */
|
/* Now do the click */
|
||||||
xbevent.type = ButtonPress;
|
if (event_type == CLUTTER_BUTTON_RELEASE)
|
||||||
|
{
|
||||||
xbevent.window = xwindow;
|
xbevent.window = xwindow;
|
||||||
xbevent.root = xrootwindow;
|
xbevent.root = xrootwindow;
|
||||||
xbevent.subwindow = None;
|
xbevent.subwindow = None;
|
||||||
@ -225,12 +229,33 @@ shell_tray_icon_click (ShellTrayIcon *icon,
|
|||||||
xbevent.x_root = xcevent.x_root;
|
xbevent.x_root = xcevent.x_root;
|
||||||
xbevent.y_root = xcevent.y_root;
|
xbevent.y_root = xcevent.y_root;
|
||||||
xbevent.state = clutter_event_get_state (event);
|
xbevent.state = clutter_event_get_state (event);
|
||||||
xbevent.button = clutter_event_get_button (event);
|
|
||||||
xbevent.same_screen = True;
|
xbevent.same_screen = True;
|
||||||
|
xbevent.type = ButtonPress;
|
||||||
|
xbevent.button = clutter_event_get_button (event);
|
||||||
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
|
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
|
||||||
|
|
||||||
xbevent.type = ButtonRelease;
|
xbevent.type = ButtonRelease;
|
||||||
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
|
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xkevent.window = xwindow;
|
||||||
|
xkevent.root = xrootwindow;
|
||||||
|
xkevent.subwindow = None;
|
||||||
|
xkevent.time = xcevent.time;
|
||||||
|
xkevent.x = xcevent.x;
|
||||||
|
xkevent.y = xcevent.y;
|
||||||
|
xkevent.x_root = xcevent.x_root;
|
||||||
|
xkevent.y_root = xcevent.y_root;
|
||||||
|
xkevent.state = clutter_event_get_state (event);
|
||||||
|
xkevent.same_screen = True;
|
||||||
|
xkevent.type = KeyPress;
|
||||||
|
xkevent.keycode = clutter_event_get_key_code (event);
|
||||||
|
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xkevent);
|
||||||
|
|
||||||
|
xkevent.type = KeyRelease;
|
||||||
|
XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xkevent);
|
||||||
|
}
|
||||||
|
|
||||||
/* And move the pointer back out */
|
/* And move the pointer back out */
|
||||||
xcevent.type = LeaveNotify;
|
xcevent.type = LeaveNotify;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user