Skip to content

Commit

Permalink
#765: constify so we can add debug logging with meaningful information
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@13718 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 14, 2016
1 parent 01545c4 commit a2d7f8b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 29 deletions.
30 changes: 4 additions & 26 deletions src/tests/xpra/test_apps/test_window_initiatemoveresize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,10 @@

import gtk

MOVERESIZE_SIZE_TOPLEFT = 0
MOVERESIZE_SIZE_TOP = 1
MOVERESIZE_SIZE_TOPRIGHT = 2
MOVERESIZE_SIZE_RIGHT = 3
MOVERESIZE_SIZE_BOTTOMRIGHT = 4
MOVERESIZE_SIZE_BOTTOM = 5
MOVERESIZE_SIZE_BOTTOMLEFT = 6
MOVERESIZE_SIZE_LEFT = 7
MOVERESIZE_MOVE = 8
MOVERESIZE_SIZE_KEYBOARD = 9
MOVERESIZE_MOVE_KEYBOARD = 10
MOVERESIZE_CANCEL = 11
MOVERESIZE_DIRECTION_STRING = {
MOVERESIZE_SIZE_TOPLEFT : "SIZE_TOPLEFT",
MOVERESIZE_SIZE_TOP : "SIZE_TOP",
MOVERESIZE_SIZE_TOPRIGHT : "SIZE_TOPRIGHT",
MOVERESIZE_SIZE_RIGHT : "SIZE_RIGHT",
MOVERESIZE_SIZE_BOTTOMRIGHT : "SIZE_BOTTOMRIGHT",
MOVERESIZE_SIZE_BOTTOM : "SIZE_BOTTOM",
MOVERESIZE_SIZE_BOTTOMLEFT : "SIZE_BOTTOMLEFT",
MOVERESIZE_SIZE_LEFT : "SIZE_LEFT",
MOVERESIZE_MOVE : "MOVE",
MOVERESIZE_SIZE_KEYBOARD : "SIZE_KEYBOARD",
MOVERESIZE_MOVE_KEYBOARD : "MOVE_KEYBOARD",
MOVERESIZE_CANCEL : "CANCEL",
}
from xpra.util import MOVERESIZE_DIRECTION_STRING, MOVERESIZE_SIZE_TOPLEFT, MOVERESIZE_SIZE_TOP, \
MOVERESIZE_SIZE_TOPRIGHT, MOVERESIZE_SIZE_RIGHT, MOVERESIZE_SIZE_BOTTOMRIGHT, \
MOVERESIZE_SIZE_BOTTOM, MOVERESIZE_SIZE_BOTTOMLEFT, MOVERESIZE_SIZE_LEFT, \
MOVERESIZE_MOVE, MOVERESIZE_CANCEL

width = 400
height = 200
Expand Down
5 changes: 2 additions & 3 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


from xpra.os_util import memoryview_to_bytes, bytestostr
from xpra.util import AdHocStruct, typedict, envint, WORKSPACE_UNSET, WORKSPACE_ALL, WORKSPACE_NAMES
from xpra.util import AdHocStruct, typedict, envint, WORKSPACE_UNSET, WORKSPACE_ALL, WORKSPACE_NAMES, MOVERESIZE_DIRECTION_STRING, SOURCE_INDICATION_STRING
from xpra.gtk_common.gobject_compat import import_gtk, import_gdk, import_cairo, import_pixbufloader, get_xid
from xpra.gtk_common.gobject_util import no_arg_signal
from xpra.gtk_common.gtk_util import get_pixbuf_from_data, get_default_root_window, is_realized, WINDOW_POPUP, WINDOW_TOPLEVEL, GRAB_STATUS_STRING, GRAB_SUCCESS
Expand Down Expand Up @@ -904,9 +904,8 @@ def call_action(self, action_type, action, state, pdata):
except Exception as e:
log.error("Error: failed to send %s menu rpc request for %s", action_type, action, exc_info=True)


def initiate_moveresize(self, x_root, y_root, direction, button, source_indication):
statelog("initiate_moveresize%s", (x_root, y_root, direction, button, source_indication))
statelog("initiate_moveresize%s", (x_root, y_root, MOVERESIZE_DIRECTION_STRING.get(direction, direction), button, SOURCE_INDICATION_STRING.get(source_indication, source_indication)))
assert HAS_X11_BINDINGS, "cannot handle initiate-moveresize without X11 bindings"
event_mask = SubstructureNotifyMask | SubstructureRedirectMask
root = self.get_window().get_screen().get_root_window()
Expand Down
37 changes: 37 additions & 0 deletions src/xpra/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,43 @@
"role", "opacity", "xid", "group-leader")


#initiate-moveresize X11 constants
MOVERESIZE_SIZE_TOPLEFT = 0
MOVERESIZE_SIZE_TOP = 1
MOVERESIZE_SIZE_TOPRIGHT = 2
MOVERESIZE_SIZE_RIGHT = 3
MOVERESIZE_SIZE_BOTTOMRIGHT = 4
MOVERESIZE_SIZE_BOTTOM = 5
MOVERESIZE_SIZE_BOTTOMLEFT = 6
MOVERESIZE_SIZE_LEFT = 7
MOVERESIZE_MOVE = 8
MOVERESIZE_SIZE_KEYBOARD = 9
MOVERESIZE_MOVE_KEYBOARD = 10
MOVERESIZE_CANCEL = 11
MOVERESIZE_DIRECTION_STRING = {
MOVERESIZE_SIZE_TOPLEFT : "SIZE_TOPLEFT",
MOVERESIZE_SIZE_TOP : "SIZE_TOP",
MOVERESIZE_SIZE_TOPRIGHT : "SIZE_TOPRIGHT",
MOVERESIZE_SIZE_RIGHT : "SIZE_RIGHT",
MOVERESIZE_SIZE_BOTTOMRIGHT : "SIZE_BOTTOMRIGHT",
MOVERESIZE_SIZE_BOTTOM : "SIZE_BOTTOM",
MOVERESIZE_SIZE_BOTTOMLEFT : "SIZE_BOTTOMLEFT",
MOVERESIZE_SIZE_LEFT : "SIZE_LEFT",
MOVERESIZE_MOVE : "MOVE",
MOVERESIZE_SIZE_KEYBOARD : "SIZE_KEYBOARD",
MOVERESIZE_MOVE_KEYBOARD : "MOVE_KEYBOARD",
MOVERESIZE_CANCEL : "CANCEL",
}
SOURCE_INDICATION_UNSET = 0
SOURCE_INDICATION_NORMAL = 1
SOURCE_INDICATION_PAGER = 2
SOURCE_INDICATION_STRING = {
SOURCE_INDICATION_UNSET : "UNSET",
SOURCE_INDICATION_NORMAL : "NORMAL",
SOURCE_INDICATION_PAGER : "PAGER",
}


#convenience method based on the strings above:
def disconnect_is_an_error(reason):
return reason.find("error")>=0 or (reason.find("timeout")>=0 and reason!=IDLE_TIMEOUT)
Expand Down

0 comments on commit a2d7f8b

Please sign in to comment.