Skip to content

Commit

Permalink
#640 move the mouse state workaround to the client so it becomes comm…
Browse files Browse the repository at this point in the history
…on to all windows, re-use it to avoid sending duplicate events with gtk3 + win32...

git-svn-id: https://xpra.org/svn/Xpra/trunk@9073 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 20, 2015
1 parent 26c2ce0 commit fa04c40
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
13 changes: 1 addition & 12 deletions src/xpra/client/client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(self, client, group_leader, wid, x, y, w, h, metadata, override_red
self._iconified = False
self.border = border
self.max_window_size = max_window_size
self.button_state = {}

self.init_window(metadata)
self.setup_window()
Expand Down Expand Up @@ -490,17 +489,7 @@ def _button_action(self, button, event, depressed):
pointer, modifiers, buttons = self._pointer_modifiers(event)
wid = self.get_mouse_event_wid()
mouselog("_button_action(%s, %s, %s) wid=%s / focus=%s, pointer=%s, modifiers=%s, buttons=%s", button, event, depressed, self._id, self._client._focused, pointer, modifiers, buttons)
def send_button(pressed):
self._client.send_positional(["button-action", wid,
button, pressed,
pointer, modifiers, buttons])
pressed_state = self.button_state.get(button, False)
if pressed_state is False and depressed is False:
mouselog("button action: simulating a missing mouse-down event for window %s before sending the mouse-up event", wid)
#(needed for some dialogs on win32):
send_button(True)
self.button_state[button] = depressed
send_button(depressed)
self._client.send_button(wid, button, depressed, pointer, modifiers, buttons)

def do_button_press_event(self, event):
self._button_action(event.button, event, True)
Expand Down
23 changes: 23 additions & 0 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
grablog = Logger("client", "grab")
iconlog = Logger("client", "icon")
screenlog = Logger("client", "screen")
mouselog = Logger("mouse")

from xpra import __version__ as XPRA_VERSION
from xpra.gtk_common.gobject_util import no_arg_signal
Expand Down Expand Up @@ -58,6 +59,10 @@
UNGRAB_KEY = os.environ.get("XPRA_UNGRAB_KEY", "Escape")


PYTHON3 = sys.version_info[0] == 3
WIN32 = sys.platform.startswith("win")


"""
Utility superclass for client classes which have a UI.
See gtk_client_base and its subclasses.
Expand Down Expand Up @@ -224,6 +229,7 @@ def __init__(self):
self._window_with_grab = None
self._last_screen_settings = None
self._suspended_at = 0
self._button_state = {}

self.init_aliases()

Expand Down Expand Up @@ -745,6 +751,23 @@ def init_opengl(self, enable_opengl):
self.opengl_props = {"info" : "not supported"}


def send_button(self, wid, button, pressed, pointer, modifiers, buttons):
def send_button(state):
self.send_positional(["button-action", wid,
button, state,
pointer, modifiers, buttons])
pressed_state = self._button_state.get(button, False)
if PYTHON3 and WIN32 and pressed_state==pressed:
mouselog("button action: unchanged state, ignoring event")
return
if pressed_state is False and pressed is False:
mouselog("button action: simulating a missing mouse-down event for window %s before sending the mouse-up event", wid)
#(needed for some dialogs on win32):
send_button(True)
self._button_state[button] = pressed
send_button(pressed)


def get_keymap_properties(self):
props = self.keyboard_helper.get_keymap_properties()
props["modifiers"] = self.get_current_modifiers()
Expand Down

0 comments on commit fa04c40

Please sign in to comment.