Skip to content

Commit

Permalink
Fix some build warnings (#71)
Browse files Browse the repository at this point in the history
* Fix some build warnings

* Decent log message
  • Loading branch information
ryonakano authored Dec 16, 2024
1 parent 06e3765 commit db18e22
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
30 changes: 17 additions & 13 deletions src/Backend/DeviceManagerWayland.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ public class Wacom.Backend.DeviceManagerWayland : DeviceManager {
private Gee.HashMap<GUdev.Device, Device>? devices = null;
private GUdev.Client? client = null;

// Keep in same order as types in Device.vala
const string[] UDEV_IDS = {
"ID_INPUT_MOUSE",
"ID_INPUT_KEYBOARD",
"ID_INPUT_TOUCHPAD",
"ID_INPUT_TABLET",
"ID_INPUT_TOUCHSCREEN",
"ID_INPUT_TABLET_PAD",
private struct UdevIDTable {
string udev_id;
Device.DeviceType device_type;
}
const UdevIDTable[] UDEV_ID_TABLE = {
{ "ID_INPUT_MOUSE", Device.DeviceType.MOUSE },
{ "ID_INPUT_KEYBOARD", Device.DeviceType.KEYBOARD },
{ "ID_INPUT_TOUCHPAD", Device.DeviceType.TOUCHPAD },
{ "ID_INPUT_TABLET", Device.DeviceType.TABLET },
{ "ID_INPUT_TOUCHSCREEN", Device.DeviceType.TOUCHSCREEN },
{ "ID_INPUT_TABLET_PAD", Device.DeviceType.PAD },
};

public DeviceManagerWayland () {
Expand Down Expand Up @@ -95,9 +98,9 @@ public class Wacom.Backend.DeviceManagerWayland : DeviceManager {

private static Device.DeviceType get_udev_device_type (GUdev.Device device) {
Device.DeviceType type = 0;
for (int i = 0; i < UDEV_IDS.length; i++) {
if (device.get_property_as_boolean (UDEV_IDS[i])) {
type |= (1 << i);
for (int i = 0; i < UDEV_ID_TABLE.length; i++) {
if (device.get_property_as_boolean (UDEV_ID_TABLE[i].udev_id)) {
type |= UDEV_ID_TABLE[i].device_type;
}
}

Expand Down Expand Up @@ -145,11 +148,12 @@ public class Wacom.Backend.DeviceManagerWayland : DeviceManager {
}

public override Device? lookup_gdk_device (Gdk.Device device) {
if (!(device is Gdk.Wayland.Device)) {
Gdk.Wayland.Device? wayland_device = (device as Gdk.Wayland.Device);
if (wayland_device == null) {
return null;
}

var node_path = (device as Gdk.Wayland.Device).get_node_path ();
var node_path = wayland_device.get_node_path ();
if (node_path == null) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/WacomToolMap.vala
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public class Wacom.Backend.WacomToolMap : GLib.Object {
}
}

public Gee.ArrayList<WacomTool> list_tools (Backend.Device device) {
public Gee.ArrayList<WacomTool> list_tools (Backend.Device device) throws WacomException {
var styli = new Gee.ArrayList<WacomTool> ();

var key = "%s:%s".printf (device.vendor_id, device.product_id);
Expand Down
9 changes: 8 additions & 1 deletion src/MainPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ public class Wacom.MainPage : Switchboard.SettingsPage {
return;
}

var tools = tool_map.list_tools (d);
Gee.ArrayList<Backend.WacomTool> tools;
try {
tools = tool_map.list_tools (d);
} catch (WacomException e) {
warning ("Failed to list tools: %s", e.message);
return;
}

if (tools.size > 0) {
stylus_view.set_device (tools[0]);
stylus_stack.visible_child = stylus_view;
Expand Down

0 comments on commit db18e22

Please sign in to comment.