[caribou: 13/23] connect to both notify["has-toplevel-focus"] and set_focus
- From: Eitan Isaacson <eitani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [caribou: 13/23] connect to both notify["has-toplevel-focus"] and set_focus
- Date: Fri, 12 Aug 2011 07:48:15 +0000 (UTC)
commit de6517b8d1bf16ec9ee87aacc96adf2d8c836870
Author: Dan Winship <danw gnome org>
Date: Fri Aug 5 12:28:34 2011 -0400
connect to both notify["has-toplevel-focus"] and set_focus
the former tells us when a new window has been focused, the latter
tells us when the focus changes from one widget to another within a
window.
modules/gtk3/caribou-gtk-module.vala | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala
index 46a76ce..4441f97 100644
--- a/modules/gtk3/caribou-gtk-module.vala
+++ b/modules/gtk3/caribou-gtk-module.vala
@@ -38,19 +38,26 @@ namespace Caribou {
toplevels = Gtk.Window.list_toplevels ();
foreach (Gtk.Window window in toplevels) {
if (!windows.lookup (window)) {
- window.notify["has-toplevel-focus"].connect (has_top_level_focus_changed);
+ window.notify["has-toplevel-focus"].connect (toplevel_focus_changed);
+ window.set_focus.connect (window_focus_changed);
window.destroy.connect (() => { windows.remove (window); });
windows.insert (window, true);
}
}
}
- private void has_top_level_focus_changed (Object obj, ParamSpec prop) {
+ private void toplevel_focus_changed (Object obj, ParamSpec prop) {
Gtk.Window window = (Gtk.Window) obj;
- if (!window.has_toplevel_focus)
- return;
+ if (window.has_toplevel_focus)
+ do_focus_change (window.get_focus ());
+ }
+
+ private void window_focus_changed (Gtk.Window window,
+ Gtk.Widget? widget) {
+ do_focus_change (widget);
+ }
- Gtk.Widget? widget = window.get_focus ();
+ private void do_focus_change (Gtk.Widget? widget) {
uint32 timestamp = Gtk.get_current_event_time ();
if (widget != null && (widget is Gtk.Entry || widget is Gtk.TextView) && widget is Gtk.Editable) {
Gdk.Window current_window = widget.get_window ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]