Bubble up the width/height from the protocol to the dbus interface
Fixes #135
This commit is contained in:
parent
d3156110b7
commit
5d53ec8005
10
tuhi/base.py
10
tuhi/base.py
|
@ -79,6 +79,12 @@ class TuhiDevice(GObject.Object):
|
|||
|
||||
self._tuhi_dbus_device = None
|
||||
|
||||
@GObject.Property
|
||||
def dimensions(self):
|
||||
if self._wacom_device is None:
|
||||
return 0, 0
|
||||
return self._wacom_device.dimensions
|
||||
|
||||
@GObject.Property
|
||||
def mode(self):
|
||||
return self._mode
|
||||
|
@ -174,6 +180,7 @@ class TuhiDevice(GObject.Object):
|
|||
self._wacom_device.connect('notify::uuid', self._on_uuid_updated, bluez_device)
|
||||
self._wacom_device.connect('battery-status', self._on_battery_status, bluez_device)
|
||||
self._wacom_device.connect('notify::sync-state', self._on_sync_state)
|
||||
self._wacom_device.connect('notify::dimensions', self._on_dimensions)
|
||||
|
||||
if mode == DeviceMode.REGISTER:
|
||||
self._wacom_device.start_register()
|
||||
|
@ -188,6 +195,9 @@ class TuhiDevice(GObject.Object):
|
|||
except KeyError:
|
||||
pass
|
||||
|
||||
def _on_dimensions(self, device, pspec):
|
||||
self.notify('dimensions')
|
||||
|
||||
def _on_sync_state(self, device, pspec):
|
||||
self._sync_state = device.sync_state
|
||||
self.notify('sync-state')
|
||||
|
|
|
@ -171,7 +171,7 @@ class TuhiDBusDevice(_TuhiDBus):
|
|||
|
||||
self.bluez_device_objpath = device.bluez_device.objpath
|
||||
self.name = device.name
|
||||
self.width, self.height = 0, 0
|
||||
self.width, self.height = device.dimensions
|
||||
self.drawings = {}
|
||||
self.registered = device.registered
|
||||
self._listening = False
|
||||
|
@ -187,6 +187,7 @@ class TuhiDBusDevice(_TuhiDBus):
|
|||
device.connect('notify::battery-state', self._on_battery_state)
|
||||
device.connect('device-error', self._on_device_error)
|
||||
device.connect('notify::sync-state', self._on_sync_state)
|
||||
device.connect('notify::dimensions', self._on_dimensions)
|
||||
|
||||
@GObject.Property
|
||||
def listening(self):
|
||||
|
@ -335,6 +336,12 @@ class TuhiDBusDevice(_TuhiDBus):
|
|||
self._stop_listening(self.connection, self._listening_client[0],
|
||||
-exception.errno)
|
||||
|
||||
def _on_dimensions(self, device, pspec):
|
||||
self.width, self.height = device.dimensions
|
||||
w = GLib.Variant.new_uint32(self.width)
|
||||
h = GLib.Variant.new_uint32(self.height)
|
||||
self.properties_changed({'Dimensions': GLib.Variant.new_tuple(w, h)})
|
||||
|
||||
def _on_sync_state(self, device, pspec):
|
||||
if self._listening_client is None:
|
||||
return
|
||||
|
|
|
@ -655,6 +655,10 @@ class WacomProtocolBase(WacomProtocolLowLevelComm):
|
|||
|
||||
child = cls
|
||||
|
||||
@GObject.property
|
||||
def dimensions(self):
|
||||
return (self.width, self.height)
|
||||
|
||||
def _on_pen_data_changed(self, name, value):
|
||||
logger.debug(binascii.hexlify(bytes(value)))
|
||||
|
||||
|
@ -1050,6 +1054,7 @@ class WacomProtocolSlate(WacomProtocolSpark):
|
|||
# starting live mode
|
||||
self.width = self.get_dimensions('width')
|
||||
self.height = self.get_dimensions('height')
|
||||
self.notify('dimensions')
|
||||
self.x_max = self.width - 1000
|
||||
self.y_max = self.height - 500
|
||||
|
||||
|
@ -1082,11 +1087,14 @@ class WacomProtocolSlate(WacomProtocolSpark):
|
|||
self.ec_command()
|
||||
name = self.get_name()
|
||||
logger.info(f'device name is {name}')
|
||||
|
||||
w = self.get_dimensions('width')
|
||||
h = self.get_dimensions('height')
|
||||
logger.debug(f'dimensions: {w}x{h}')
|
||||
if self.width != w or self.height != h:
|
||||
logger.error(f'incompatible dimensions: {w}x{h}')
|
||||
self.notify('dimensions')
|
||||
|
||||
fw_high = self.get_firmware_version(0)
|
||||
fw_low = self.get_firmware_version(1)
|
||||
logger.info(f'firmware is {fw_high}-{fw_low}')
|
||||
|
@ -1109,6 +1117,7 @@ class WacomProtocolSlate(WacomProtocolSpark):
|
|||
self.emit('battery-status', battery, charging)
|
||||
self.width = w = self.get_dimensions('width')
|
||||
self.height = h = self.get_dimensions('height')
|
||||
self.notify('dimensions')
|
||||
logger.debug(f'dimensions: {w}x{h}')
|
||||
|
||||
fw_high = self.get_firmware_version(0)
|
||||
|
@ -1311,6 +1320,14 @@ class WacomDevice(GObject.Object):
|
|||
'battery-status',
|
||||
lambda prot, percent, is_charging, self: self.emit('battery-status', percent, is_charging),
|
||||
self)
|
||||
self._wacom_protocol.connect('notify::dimensions', self._on_dimensions)
|
||||
|
||||
@GObject.Property
|
||||
def dimensions(self):
|
||||
return self._wacom_protocol.dimensions
|
||||
|
||||
def _on_dimensions(self, protocol, pspec):
|
||||
self.notify('dimensions')
|
||||
|
||||
@GObject.Property
|
||||
def uuid(self):
|
||||
|
|
Loading…
Reference in New Issue