component(developer/golang-123): Add Component
[oi-userland.git] / components / x11 / xorg-server / patches / 18-hotkey.patch
blobd6beb2dc65c858621476fdf833f945d4353f7dc6
1 diff --git a/Xi/exevents.c b/Xi/exevents.c
2 index 106da3a..dd7e3a2 100644
3 --- a/Xi/exevents.c
4 +++ b/Xi/exevents.c
5 @@ -225,7 +225,16 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
7 KeyClassPtr mk = master->key;
9 +#ifdef SUNSOFT
10 + DeviceIntPtr mdev = dixLookupPrivate(&master->devPrivates,
11 + HotkeyMapDevicePrivateKey);
12 +#endif
14 +#ifdef SUNSOFT
15 + if ((device == master) || (device == mdev))
16 +#else
17 if (device == master)
18 +#endif
19 return;
21 mk->sourceid = device->id;
22 diff --git a/config/hal.c b/config/hal.c
23 index 2ead556..9de9dfc 100644
24 --- a/config/hal.c
25 +++ b/config/hal.c
26 @@ -123,6 +123,49 @@ get_prop_string_array(LibHalContext * hal_ctx, const char *udi,
27 return ret;
30 +#ifdef SUNSOFT
31 +static void
32 +add_extra_device(char *driver)
34 + DeviceIntPtr dev;
35 + char *config_info = NULL;
36 + InputOption *input_options = NULL;
37 + InputAttributes attrs = {0};
39 + input_options = input_option_new(NULL, "_source", "server/hal");
40 + if (!input_options){
41 + LogMessage(X_ERROR, "config/hal: couldn't allocate first key/value pair\n");
42 + goto unwind;
43 + }
45 + input_options = input_option_new(input_options, "driver", driver);
46 + input_options = input_option_new(input_options, "name", driver);
48 + if (!asprintf(&config_info, "hal:%s", driver) == -1) {
49 + config_info = NULL;
50 + LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
51 + goto unwind;
52 + }
54 + /* Check for duplicate devices */
55 + if (device_is_duplicate(config_info))
56 + goto unwind;
58 + LogMessage(X_INFO, "config/hal: Adding input device %s\n", driver);
59 + if (NewInputDeviceRequest(input_options, &attrs, &dev) != Success) {
60 + LogMessage(X_ERROR, "config/hal: NewInputDeviceRequest failed\n");
61 + dev = NULL;
62 + goto unwind;
63 + }
65 + dev->config_info = xstrdup(config_info);
67 +unwind:
68 + free(config_info);
69 + input_option_free_list(&input_options);
71 +#endif
73 static void
74 device_added(LibHalContext * hal_ctx, const char *udi)
76 @@ -382,6 +425,14 @@ device_added(LibHalContext * hal_ctx, const char *udi)
77 input_option_new(input_options, "xkb_options", xkb_opts.options);
78 input_options = input_option_new(input_options, "config_info", config_info);
80 +#ifdef SUNSOFT
81 + InputOption *md = input_option_find(input_options, "mdriver");
82 + if (md) {
83 + char *mdriver = input_option_get_value(md);
84 + add_extra_device (mdriver);
85 + }
86 +#endif
88 /* this isn't an error, but how else do you output something that the user can see? */
89 LogMessage(X_INFO, "config/hal: Adding input device %s\n", name);
90 if ((rc = NewInputDeviceRequest(input_options, &attrs, &dev)) != Success) {
91 diff --git a/config/x11-input.fdi b/config/x11-input.fdi
92 index b263f36..425aec2 100644
93 --- a/config/x11-input.fdi
94 +++ b/config/x11-input.fdi
95 @@ -71,6 +71,12 @@
96 <!-- If we're using Linux, we use evdev by default (falling back to
97 kbd otherwise). -->
98 <merge key="input.x11_driver" type="string">kbd</merge>
99 + <match key="/org/freedesktop/Hal/devices/computer:system.formfactor" string="laptop">
100 + <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
101 + string="SunOS">
102 + <merge key="input.x11_options.mdriver" type="string">hotkey</merge>
103 + </match>
104 + </match>
105 <merge key="input.x11_options.XkbModel" type="string">pc105</merge>
106 <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
107 string="Linux">
108 diff --git a/include/inputstr.h b/include/inputstr.h
109 index 5a38924..263b1b1 100644
110 --- a/include/inputstr.h
111 +++ b/include/inputstr.h
112 @@ -57,6 +57,11 @@ SOFTWARE.
113 #include "geext.h"
114 #include "privates.h"
116 +#ifdef SUNSOFT
117 +extern _X_EXPORT DevPrivateKeyRec HotkeyMapDevicePrivateKeyRec;
118 +#define HotkeyMapDevicePrivateKey (&HotkeyMapDevicePrivateKeyRec)
119 +#endif
121 #define BitIsOn(ptr, bit) (!!(((const BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
122 #define SetBit(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
123 #define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))
124 --- xorg-server-1.19.5/Xi/extinit.c.orig Mon Oct 23 14:46:01 2017
125 +++ xorg-server-1.19.5/Xi/extinit.c Mon Oct 23 14:46:10 2017
126 @@ -371,6 +371,10 @@
128 DevPrivateKeyRec XIClientPrivateKeyRec;
130 +#ifdef SUNSOFT
131 +DevPrivateKeyRec HotkeyMapDevicePrivateKeyRec;
132 +#endif
134 /*****************************************************************
136 * Declarations of local routines.
137 @@ -1290,6 +1290,11 @@
138 (&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
139 FatalError("Cannot request private for XI.\n");
141 +#ifdef SUNSOFT
142 + if (!dixRegisterPrivateKey(&HotkeyMapDevicePrivateKeyRec, PRIVATE_DEVICE, 0))
143 + FatalError("Cannot request private for hotkey.\n");
144 +#endif
146 if (!XIBarrierInit())
147 FatalError("Could not initialize barriers.\n");