Changeset 4b0895a574f8fbaaf2caa4a11fc9c6b4fe504c09
- Timestamp:
- 03/19/09 15:30:45 (3 years ago)
- Author:
- Lincoln de Sousa <lincoln@…>
- Children:
- 014842639ffec88ea516166f1a40e612591a1d63
- Parents:
- c87d938e304a9095234a1e40819b25d5fd433bef
- git-author:
- Aleksandar Krsteski <alekrsteski@…> (03/18/09 21:03:28)
- git-committer:
- Lincoln de Sousa <lincoln@…> (03/19/09 15:30:45)
- Message:
-
Try a better fix for losefocus race condition.
Try to fix the race condition between window losefocus event and
keybinding event from globalhotkeys in a better way, by comparing event
times of the keybinding event and losefocus event. To achive this add a
python binding for keybinder_get_current_event_time funcion and use it
to compare keybinding timestamp with losefocus timestamp.
- Location:
- src
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r08770e8
|
r4b0895a5
|
|
| 197 | 197 | } |
| 198 | 198 | |
| | 199 | static PyObject * |
| | 200 | GlobalHotkey_get_current_event_time (GlobalHotkey *self) |
| | 201 | { |
| | 202 | guint32 ret = keybinder_get_current_event_time (); |
| | 203 | return Py_BuildValue ("i", ret); |
| | 204 | } |
| | 205 | |
| 199 | 206 | static struct PyMemberDef GlobalHotkey_members[] = { |
| 200 | 207 | {"binded", T_OBJECT_EX, offsetof (GlobalHotkey, binded), 0, |
| … |
… |
|
| 216 | 223 | {"bind", (PyCFunction) GlobalHotkey_bind, |
| 217 | 224 | METH_VARARGS, "Bind a key to a callable object"}, |
| | 225 | |
| | 226 | {"get_current_event_time", (PyCFunction) GlobalHotkey_get_current_event_time, |
| | 227 | METH_NOARGS, "Returns the timestamp of the current event"}, |
| 218 | 228 | |
| 219 | 229 | {NULL} /* sentinel */ |
-
|
rc87d938
|
r4b0895a5
|
|
| 523 | 523 | self.fullscreen = False |
| 524 | 524 | |
| | 525 | # holds the timestamp of the losefocus event |
| | 526 | self.losefocus_time = 0 |
| | 527 | |
| 525 | 528 | # double click stuff |
| 526 | 529 | def double_click(hbox, event): |
| … |
… |
|
| 605 | 608 | visible = window.get_property('visible') |
| 606 | 609 | if value and visible and not self.showing_context_menu: |
| | 610 | self.losefocus_time = gtk.gdk.x11_get_server_time(self.window.window) |
| 607 | 611 | self.hide() |
| 608 | | |
| 609 | | # There is a race condition between the focus-out-event and |
| 610 | | # the global keybind that calls the self.show_hide method. I |
| 611 | | # didn't investigate but this callback is allways called |
| 612 | | # before the X keyboard event. So, to fix it temporarely, I |
| 613 | | # did the following hammer: |
| 614 | | def hack(): |
| 615 | | sleep(0.1) |
| 616 | | self.client.notify(GKEY('show_hide')) |
| 617 | | self.hotkeys.unbind_all() |
| 618 | | start_new_thread(hack, ()) |
| 619 | 612 | |
| 620 | 613 | def show_menu(self, *args): |
| … |
… |
|
| 670 | 663 | """Toggles the main window visibility |
| 671 | 664 | """ |
| | 665 | event_time = self.hotkeys.get_current_event_time() |
| | 666 | |
| | 667 | if self.losefocus_time and \ |
| | 668 | self.losefocus_time >= event_time and \ |
| | 669 | (self.losefocus_time - event_time) < 10: |
| | 670 | self.losefocus_time = 0 |
| | 671 | return |
| | 672 | |
| 672 | 673 | if not self.window.get_property('visible'): |
| 673 | 674 | self.show() |