mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
config: add tablet area configuration
This commit is contained in:
parent
dd91cd89ae
commit
f0abd9304f
5 changed files with 32 additions and 2 deletions
|
|
@ -394,14 +394,22 @@
|
|||
</mouse>
|
||||
|
||||
<!--
|
||||
The active tablet area can be specified by setting the top/left
|
||||
coordinate (in mm) and/or width/height (in mm). If width or height
|
||||
are omitted or default (0.0), width/height will be set to the
|
||||
remaining width/height seen from top/left.
|
||||
|
||||
The tablet orientation can be changed in 90 degree steps, thus
|
||||
rotation can be set to [0|90|180|270].
|
||||
rotation can be set to [0|90|180|270]. Rotation will be applied
|
||||
after applying tablet area transformation.
|
||||
|
||||
Tablet buttons emulate regular mouse buttons. The tablet *button* can
|
||||
be set to any of [tip|stylus|stylus2|stylus3]. Valid *to* mouse buttons
|
||||
are [left|right|middle].
|
||||
-->
|
||||
<tablet rotate="0">
|
||||
<!-- Active area dimensions are in mm -->
|
||||
<area top="0.0" left="0.0" width="0.0" height="0.0">
|
||||
<map button="tip" to="left" />
|
||||
<map button="stylus" to="right" />
|
||||
<map button="stylus2" to="middle" />
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ struct rcxml {
|
|||
|
||||
/* graphics tablet */
|
||||
struct tablet_config {
|
||||
struct wlr_fbox box;
|
||||
enum rotation rotation;
|
||||
uint16_t button_map_count;
|
||||
struct button_map_entry button_map[BUTTON_MAP_MAX];
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ struct button_map_entry {
|
|||
uint32_t to;
|
||||
};
|
||||
|
||||
double tablet_get_dbl_if_positive(const char *content, const char *name);
|
||||
enum rotation tablet_parse_rotation(int value);
|
||||
uint32_t tablet_button_from_str(const char *button);
|
||||
uint32_t mouse_button_from_str(const char *button);
|
||||
|
|
|
|||
|
|
@ -854,6 +854,14 @@ entry(xmlNode *node, char *nodename, char *content)
|
|||
} else {
|
||||
wlr_log(WLR_ERROR, "Invalid value for <resize popupShow />");
|
||||
}
|
||||
} else if (!strcasecmp(nodename, "left.area.tablet")) {
|
||||
rc.tablet.box.x = tablet_get_dbl_if_positive(content, "left");
|
||||
} else if (!strcasecmp(nodename, "top.area.tablet")) {
|
||||
rc.tablet.box.y = tablet_get_dbl_if_positive(content, "top");
|
||||
} else if (!strcasecmp(nodename, "width.area.tablet")) {
|
||||
rc.tablet.box.width = tablet_get_dbl_if_positive(content, "width");
|
||||
} else if (!strcasecmp(nodename, "height.area.tablet")) {
|
||||
rc.tablet.box.height = tablet_get_dbl_if_positive(content, "height");
|
||||
} else if (!strcasecmp(nodename, "rotate.tablet")) {
|
||||
rc.tablet.rotation = tablet_parse_rotation(atoi(content));
|
||||
} else if (!strcasecmp(nodename, "button.map.tablet")) {
|
||||
|
|
@ -1027,7 +1035,7 @@ rcxml_init(void)
|
|||
rc.doubleclick_time = 500;
|
||||
rc.scroll_factor = 1.0;
|
||||
|
||||
rc.tablet.button_map_count = 0;
|
||||
rc.tablet.box = (struct wlr_fbox){0};
|
||||
tablet_load_default_button_mappings();
|
||||
|
||||
rc.repeat_rate = 25;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,17 @@
|
|||
#include "config/tablet.h"
|
||||
#include "config/rcxml.h"
|
||||
|
||||
double
|
||||
tablet_get_dbl_if_positive(const char *content, const char *name)
|
||||
{
|
||||
double value = atof(content);
|
||||
if (value < 0) {
|
||||
wlr_log(WLR_ERROR, "Invalid value for tablet area %s", name);
|
||||
return 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
enum rotation
|
||||
tablet_parse_rotation(int value)
|
||||
{
|
||||
|
|
@ -84,6 +95,7 @@ tablet_button_mapping_add(uint32_t from, uint32_t to)
|
|||
void
|
||||
tablet_load_default_button_mappings(void)
|
||||
{
|
||||
rc.tablet.button_map_count = 0;
|
||||
tablet_button_mapping_add(BTN_TOOL_PEN, BTN_LEFT); /* Used for the pen tip */
|
||||
tablet_button_mapping_add(BTN_STYLUS, BTN_RIGHT);
|
||||
tablet_button_mapping_add(BTN_STYLUS2, BTN_MIDDLE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue