=?windows-1252?Q?Bug_579643_=96_modifier_keys_not_reset_when_focus_ch?= =?windows-1252?Q?ange?=



if you alt tab with a modifier key pressed at the same time this modifier key
stays as pressed even if released when meld had not the focus.

Steps to reproduce:
- open some file diff
- press shift (see the linkmap buttons change)
- keeping shift pressed, press alt-tab to switch to another already runnig app
- release shift
- refocus meld with alt-tab or mouse click or window list
- see the linkmap buttons still in shift mode

The debian bug report
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470781
is about the ALT modifier for unsynchronized scrolling
(which is SHIFT for me, where does that difference come
from ?)

The attached patch fixes that, please review.

I'm especially interested in the comment about circular reference,
is that part OK, any idea to do this in a cleaner way ? (I think this
is easy and clean if  python GC handles it properly...)

-- 
Vincent Legoll
Index: filediff.py
===================================================================
--- filediff.py	(revision 1351)
+++ filediff.py	(working copy)
@@ -130,6 +130,10 @@
         gnomeglade.connect_signal_handlers(self)
         self.findbar = self.findbar.get_data("pyobject")
 
+    def on_focus_change(self):
+        self.keymask = 0
+        self._update_linkmap_buttons()
+
     def on_container_switch_in_event(self, ui):
         melddoc.MeldDoc.on_container_switch_in_event(self, ui)
         if self.textview_focussed:
Index: meldapp.py
===================================================================
--- meldapp.py	(revision 1351)
+++ meldapp.py	(working copy)
@@ -579,7 +579,17 @@
         self.widget.set_default_size(self.prefs.window_size_x, self.prefs.window_size_y)
         self.ui.ensure_update()
         self.widget.show()
+        self.widget.connect('focus_in_event', self.on_focus_change)
+        self.widget.connect('focus_out_event', self.on_focus_change)
 
+    def on_focus_change(self, widget, event, callback_data = None):
+        for idx in range(self.notebook.get_n_pages()):
+            w = self.notebook.get_nth_page(idx)
+            if hasattr(w.melddoc, 'on_focus_change'):
+                w.melddoc.on_focus_change()
+        # Let the rest of the stack knows about this event
+        return False
+
     def on_widget_drag_data_received(self, wid, context, x, y, selection_data, info, time):
         if len(selection_data.get_uris()) != 0:
             paths = [gnomevfs.get_local_path_from_uri(u) for u in selection_data.get_uris()]
@@ -820,6 +830,7 @@
 
     def _append_page(self, page, icon):
         nbl = NotebookLabel(icon, "", lambda b: self.try_remove_page(page))
+        page.widget.melddoc = page # FIXME: isn't that a leak by circular reference ?
         self.notebook.append_page( page.widget, nbl)
         self.notebook.set_current_page( self.notebook.page_num(page.widget) )
         self.scheduler.add_scheduler(page.scheduler)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]