Re: [PATCH xserver 3/3] kdrive: Remove now-unused linux backend
drive/linux/tslib.c > +++ /dev/null > @@ -1,194 +0,0 @@ > -/* > - * TSLIB based touchscreen driver for KDrive > - * Porting to new input API and event queueing by Daniel Stone. > - * Derived from ts.c by Keith Packard > - * Derived from ps2.c by Jim Gettys > - * > - * Copyright © 1999 Keith Packard > - * Copyright © 2000 Compaq Computer Corporation > - * Copyright © 2002 MontaVista Software Inc. > - * Copyright © 2005 OpenedHand Ltd. > - * Copyright © 2006 Nokia Corporation > - * > - * Permission to use, copy, modify, distribute, and sell this software > and its > - * documentation for any purpose is hereby granted without fee, provided > that > - * the above copyright notice appear in all copies and that both that > - * copyright notice and this permission notice appear in supporting > - * documentation, and that the name of the authors and/or copyright > holders > - * not be used in advertising or publicity pertaining to distribution of > the > - * software without specific, written prior permission. The authors > and/or > - * copyright holders make no representations about the suitability of this > - * software for any purpose. It is provided "as is" without express or > - * implied warranty. > - * > - * THE AUTHORS AND/OR COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH > REGARD > - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY > - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS AND/OR COPYRIGHT HOLDERS BE > - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY > DAMAGES > - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > - */ > - > -#ifdef HAVE_KDRIVE_CONFIG_H > -#include > -#endif > - > -#include > -#include > -#include "inputstr.h" > -#include "scrnintstr.h" > -#include "kdrive.h" > -#include > -#include > -#include > -#include > - > -struct TslibPrivate { > -int fd; > -int lastx, lasty; > -struct tsdev *tsDev; > -void (*raw_event_hook) (int x, int y, int pressure, void *closure); > -void *raw_event_closure; > -int phys_screen; > -}; > - > -static void > -TsRead(int fd, void *closure) > -{ > -KdPointerInfo *pi = closure; > -struct TslibPrivate *private = pi->driverPrivate; > -struct ts_sample event; > -long x = 0, y = 0; > -unsigned long flags; > - > -if (private->raw_event_hook) { > -while (ts_read_raw(private->tsDev, , 1) == 1) > -private->raw_event_hook(event.x, event.y, event.pressure, > -private->raw_event_closure); > -return; > -} > - > -while (ts_read(private->tsDev, , 1) == 1) { > -if (event.pressure) { > -flags = KD_BUTTON_1; > - > -/* > - * Here we test for the touch screen driver actually being on > the > - * touch screen, if it is we send absolute coordinates. If > not, > - * then we send delta's so that we can track the entire vga > screen. > - */ > -if (KdCurScreen == private->phys_screen) { > -x = event.x; > -y = event.y; > -} > -else { > -flags |= KD_MOUSE_DELTA; > -if ((private->lastx == 0) || (private->lasty == 0)) { > -x = event.x; > -y = event.y; > -} > -else { > -x = event.x - private->lastx; > -y = event.y - private->lasty; > -} > -} > -private->lastx = event.x; > -private->lasty = event.y; > -} > -else { > -flags = 0; > -x = private->lastx; > -y = private->lasty; > -} > - > -KdEnqueuePointerEvent(pi, flags, x, y, event.pressure); > -} > -} > - > -static Status > -TslibEnable(KdPointerInfo * pi) > -{ > -struct TslibPrivate *private = pi->driverPrivate; > - > -private->raw_event_hook = NULL; > -private->raw_event_closure = NULL; > -if (!pi->path) { > -pi->path = strdup("/dev/input/touchscreen0"); > -ErrorF("[tslib/TslibEnable] no device path given, trying %s\n", > - pi->path); > -} > - > -private->tsDev = ts_open(pi->path, 0); > -if (!private->tsDev) { > -ErrorF("[tslib/TslibEnable] failed to open %s\n", pi->path); > -return BadAlloc; > -} > - > -if (ts_config(private->tsDev)) { > -ErrorF("[tslib/TslibEnable] failed to load configuration\n"); > -ts_close(private->tsDev); > -private->tsDev = NULL; > -return BadValue; > -} > - > -private->fd = ts_fd(private->tsDev); > - > -KdRegisterFd(private->fd, TsRead, pi); > - > -return Success; > -} > - > -static void > -TslibDisable(KdPointerInfo * pi) > -{ > -struct TslibPrivate *private = pi->driverPrivate; > - > -if (private->fd) > -KdUnregisterFd(pi, private->fd, TRUE); > - > -if (private->tsDev) > -ts_close(private->tsDev); > - > -private->fd = 0; > -private->tsDev = NULL; > -} > - > -static Status > -TslibInit(KdPointerInfo * pi) > -{ > -struct TslibPrivate *private = NULL; > - > -if (!pi || !pi->dixdev) > -return !Success; > - > -pi->driverPrivate = (struct TslibPrivate *) > -calloc(sizeof(struct TslibPrivate), 1); > -if (!pi->driverPrivate) > -return !Success; > - > -private = pi->driverPrivate; > -/* hacktastic */ > -private->phys_screen = 0; > -pi->nAxes = 3; > -pi->name = strdup("Touchscreen"); > -pi->inputClass = KD_TOUCHSCREEN; > - > -return Success; > -} > - > -static void > -TslibFini(KdPointerInfo * pi) > -{ > -free(pi->driverPrivate); > -pi->driverPrivate = NULL; > -} > - > -KdPointerDriver TsDriver = { > -"tslib", > -TslibInit, > -TslibEnable, > -TslibDisable, > -TslibFini, > -NULL, > -}; > -- > 2.9.3 > > ___ > xorg-devel@lists.x.org: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: https://lists.x.org/mailman/listinfo/xorg-devel -- *Laércio de Sousa* *Orientador de Informática* *Rua Ismael da Silva Mello, 559, Mogi Moderno, **Mogi das Cruzes - SP* *CEP 08717-390* Telefone: (11) 4726-8313 / 4796-5656 Facebook: https://www.facebook.com/egruppi ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: Proposed X server 1.19 schedule
Please consider reviewing my latest Xephyr patches (at least the latest one - I'm afraid things may break in Xephyr running in mui-seat mode after Keith's new event-handling API): https://patchwork.freedesktop.org/patch/89109/ https://patchwork.freedesktop.org/patch/89110/ https://patchwork.freedesktop.org/patch/89108/ 2016-09-02 2:33 GMT-03:00 Keith Packard <kei...@keithp.com>: > > Following the 'release early and often' mantra, we should probably get > 1.19 out the door and let people start using the new code. > > I'd like to propose that we figure out what remaining non-bug changes > we'd like to get merged in the next week (or two?), then move into a > non-critical bug fix period for two weeks followed by three or four > weeks of critical bug fixing and testing. That would look like: > > Development cycle ends: 2016-9-10 > Non-critical bugs: 2016-9-24 > Critical-bugs: 2016-10-22 > > We can chat about how things are going at XDC, of course. > > This is only a proposal; let's try to generate some rough consensus in > the next day or two on a final schedule. > > -- > -keith > > ___ > xorg-devel@lists.x.org: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: https://lists.x.org/mailman/listinfo/xorg-devel > -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr] ephyr: use XCB_EVENT_RESPONSE_TYPE macro
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index fe947db..5a8d9ef 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -27,6 +27,7 @@ #include #endif +#include #include #include @@ -1127,7 +1128,7 @@ ephyrXcbNotify(int fd, int ready, void *data) break; } -switch (xev->response_type & 0x7f) { +switch (XCB_EVENT_RESPONSE_TYPE(xev)) { case 0: ephyrProcessErrorEvent(xev); break; -- 2.7.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v3 3/3] ephyr: move SetNotifyFd()/RemoveNotifyFd() calls outside ephyr mouse driver
When Xephyr is launched in multi-seat mode (i.e. with command-line option "-seat seat"), ephyr virtual keyboard/mouse driver is not loaded. Without this patch, Xephyr won't listen to any events in multi-seat mode, including XCB_EXPOSE and XCB_CONFIGURE_NOTIFY, which may be needed even for this mode. v2: Don't register XCB input events when creating a new Xephyr window, if -seat option is passed. v3: Assume function hostx_create_window() was removed by previous patch. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyr.c | 4 ++-- hw/kdrive/ephyr/hostx.c | 17 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index f6897cc..9eae0c7 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -709,6 +709,7 @@ ephyrPreserve(KdCardInfo * card) Bool ephyrEnable(ScreenPtr pScreen) { +SetNotifyFd(hostx_get_fd(), ephyrXcbNotify, X_NOTIFY_READ, NULL); return TRUE; } @@ -721,6 +722,7 @@ ephyrDPMS(ScreenPtr pScreen, int mode) void ephyrDisable(ScreenPtr pScreen) { +RemoveNotifyFd(hostx_get_fd()); } void @@ -1257,7 +1259,6 @@ static Status MouseEnable(KdPointerInfo * pi) { ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = TRUE; -SetNotifyFd(hostx_get_fd(), ephyrXcbNotify, X_NOTIFY_READ, NULL); return Success; } @@ -1265,7 +1266,6 @@ static void MouseDisable(KdPointerInfo * pi) { ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE; -RemoveNotifyFd(hostx_get_fd()); return; } diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 8eb02b1..7e45828 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -431,16 +431,17 @@ hostx_init(void) xcb_screen_t *xscreen; xcb_rectangle_t rect = { 0, 0, 1, 1 }; -attrs[0] = -XCB_EVENT_MASK_BUTTON_PRESS -| XCB_EVENT_MASK_BUTTON_RELEASE -| XCB_EVENT_MASK_POINTER_MOTION -| XCB_EVENT_MASK_KEY_PRESS -| XCB_EVENT_MASK_KEY_RELEASE -| XCB_EVENT_MASK_EXPOSURE -| XCB_EVENT_MASK_STRUCTURE_NOTIFY; +attrs[0] = XCB_EVENT_MASK_EXPOSURE + | XCB_EVENT_MASK_STRUCTURE_NOTIFY; attr_mask |= XCB_CW_EVENT_MASK; +if (!SeatId) +attrs[0] |= XCB_EVENT_MASK_BUTTON_PRESS +| XCB_EVENT_MASK_BUTTON_RELEASE +| XCB_EVENT_MASK_POINTER_MOTION +| XCB_EVENT_MASK_KEY_PRESS +| XCB_EVENT_MASK_KEY_RELEASE; + EPHYR_DBG("mark"); #ifdef GLAMOR if (ephyr_glamor) -- 2.7.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v3 2/3] ephyr: fix RandR version check in hostx_get_output_geometry()
Current hostx_get_output_geometry() has a little problem when checking RandR version, treating e.g. version 2.0 as lower than 1.2. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/hostx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ca3e43f..8eb02b1 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -262,7 +262,8 @@ hostx_get_output_geometry(const char *output, fprintf(stderr, "\nFailed to get RandR version supported by host X server.\n"); exit(1); } -else if (version_r->major_version < 1 || version_r->minor_version < 2) +else if (version_r->major_version < 1 || + (version_r->major_version == 1 && version_r->minor_version < 2)) { free(version_r); fprintf(stderr, "\nHost X server doesn't support RandR 1.2, needed for -output usage.\n"); -- 2.7.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v3 1/3] ephyr: drop a lot of deprecated code
After commit 623ff251, a lot of functions and data structures in ephyr/hostx.{c,h} became uneeded. We are removing them now. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/hostx.c | 227 hw/kdrive/ephyr/hostx.h | 46 -- 2 files changed, 273 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index cdb12b0..ca3e43f 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -1231,233 +1231,6 @@ hostx_get_fd(void) return xcb_get_file_descriptor(HostX.conn); } -int -hostx_get_window(int a_screen_number) -{ -EphyrScrPriv *scrpriv; -if (a_screen_number < 0 || a_screen_number >= HostX.n_screens) { -EPHYR_LOG_ERROR("bad screen number:%d\n", a_screen_number); -return 0; -} -scrpriv = HostX.screens[a_screen_number]->driver; -return scrpriv->win; -} - -int -hostx_get_window_attributes(int a_window, EphyrHostWindowAttributes * a_attrs) -{ -xcb_get_geometry_cookie_t geom_cookie; -xcb_get_window_attributes_cookie_t attr_cookie; -xcb_get_geometry_reply_t *geom_reply; -xcb_get_window_attributes_reply_t *attr_reply; - -geom_cookie = xcb_get_geometry(HostX.conn, a_window); -attr_cookie = xcb_get_window_attributes(HostX.conn, a_window); -geom_reply = xcb_get_geometry_reply(HostX.conn, geom_cookie, NULL); -attr_reply = xcb_get_window_attributes_reply(HostX.conn, attr_cookie, NULL); - -a_attrs->x = geom_reply->x; -a_attrs->y = geom_reply->y; -a_attrs->width = geom_reply->width; -a_attrs->height = geom_reply->height; -a_attrs->visualid = attr_reply->visual; - -free(geom_reply); -free(attr_reply); -return TRUE; -} - -int -hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries) -{ -Bool is_ok = FALSE; -EphyrHostVisualInfo *host_visuals = NULL; -int nb_items = 0, i = 0, screen_num; -xcb_screen_iterator_t screens; -xcb_depth_iterator_t depths; - -EPHYR_RETURN_VAL_IF_FAIL(a_visuals && a_num_entries, FALSE); -EPHYR_LOG("enter\n"); - -screens = xcb_setup_roots_iterator(xcb_get_setup(HostX.conn)); -for (screen_num = 0; screens.rem; screen_num++, xcb_screen_next()) { -depths = xcb_screen_allowed_depths_iterator(screens.data); -for (; depths.rem; xcb_depth_next()) { -xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data); -EphyrHostVisualInfo *tmp_visuals = -reallocarray(host_visuals, - nb_items + depths.data->visuals_len, - sizeof(EphyrHostVisualInfo)); -if (!tmp_visuals) { -goto out; -} -host_visuals = tmp_visuals; -for (i = 0; i < depths.data->visuals_len; i++) { -host_visuals[nb_items + i].visualid = visuals[i].visual_id; -host_visuals[nb_items + i].screen = screen_num; -host_visuals[nb_items + i].depth = depths.data->depth; -host_visuals[nb_items + i].class = visuals[i]._class; -host_visuals[nb_items + i].red_mask = visuals[i].red_mask; -host_visuals[nb_items + i].green_mask = visuals[i].green_mask; -host_visuals[nb_items + i].blue_mask = visuals[i].blue_mask; -host_visuals[nb_items + i].colormap_size = visuals[i].colormap_entries; -host_visuals[nb_items + i].bits_per_rgb = visuals[i].bits_per_rgb_value; -} -nb_items += depths.data->visuals_len; -} -} - -EPHYR_LOG("host advertises %d visuals\n", nb_items); -*a_visuals = host_visuals; -*a_num_entries = nb_items; -host_visuals = NULL; - -is_ok = TRUE; -out: -free(host_visuals); -host_visuals = NULL; -EPHYR_LOG("leave\n"); -return is_ok; - -} - -int -hostx_create_window(int a_screen_number, -EphyrBox * a_geometry, -int a_visual_id, int *a_host_peer /*out parameter */ ) -{ -Bool is_ok = FALSE; -xcb_window_t win; -int winmask = 0; -uint32_t attrs[2]; -xcb_screen_t *screen = xcb_aux_get_screen(HostX.conn, hostx_get_screen()); -xcb_visualtype_t *visual; -int depth = 0; -EphyrScrPriv *scrpriv = HostX.screens[a_screen_number]->driver; - -EPHYR_RETURN_VAL_IF_FAIL(screen && a_geometry, FALSE); - -EPHYR_LOG("enter\n"); - -visual = xcb_aux_find_visual_by_id(screen, a_visual_id); -if (!visual) { -EPHYR_LOG_ERROR ("argh, could not find a remote visual with id:%d\n", - a_visual_id); -goto out; -} -depth = xcb_aux_get_depth_of_visual(screen, a_visual_id); - -winmask = XCB_CW_EVENT_MASK | XCB_CW_COL
Re: [PATCH xserver 08/11] kdrive/ephyr: Poll for events in block handler
> Your patch looks like a fine > change, although I think it might need to include a change to discard > input events when the input subsystem wasn't running (which is why the > SetNotifyFd calls are where they are) > Thanks for the tip! I'm submitting a v2 of my patch preventing Xephyr windows from registering input events when -seat option is passed. Regards, -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v2] ephyr: move SetNotifyFd()/RemoveNotifyFd() calls outside ephyr mouse driver
When Xephyr is launched in multi-seat mode (i.e. with command-line option "-seat seat"), ephyr virtual keyboard/mouse driver is not loaded. Without this patch, Xephyr won't listen to any events in multi-seat mode, including XCB_EXPOSE and XCB_CONFIGURE_NOTIFY, which may be needed even for this mode. v2: Don't register XCB input events when creating a new Xephyr window, if -seat option is passed. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyr.c | 4 ++-- hw/kdrive/ephyr/hostx.c | 33 ++--- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index f6897cc..9eae0c7 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -709,6 +709,7 @@ ephyrPreserve(KdCardInfo * card) Bool ephyrEnable(ScreenPtr pScreen) { +SetNotifyFd(hostx_get_fd(), ephyrXcbNotify, X_NOTIFY_READ, NULL); return TRUE; } @@ -721,6 +722,7 @@ ephyrDPMS(ScreenPtr pScreen, int mode) void ephyrDisable(ScreenPtr pScreen) { +RemoveNotifyFd(hostx_get_fd()); } void @@ -1257,7 +1259,6 @@ static Status MouseEnable(KdPointerInfo * pi) { ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = TRUE; -SetNotifyFd(hostx_get_fd(), ephyrXcbNotify, X_NOTIFY_READ, NULL); return Success; } @@ -1265,7 +1266,6 @@ static void MouseDisable(KdPointerInfo * pi) { ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE; -RemoveNotifyFd(hostx_get_fd()); return; } diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index cdb12b0..1ef8cec 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -430,16 +430,17 @@ hostx_init(void) xcb_screen_t *xscreen; xcb_rectangle_t rect = { 0, 0, 1, 1 }; -attrs[0] = -XCB_EVENT_MASK_BUTTON_PRESS -| XCB_EVENT_MASK_BUTTON_RELEASE -| XCB_EVENT_MASK_POINTER_MOTION -| XCB_EVENT_MASK_KEY_PRESS -| XCB_EVENT_MASK_KEY_RELEASE -| XCB_EVENT_MASK_EXPOSURE -| XCB_EVENT_MASK_STRUCTURE_NOTIFY; +attrs[0] = XCB_EVENT_MASK_EXPOSURE + | XCB_EVENT_MASK_STRUCTURE_NOTIFY; attr_mask |= XCB_CW_EVENT_MASK; +if (!SeatId) +attrs[0] |= XCB_EVENT_MASK_BUTTON_PRESS +| XCB_EVENT_MASK_BUTTON_RELEASE +| XCB_EVENT_MASK_POINTER_MOTION +| XCB_EVENT_MASK_KEY_PRESS +| XCB_EVENT_MASK_KEY_RELEASE; + EPHYR_DBG("mark"); #ifdef GLAMOR if (ephyr_glamor) @@ -1348,19 +1349,21 @@ hostx_create_window(int a_screen_number, depth = xcb_aux_get_depth_of_visual(screen, a_visual_id); winmask = XCB_CW_EVENT_MASK | XCB_CW_COLORMAP; -attrs[0] = XCB_EVENT_MASK_BUTTON_PRESS - |XCB_EVENT_MASK_BUTTON_RELEASE - |XCB_EVENT_MASK_POINTER_MOTION - |XCB_EVENT_MASK_KEY_PRESS - |XCB_EVENT_MASK_KEY_RELEASE - |XCB_EVENT_MASK_EXPOSURE; +attrs[0] = XCB_EVENT_MASK_EXPOSURE; attrs[1] = xcb_generate_id(HostX.conn); + +if (!SeatId) +attrs[0] |= XCB_EVENT_MASK_BUTTON_PRESS +| XCB_EVENT_MASK_BUTTON_RELEASE +| XCB_EVENT_MASK_POINTER_MOTION +| XCB_EVENT_MASK_KEY_PRESS +| XCB_EVENT_MASK_KEY_RELEASE; + xcb_create_colormap(HostX.conn, XCB_COLORMAP_ALLOC_NONE, attrs[1], hostx_get_window(a_screen_number), a_visual_id); - win = xcb_generate_id(HostX.conn); xcb_create_window(HostX.conn, depth, -- 2.7.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 08/11] kdrive/ephyr: Poll for events in block handler
Could it be related somehow to my concerns in https://patchwork.freedesktop.org/patch/86328 ? 2016-05-18 18:51 GMT-03:00 Keith Packard <kei...@keithp.com>: > With the driver block handler guaranteed to be the last thing called > before the server blocks, we can now reliably check for events there > and never block with events read but not processed. > > Signed-off-by: Keith Packard <kei...@keithp.com> > --- > hw/kdrive/ephyr/ephyr.c | 14 +- > hw/kdrive/ephyr/ephyr.h | 3 +++ > hw/kdrive/ephyr/ephyrinit.c | 1 + > hw/kdrive/src/kdrive.h | 2 +- > hw/kdrive/src/kinput.c | 9 - > 5 files changed, 22 insertions(+), 7 deletions(-) > > diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c > index 1a410ca..6066b5d 100644 > --- a/hw/kdrive/ephyr/ephyr.c > +++ b/hw/kdrive/ephyr/ephyr.c > @@ -1106,7 +1106,7 @@ ephyrProcessConfigureNotify(xcb_generic_event_t *xev) > } > > static void > -ephyrXcbNotify(int fd, int ready, void *data) > +ephyrXcbProcessEvents(void) > { > xcb_connection_t *conn = hostx_get_xcbconn(); > > @@ -1166,6 +1166,18 @@ ephyrXcbNotify(int fd, int ready, void *data) > } > } > > +static void > +ephyrXcbNotify(int fd, int ready, void *data) > +{ > +ephyrXcbProcessEvents(); > +} > + > +void > +ephyrBlockHandler(ScreenPtr pScreen, void *timeo) > +{ > +ephyrXcbProcessEvents(); > +} > + > void > ephyrCardFini(KdCardInfo * card) > { > diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h > index f5015f6..ef5736e 100644 > --- a/hw/kdrive/ephyr/ephyr.h > +++ b/hw/kdrive/ephyr/ephyr.h > @@ -138,6 +138,9 @@ void > ephyrCloseScreen(ScreenPtr pScreen); > > void > +ephyrBlockHandler(ScreenPtr pScreen, void *timeo); > + > +void > ephyrCardFini(KdCardInfo * card); > > void > diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c > index 149ea98..03d6289 100644 > --- a/hw/kdrive/ephyr/ephyrinit.c > +++ b/hw/kdrive/ephyr/ephyrinit.c > @@ -411,4 +411,5 @@ KdCardFuncs ephyrFuncs = { > ephyrPutColors, /* putColors */ > > ephyrCloseScreen, /* closeScreen */ > +ephyrBlockHandler, /* blockHandler */ > }; > diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h > index 3c7f2cd..6ef7337 100644 > --- a/hw/kdrive/src/kdrive.h > +++ b/hw/kdrive/src/kdrive.h > @@ -133,6 +133,7 @@ typedef struct _KdCardFuncs { > void (*putColors) (ScreenPtr, int, xColorItem *); > > void (*closeScreen) (ScreenPtr);/* close ScreenRec */ > +void (*blockHandler) (ScreenPtr, void *timeo); > } KdCardFuncs; > > #define KD_MAX_PSEUDO_DEPTH 8 > @@ -296,7 +297,6 @@ typedef struct _KdOsFuncs { > Bool (*SpecialKey) (KeySym); > void (*Disable) (void); > void (*Fini) (void); > -void (*pollEvents) (void); > void (*Bell) (int, int, int); > } KdOsFuncs; > > diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c > index c0f1cf7..2234dfc 100644 > --- a/hw/kdrive/src/kinput.c > +++ b/hw/kdrive/src/kinput.c > @@ -1965,6 +1965,7 @@ KdBlockHandler(ScreenPtr pScreen, void *timeo) > { > KdPointerInfo *pi; > int myTimeout = 0; > +KdScreenPriv(pScreen); > > for (pi = kdPointers; pi; pi = pi->next) { > if (pi->timeoutPending) { > @@ -1977,13 +1978,11 @@ KdBlockHandler(ScreenPtr pScreen, void *timeo) > myTimeout = ms; > } > } > -/* if we need to poll for events, do that */ > -if (kdOsFuncs->pollEvents) { > -(*kdOsFuncs->pollEvents) (); > -myTimeout = 20; > -} > if (myTimeout > 0) > AdjustWaitForDelay(timeo, myTimeout); > + > + if (pScreenPriv->card->cfuncs->blockHandler) > +(*pScreenPriv->card->cfuncs->blockHandler)(pScreen, timeo); > } > > void > -- > 2.8.0.rc3 > > ___ > xorg-devel@lists.x.org: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: https://lists.x.org/mailman/listinfo/xorg-devel -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr RFC] ephyr: move SetNotifyFd()/RemoveNotifyFd() calls outside ephyr mouse driver
When Xephyr is launched in multi-seat mode (i.e. with command-line option "-seat seat"), ephyr virtual keyboard/mouse driver is not loaded. Without this patch, Xephyr won't listen to any events in multi-seat mode, including XCB_EXPOSE and XCB_CONFIGURE_NOTIFY, which may be needed even for this mode. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index f6897cc..9eae0c7 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -709,6 +709,7 @@ ephyrPreserve(KdCardInfo * card) Bool ephyrEnable(ScreenPtr pScreen) { +SetNotifyFd(hostx_get_fd(), ephyrXcbNotify, X_NOTIFY_READ, NULL); return TRUE; } @@ -721,6 +722,7 @@ ephyrDPMS(ScreenPtr pScreen, int mode) void ephyrDisable(ScreenPtr pScreen) { +RemoveNotifyFd(hostx_get_fd()); } void @@ -1257,7 +1259,6 @@ static Status MouseEnable(KdPointerInfo * pi) { ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = TRUE; -SetNotifyFd(hostx_get_fd(), ephyrXcbNotify, X_NOTIFY_READ, NULL); return Success; } @@ -1265,7 +1266,6 @@ static void MouseDisable(KdPointerInfo * pi) { ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE; -RemoveNotifyFd(hostx_get_fd()); return; } -- 2.7.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v2] kdrive/ephyr: map host X server's keymap into Xephyr, if supported
2016-02-25 16:32 GMT-03:00 Laércio de Sousa < laercioso...@sme-mogidascruzes.sp.gov.br>: > > The thing here is that I want to call XkbApplyMappingChange() + > XkbDDXChangeControls() inside EphyrKeyboardInit(), so I can isolate this > code properly (I don't need it for e.g. kdrive evdev driver, since this one > takes keymap directly from proposed -xkb-* options or udev properties), but > I can only do that if EphyrKeyboardInit() is called *after* > InitKeyboardDeviceStruct(). This is why I've moved the "if > ((*ki->driver->Init) (ki) != Success) ..." block down a bit. > To be more clear, Alan: this patch is not related to my multi-seat patch series at all. This one applies to the general use case for Xephyr (an embedded X server that runs inside a usual desktop session for testing purposes, sharing input devices with the host X server). It has absolutely no effect when Xephyr handles its own input hardware via kdrive evdev driver. -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v3] kdrive/ephyr: map host X server's keymap into Xephyr, if supported
Currently Xephyr doesn't inherit host X server's keymap, which may lead to keymap mismatches when using a non-US keyboard in a window inside Xephyr. This patch makes Xephyr change its keymap to match host X server's one (unless XKB support is disabled), using xcb-xkb to retrieve the needed XKB controls. This implementation is analogous to Xnest one at commit 83fef4235. Supersedes: https://patchwork.freedesktop.org/patch/67504 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac| 2 +- hw/kdrive/ephyr/ephyr.c | 28 --- hw/kdrive/ephyr/hostx.c | 131 +--- hw/kdrive/ephyr/hostx.h | 9 +--- hw/kdrive/src/kinput.c | 8 +-- 5 files changed, 151 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index 312fc69..c166841 100644 --- a/configure.ac +++ b/configure.ac @@ -2393,7 +2393,7 @@ if test "$KDRIVE" = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" +XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb" if test "x$XV" = xyes; then XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" fi diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index a272882..f6897cc 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -47,7 +47,6 @@ extern Bool ephyr_glamor; KdKeyboardInfo *ephyrKbd; KdPointerInfo *ephyrMouse; -EphyrKeySyms ephyrKeySyms; Bool ephyrNoDRI = FALSE; Bool ephyrNoXV = FALSE; @@ -1291,16 +1290,29 @@ KdPointerDriver EphyrMouseDriver = { static Status EphyrKeyboardInit(KdKeyboardInfo * ki) { +KeySymsRec keySyms; +CARD8 modmap[MAP_LENGTH]; +XkbControlsRec controls; + ki->driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); -hostx_load_keymap(); -if (!ephyrKeySyms.minKeyCode) { -ErrorF("Couldn't load keymap from host\n"); -return BadAlloc; + +if (hostx_load_keymap(, modmap, )) { +XkbApplyMappingChange(ki->dixdev, , + keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); +XkbDDXChangeControls(ki->dixdev, , ); +free(keySyms.map); +} + +ki->minScanCode = keySyms.minKeyCode; +ki->maxScanCode = keySyms.maxKeyCode; + +if (ki->name != NULL) { +free(ki->name); } -ki->minScanCode = ephyrKeySyms.minKeyCode; -ki->maxScanCode = ephyrKeySyms.maxKeyCode; -free(ki->name); + ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ce9faca..cdb12b0 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef GLAMOR #include #include "glamor.h" @@ -86,8 +87,6 @@ static EphyrHostXVars HostX; static int HostXWantDamageDebug = 0; -extern EphyrKeySyms ephyrKeySyms; - extern Bool EphyrWantResize; char *ephyrResName = NULL; @@ -1082,18 +1081,136 @@ hostx_paint_debug_rect(KdScreenInfo *screen, nanosleep(, NULL); } -void -hostx_load_keymap(void) +Bool +hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls) { int min_keycode, max_keycode; - +int map_width; +size_t i, j; +int keymap_len; +xcb_keysym_t *keymap; +xcb_keycode_t *modifier_map; +xcb_get_keyboard_mapping_cookie_t mapping_c; +xcb_get_keyboard_mapping_reply_t *mapping_r; +xcb_get_modifier_mapping_cookie_t modifier_c; +xcb_get_modifier_mapping_reply_t *modifier_r; +xcb_xkb_use_extension_cookie_t use_c; +xcb_xkb_use_extension_reply_t *use_r; +xcb_xkb_get_controls_cookie_t controls_c; +xcb_xkb_get_controls_reply_t *controls_r; + +/* First of all, collect host X server's + * min_keycode and max_keycode, which are + * independent from XKB support. */ min_keycode = xcb_get_setup(HostX.conn)->min_keycode; max_keycode = xcb_get_setup(HostX.conn)->max_keycode; EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode); -ephyrKeySyms.minKeyCode = min_keycode; -ephyrKeySyms.maxKeyCode = max_keycode; +keySyms->minKeyCode = min_keycode; +keySyms->maxKeyCode = max_keycode; + +/* Check for XKB availability in host X server */ +if (!hostx_has_extension(_xkb_id)) { +EPHYR_LOG_ERROR("XKB extension is not supported in host X server."); +return FALSE; +} + +use_c = xcb_xkb_us
Re: [PATCH kdrive/ephyr v2] kdrive/ephyr: map host X server's keymap into Xephyr, if supported
2016-02-25 16:07 GMT-03:00 Adam Jackson <a...@nwnk.net>: > @ -1291,16 +1290,35 @@ KdPointerDriver EphyrMouseDriver = { > > static Status > > EphyrKeyboardInit(KdKeyboardInfo * ki) > > { > > +int i; > > Unused variable. > Removed. Thanks! > +if (!keySyms.minKeyCode) { > > ErrorF("Couldn't load keymap from host\n"); > > return BadAlloc; > > } > > I don't think this can ever be triggered? hostx_load_keymap initializes > minKeyCode based on the initial connection block before doing anything > else, and it'll never be 0 because the X protocol guarantees it's >= 8. > > I suppose that's not your fault, the current code is broken in the same > way. Still probably best to just delete that conditional, if we ever > run against a non-XKB server we might as well try to stumble through. > I'll drop it. Thanks! > > diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c > > index 3a1c6a0..00ef4d0 100644 > > --- a/hw/kdrive/src/kinput.c > > +++ b/hw/kdrive/src/kinput.c > > @@ -747,10 +747,6 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) > > return BadImplementation; > > } > > > > -if ((*ki->driver->Init) (ki) != Success) { > > -return !Success; > > -} > > - > > memset(, 0, sizeof(rmlvo)); > > rmlvo.rules = ki->xkbRules; > > rmlvo.model = ki->xkbModel; > > @@ -763,6 +759,10 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) > > return BadImplementation; > > } > > > > +if ((*ki->driver->Init) (ki) != Success) { > > +return !Success; > > +} > > + > > xiclass = AtomFromName(XI_KEYBOARD); > > AssignTypeAndName(pDevice, xiclass, > >ki->name ? ki->name : "Generic KDrive > Keyboard"); > > This seems like it clobbers whatever you'd have passed in from the > command line (in patch 2/4 of your other series). Am I reading that > right? What's the desired result here The thing here is that I want to call XkbApplyMappingChange() + XkbDDXChangeControls() inside EphyrKeyboardInit(), so I can isolate this code properly (I don't need it for e.g. kdrive evdev driver, since this one takes keymap directly from proposed -xkb-* options or udev properties), but I can only do that if EphyrKeyboardInit() is called *after* InitKeyboardDeviceStruct(). This is why I've moved the "if ((*ki->driver->Init) (ki) != Success) ..." block down a bit. -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr] kdrive/ephyr: map host X server's keymap into Xephyr, if supported
2016-02-23 17:16 GMT-03:00 Ran Benita <ran...@gmail.com>: > So the sentence "If host X server supports XKB extension, this patch > uses xcb-xkb to apply its keymap in Xephyr." should be adjusted to only > talk about XKB controls and not the entire keymap, I think. > What about this? "This patch makes Xephyr change its keymap to match host X server's one (unless XKB support is disabled), using xcb-xkb to retrieve the needed XKB controls." Kind regards, -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr] kdrive/ephyr: map host X server's keymap into Xephyr, if supported
Currently Xephyr doesn't inherit host X server's keymap, which may lead to keymap mismatches when typing in a window inside Xephyr. This patch makes Xephyr change its keymap to match host X server's one (unless XKB support is disabled), using xcb-xkb to retrieve the needed XKB controls. This implementation is analogous to Xnest one at commit 83fef4235. Supersedes: https://patchwork.freedesktop.org/patch/67504 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac| 2 +- hw/kdrive/ephyr/ephyr.c | 30 --- hw/kdrive/ephyr/hostx.c | 131 +--- hw/kdrive/ephyr/hostx.h | 9 +--- hw/kdrive/src/kinput.c | 8 +-- 5 files changed, 155 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 312fc69..c166841 100644 --- a/configure.ac +++ b/configure.ac @@ -2393,7 +2393,7 @@ if test "$KDRIVE" = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" +XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb" if test "x$XV" = xyes; then XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" fi diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index a272882..fa76765 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -47,7 +47,6 @@ extern Bool ephyr_glamor; KdKeyboardInfo *ephyrKbd; KdPointerInfo *ephyrMouse; -EphyrKeySyms ephyrKeySyms; Bool ephyrNoDRI = FALSE; Bool ephyrNoXV = FALSE; @@ -1291,16 +1290,35 @@ KdPointerDriver EphyrMouseDriver = { static Status EphyrKeyboardInit(KdKeyboardInfo * ki) { +int i; +KeySymsRec keySyms; +CARD8 modmap[MAP_LENGTH]; +XkbControlsRec controls; + ki->driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); -hostx_load_keymap(); -if (!ephyrKeySyms.minKeyCode) { + +if (hostx_load_keymap(, modmap, )) { +XkbApplyMappingChange(ki->dixdev, , + keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); +XkbDDXChangeControls(ki->dixdev, , ); +free(keySyms.map); +} + +if (!keySyms.minKeyCode) { ErrorF("Couldn't load keymap from host\n"); return BadAlloc; } -ki->minScanCode = ephyrKeySyms.minKeyCode; -ki->maxScanCode = ephyrKeySyms.maxKeyCode; -free(ki->name); + +ki->minScanCode = keySyms.minKeyCode; +ki->maxScanCode = keySyms.maxKeyCode; + +if (ki->name != NULL) { +free(ki->name); +} + ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ce9faca..cdb12b0 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef GLAMOR #include #include "glamor.h" @@ -86,8 +87,6 @@ static EphyrHostXVars HostX; static int HostXWantDamageDebug = 0; -extern EphyrKeySyms ephyrKeySyms; - extern Bool EphyrWantResize; char *ephyrResName = NULL; @@ -1082,18 +1081,136 @@ hostx_paint_debug_rect(KdScreenInfo *screen, nanosleep(, NULL); } -void -hostx_load_keymap(void) +Bool +hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls) { int min_keycode, max_keycode; - +int map_width; +size_t i, j; +int keymap_len; +xcb_keysym_t *keymap; +xcb_keycode_t *modifier_map; +xcb_get_keyboard_mapping_cookie_t mapping_c; +xcb_get_keyboard_mapping_reply_t *mapping_r; +xcb_get_modifier_mapping_cookie_t modifier_c; +xcb_get_modifier_mapping_reply_t *modifier_r; +xcb_xkb_use_extension_cookie_t use_c; +xcb_xkb_use_extension_reply_t *use_r; +xcb_xkb_get_controls_cookie_t controls_c; +xcb_xkb_get_controls_reply_t *controls_r; + +/* First of all, collect host X server's + * min_keycode and max_keycode, which are + * independent from XKB support. */ min_keycode = xcb_get_setup(HostX.conn)->min_keycode; max_keycode = xcb_get_setup(HostX.conn)->max_keycode; EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode); -ephyrKeySyms.minKeyCode = min_keycode; -ephyrKeySyms.maxKeyCode = max_keycode; +keySyms->minKeyCode = min_keycode; +keySyms->maxKeyCode = max_keycode; + +/* Check for XKB availability in host X server */ +if (!hostx_has_extension(_xkb_id)) { +EPHYR_LOG_ERROR("XKB extension is not supported in host X
[PATCH kdrive/ephyr v2] kdrive/ephyr: map host X server's keymap into Xephyr, if supported
Currently Xephyr doesn't inherit host X server's keymap, which may lead to keymap mismatches when typing in a window inside Xephyr. This patch makes Xephyr change its keymap to match host X server's one (unless XKB support is disabled), using xcb-xkb to retrieve the needed XKB controls. This implementation is analogous to Xnest one at commit 83fef4235. Supersedes: https://patchwork.freedesktop.org/patch/67504 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac| 2 +- hw/kdrive/ephyr/ephyr.c | 30 --- hw/kdrive/ephyr/hostx.c | 131 +--- hw/kdrive/ephyr/hostx.h | 9 +--- hw/kdrive/src/kinput.c | 8 +-- 5 files changed, 155 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 312fc69..c166841 100644 --- a/configure.ac +++ b/configure.ac @@ -2393,7 +2393,7 @@ if test "$KDRIVE" = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" +XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb" if test "x$XV" = xyes; then XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" fi diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index a272882..fa76765 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -47,7 +47,6 @@ extern Bool ephyr_glamor; KdKeyboardInfo *ephyrKbd; KdPointerInfo *ephyrMouse; -EphyrKeySyms ephyrKeySyms; Bool ephyrNoDRI = FALSE; Bool ephyrNoXV = FALSE; @@ -1291,16 +1290,35 @@ KdPointerDriver EphyrMouseDriver = { static Status EphyrKeyboardInit(KdKeyboardInfo * ki) { +int i; +KeySymsRec keySyms; +CARD8 modmap[MAP_LENGTH]; +XkbControlsRec controls; + ki->driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); -hostx_load_keymap(); -if (!ephyrKeySyms.minKeyCode) { + +if (hostx_load_keymap(, modmap, )) { +XkbApplyMappingChange(ki->dixdev, , + keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); +XkbDDXChangeControls(ki->dixdev, , ); +free(keySyms.map); +} + +if (!keySyms.minKeyCode) { ErrorF("Couldn't load keymap from host\n"); return BadAlloc; } -ki->minScanCode = ephyrKeySyms.minKeyCode; -ki->maxScanCode = ephyrKeySyms.maxKeyCode; -free(ki->name); + +ki->minScanCode = keySyms.minKeyCode; +ki->maxScanCode = keySyms.maxKeyCode; + +if (ki->name != NULL) { +free(ki->name); +} + ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ce9faca..cdb12b0 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef GLAMOR #include #include "glamor.h" @@ -86,8 +87,6 @@ static EphyrHostXVars HostX; static int HostXWantDamageDebug = 0; -extern EphyrKeySyms ephyrKeySyms; - extern Bool EphyrWantResize; char *ephyrResName = NULL; @@ -1082,18 +1081,136 @@ hostx_paint_debug_rect(KdScreenInfo *screen, nanosleep(, NULL); } -void -hostx_load_keymap(void) +Bool +hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls) { int min_keycode, max_keycode; - +int map_width; +size_t i, j; +int keymap_len; +xcb_keysym_t *keymap; +xcb_keycode_t *modifier_map; +xcb_get_keyboard_mapping_cookie_t mapping_c; +xcb_get_keyboard_mapping_reply_t *mapping_r; +xcb_get_modifier_mapping_cookie_t modifier_c; +xcb_get_modifier_mapping_reply_t *modifier_r; +xcb_xkb_use_extension_cookie_t use_c; +xcb_xkb_use_extension_reply_t *use_r; +xcb_xkb_get_controls_cookie_t controls_c; +xcb_xkb_get_controls_reply_t *controls_r; + +/* First of all, collect host X server's + * min_keycode and max_keycode, which are + * independent from XKB support. */ min_keycode = xcb_get_setup(HostX.conn)->min_keycode; max_keycode = xcb_get_setup(HostX.conn)->max_keycode; EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode); -ephyrKeySyms.minKeyCode = min_keycode; -ephyrKeySyms.maxKeyCode = max_keycode; +keySyms->minKeyCode = min_keycode; +keySyms->maxKeyCode = max_keycode; + +/* Check for XKB availability in host X server */ +if (!hostx_has_extension(_xkb_id)) { +EPHYR_LOG_ERROR("XKB extension is not supported in host X
Possible regression/ABI breakage in Xorg socket-activation support
Hi there! Regarging https://bugs.freedesktop.org/show_bug.cgi?id=93072, I've also observed this issue in Ubuntu 15.10 (xorg-server 1.17.2 and systemd 225) and 16.04 alpha 2 (xorg-server 1.17.3 and systemd 229), but not in openSUSE Leap 42.1 (xorg-server 1.17.2 and systemd 210). Could it be a Xorg regression? A systemd regression? Or some kind of libsystemd ABI breakage? ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr] kdrive/ephyr: map host X server's keymap into Xephyr, if supported
Currently Xephyr doesn't inherit host X server's keymap, which may lead to keymap mismatches when typing in a window inside Xephyr. If host X server supports XKB extension, this patch uses xcb-xkb to apply its keymap in Xephyr. This implementation is analogous to Xnest one at commit 83fef4235. Supersedes: https://patchwork.freedesktop.org/patch/67504 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac| 2 +- hw/kdrive/ephyr/ephyr.c | 30 --- hw/kdrive/ephyr/hostx.c | 131 +--- hw/kdrive/ephyr/hostx.h | 9 +--- hw/kdrive/src/kinput.c | 8 +-- 5 files changed, 155 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 312fc69..c166841 100644 --- a/configure.ac +++ b/configure.ac @@ -2393,7 +2393,7 @@ if test "$KDRIVE" = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" +XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb" if test "x$XV" = xyes; then XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" fi diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index a272882..fa76765 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -47,7 +47,6 @@ extern Bool ephyr_glamor; KdKeyboardInfo *ephyrKbd; KdPointerInfo *ephyrMouse; -EphyrKeySyms ephyrKeySyms; Bool ephyrNoDRI = FALSE; Bool ephyrNoXV = FALSE; @@ -1291,16 +1290,35 @@ KdPointerDriver EphyrMouseDriver = { static Status EphyrKeyboardInit(KdKeyboardInfo * ki) { +int i; +KeySymsRec keySyms; +CARD8 modmap[MAP_LENGTH]; +XkbControlsRec controls; + ki->driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); -hostx_load_keymap(); -if (!ephyrKeySyms.minKeyCode) { + +if (hostx_load_keymap(, modmap, )) { +XkbApplyMappingChange(ki->dixdev, , + keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); +XkbDDXChangeControls(ki->dixdev, , ); +free(keySyms.map); +} + +if (!keySyms.minKeyCode) { ErrorF("Couldn't load keymap from host\n"); return BadAlloc; } -ki->minScanCode = ephyrKeySyms.minKeyCode; -ki->maxScanCode = ephyrKeySyms.maxKeyCode; -free(ki->name); + +ki->minScanCode = keySyms.minKeyCode; +ki->maxScanCode = keySyms.maxKeyCode; + +if (ki->name != NULL) { +free(ki->name); +} + ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ce9faca..cdb12b0 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef GLAMOR #include #include "glamor.h" @@ -86,8 +87,6 @@ static EphyrHostXVars HostX; static int HostXWantDamageDebug = 0; -extern EphyrKeySyms ephyrKeySyms; - extern Bool EphyrWantResize; char *ephyrResName = NULL; @@ -1082,18 +1081,136 @@ hostx_paint_debug_rect(KdScreenInfo *screen, nanosleep(, NULL); } -void -hostx_load_keymap(void) +Bool +hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls) { int min_keycode, max_keycode; - +int map_width; +size_t i, j; +int keymap_len; +xcb_keysym_t *keymap; +xcb_keycode_t *modifier_map; +xcb_get_keyboard_mapping_cookie_t mapping_c; +xcb_get_keyboard_mapping_reply_t *mapping_r; +xcb_get_modifier_mapping_cookie_t modifier_c; +xcb_get_modifier_mapping_reply_t *modifier_r; +xcb_xkb_use_extension_cookie_t use_c; +xcb_xkb_use_extension_reply_t *use_r; +xcb_xkb_get_controls_cookie_t controls_c; +xcb_xkb_get_controls_reply_t *controls_r; + +/* First of all, collect host X server's + * min_keycode and max_keycode, which are + * independent from XKB support. */ min_keycode = xcb_get_setup(HostX.conn)->min_keycode; max_keycode = xcb_get_setup(HostX.conn)->max_keycode; EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode); -ephyrKeySyms.minKeyCode = min_keycode; -ephyrKeySyms.maxKeyCode = max_keycode; +keySyms->minKeyCode = min_keycode; +keySyms->maxKeyCode = max_keycode; + +/* Check for XKB availability in host X server */ +if (!hostx_has_extension(_xkb_id)) { +EPHYR_LOG_ERROR("XKB extension is not supported in host X server."); +return FALSE; +} + +use_c = xcb_xkb_use_extension(HostX.conn, +
[PATCH v2] kdrive/evdev: update keyboard LEDs (#22302)
Implement missing parts in kdrive evdev driver for correct update of evdev keyboard LEDs. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=22302 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/linux/evdev.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c index cdd45e7..a5b5954 100644 --- a/hw/kdrive/linux/evdev.c +++ b/hw/kdrive/linux/evdev.c @@ -442,10 +442,13 @@ EvdevKbdEnable(KdKeyboardInfo * ki) static void EvdevKbdLeds(KdKeyboardInfo * ki, int leds) { -/*struct input_event event; +struct input_event event; Kevdev *ke; -ki->driverPrivate = ke; +ke = ki->driverPrivate; + +if (!ki || !ke) +return; memset(, 0, sizeof(event)); @@ -468,7 +471,6 @@ EvdevKbdLeds(KdKeyboardInfo * ki, int leds) event.code = LED_COMPOSE; event.value = leds & (1 << 3) ? 1 : 0; write(ke->fd, (char *) , sizeof(event)); -*/ } static void -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/evdev] kdrive/evdev: update keyboard LEDs (#22302)
Ah, yes! No problem! We can drop it. 2016-02-22 15:48 GMT-03:00 Adam Jackson <a...@nwnk.net>: > On Mon, 2016-02-15 at 11:32 -0200, Laércio de Sousa wrote: > > > Implement missing parts in kdrive evdev driver for > > correct update of evdev keyboard LEDs. > > Hah! I like how this was there and just not wired up. > > > +if (!ke) { > > +ErrorF("Can't update LEDs of disabled evdev keyboard %s.\n", > ki->path); > > +return; > > +} > > I'm not a fan of error messages for routine conditions. If this is > really a "shouldn't happen" case then fine, but it looks like this will > emit a message every time you have >=1 disabled keyboards and hit > CapsLock on an enabled keyboard. If I'm reading that correctly, can we > just drop this message? > > - ajax > -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v8 0/4] Xephyr input hot-plugging support and other additions for single-GPU multi-seat
2016-02-12 14:17 GMT-02:00 Laércio de Sousa < laercioso...@sme-mogidascruzes.sp.gov.br>: > - During tests, I realized that some issues regarding input > hot-plugging with evdev driver in kdrive only seems to affect > Debian/Ubuntu systems, so I've dropped some pieces of code written > to address such issues at upstream level. Comparing Debian/Ubuntu and openSUSE source packages for xorg-server, I've discovered that this FD unregistering issue was already fixed in commit 44d0fd435 <https://cgit.freedesktop.org/xorg/xserver/commit/?id=44d0fd435a4eaf45e252b4f00409152a6d599dfc>, released in version 1.18.1. This patch was backported to openSUSE's 1.17.2 package, but not to Ubuntu wily/xenial one. After backporting this patch to my xorg-server packages in Ubuntu Multiseat PPA, this problem has gone. -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 3/9] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
2016-02-11 19:35 GMT-02:00 Peter Hutterer <peter.hutte...@who-t.net>: > > I just checked the kernel sources and there is no specific error case that > this code can trigger, it's something to do with the fd itself (EBADF, > EPERM, etc.). I guess fd is already closed/reset by the time you get here. > What errno do you get? I've got EBADF (Bad File Descriptor). Anyway, I realized that this error message when trying to ungrab devices are unrelated to fd unregistering. I've modified EvdevPtrDisable/EvdevKbdDisable functions, making them call KdUnregisterFd *twice*. I don't know why, but it seems to solve my problem (my "garbage collector" no longer detect orphan fds left behind and my Xephyr no longer segfaults when I unplug/replug them). Some more details about my issues: 1. This problem with incomplete fd unregistering only affects the device with the *lowest* fd number (I've found it by swapping the keyboard and mouse connections in my USB hub). 2. When I unplug the device with the lowest fd number (e.g. mouse), the one with the highest fd number (e.g. keyboard) stops working. If I then unplug this highest fd device, it does *not* disappear from "xinput list". When I finally replug this device, it works again, but it appears "duplicated" in "xinput list", with another fd number. Example: ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ SIGMACHIP Usb Mouse id=6 [slave pointer (2)] ⎣ Virtual core keyboardid=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ HID 04f3:0103id=7 [slave keyboard (3)] ↳ HID 04f3:0103id=8 [slave keyboard (3)] Crazily, issue 2 above only seems to affect Debian/Ubuntu systems. I have another openSUSE box with Xephyr-based multi-seat configured, and it's not affected by issue 2. I'll do more tests with this openSUSE box to see if it's affected by issue 1. -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 3/9] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
I've just confirmed: my openSUSE box is *not* affected by fd unregistering issue. So I won't treat it as an upstream bug anymore, and I'll drop all additional verifications from this patch. 2016-02-12 10:13 GMT-02:00 Laércio de Sousa < laercioso...@sme-mogidascruzes.sp.gov.br>: > > 2016-02-11 19:35 GMT-02:00 Peter Hutterer <peter.hutte...@who-t.net>: >> >> I just checked the kernel sources and there is no specific error case that >> this code can trigger, it's something to do with the fd itself (EBADF, >> EPERM, etc.). I guess fd is already closed/reset by the time you get here. >> What errno do you get? > > I've got EBADF (Bad File Descriptor). Anyway, I realized that this error > message when trying to ungrab devices are unrelated to fd unregistering. > > I've modified EvdevPtrDisable/EvdevKbdDisable functions, making them call > KdUnregisterFd *twice*. I don't know why, but it seems to solve my problem > (my "garbage collector" no longer detect orphan fds left behind and my > Xephyr no longer segfaults when I unplug/replug them). > > Some more details about my issues: > > 1. This problem with incomplete fd unregistering only affects the device > with the *lowest* fd number (I've found it by swapping the keyboard and > mouse connections in my USB hub). > > 2. When I unplug the device with the lowest fd number (e.g. mouse), the > one with the highest fd number (e.g. keyboard) stops working. If I then > unplug this highest fd device, it does *not* disappear from "xinput list". > When I finally replug this device, it works again, but it appears > "duplicated" in "xinput list", with another fd number. Example: > > ⎡ Virtual core pointer id=2 [master pointer (3)] > ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] > ⎜ ↳ SIGMACHIP Usb Mouse id=6 [slave pointer (2)] > ⎣ Virtual core keyboardid=3 [master keyboard (2)] > ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] > ↳ HID 04f3:0103id=7 [slave keyboard (3)] > ↳ HID 04f3:0103id=8 [slave keyboard (3)] > > Crazily, issue 2 above only seems to affect Debian/Ubuntu systems. I have > another openSUSE box with Xephyr-based multi-seat configured, and it's not > affected by issue 2. I'll do more tests with this openSUSE box to see if > it's affected by issue 1. > -- > *Laércio de Sousa* > *Orientador de Informática* > *Escola Municipal "Professor Eulálio Gruppi"* > *Rua Ismael da Silva Mello, 559, Mogi Moderno* > *Mogi das Cruzes - SPCEP 08717-390* > Telefone: (11) 4726-8313 > -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v8 1/4] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
This patch introduces input hot-plugging support for kdrive-based applications in multi-seat context. This feature is enabled by passing -seat option with desired seat name. All keyboard/mouse devices assigned to that seat will be automatically grabbed by kdrive. It supports udev and hal backends for input hot-plugging support. Another patches may be required for wscons backend. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=33140 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/Makefile.am | 8 +++ hw/kdrive/src/kdrive.c| 46 + hw/kdrive/src/kinfo.c | 4 ++ hw/kdrive/src/kinput.c| 162 +++--- 4 files changed, 198 insertions(+), 22 deletions(-) diff --git a/hw/kdrive/src/Makefile.am b/hw/kdrive/src/Makefile.am index d69f0dd..b7f94b0 100644 --- a/hw/kdrive/src/Makefile.am +++ b/hw/kdrive/src/Makefile.am @@ -23,3 +23,11 @@ libkdrive_la_SOURCES = \ kshadow.c \ $(KDRIVE_XV_SOURCES) \ $(top_srcdir)/mi/miinitext.c + +if CONFIG_UDEV +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +else +if CONFIG_HAL +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +endif +endif diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index dddbe6e..1817303 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -45,6 +45,14 @@ #include +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include +#endif + +/* This stub can be safely removed once we can + * split input and GPU parts in hotplug.h et al. */ +#include + typedef struct _kdDepths { CARD8 depth; CARD8 bpp; @@ -1125,6 +1133,11 @@ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) KdAddScreen(pScreenInfo, screen, argc, argv); OsRegisterSigWrapper(KdSignalWrapper); + +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +if (SeatId) /* Enable input hot-plugging */ +config_pre_init(); +#endif } void @@ -1143,3 +1156,36 @@ DPMSSupported(void) { return FALSE; } + +/* These stubs can be safely removed once we can + * split input and GPU parts in hotplug.h et al. */ +#ifdef CONFIG_UDEV_KMS +void +NewGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} + +void +DeleteGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} +#endif + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor) +{ +return NULL; +} + +#ifdef SYSTEMD_LOGIND +void +systemd_logind_vtenter(void) +{ +} + +void +systemd_logind_release_fd(int major, int minor, int fd) +{ +close(fd); +} +#endif diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c index 01ae1e4..f91d575 100644 --- a/hw/kdrive/src/kinfo.c +++ b/hw/kdrive/src/kinfo.c @@ -134,6 +134,7 @@ KdFreePointer(KdPointerInfo * pi) free(pi->name); free(pi->path); input_option_free_list(>options); +pi->next = NULL; free(pi); } @@ -145,6 +146,9 @@ KdFreeKeyboard(KdKeyboardInfo * ki) free(ki->xkbRules); free(ki->xkbModel); free(ki->xkbLayout); +free(ki->xkbVariant); +free(ki->xkbOptions); +input_option_free_list(>options); ki->next = NULL; free(ki); } diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 3a1c6a0..e2c081e 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -51,6 +51,10 @@ #include "inpututils.h" #include "optionstr.h" +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include +#endif + #ifdef KDRIVE_EVDEV #define DEV_INPUT_EVENT_PREFIX "/dev/input/event" #define DEV_INPUT_EVENT_PREFIX_LEN (sizeof(DEV_INPUT_EVENT_PREFIX) - 1) @@ -407,7 +411,8 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff) #endif if (!pi->driver) { if (!pi->driverPrivate) { -ErrorF("no driver specified for %s\n", pi->name); +ErrorF("no driver specified for pointer device \"%s\" (%s)\n", + pi->name ? pi->name : "(unnamed)", pi->path); return BadImplementation; } @@ -727,7 +732,8 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) #endif if (!ki->driver) { if (!ki->driverPrivate) { -ErrorF("no driver specified!\n"); +ErrorF("no driver specified for keyboard device \"%s\" (%s)\n", + ki->name ? ki->name : "(unnamed)", ki->path); return BadImplementation; } @@ -901,6 +907,8 @@ KdNewKeyboard(void) ki->bellDuration = 200; ki->next = NULL; ki->options = NULL; +ki->name = strdup("Generic Keyboard"); +ki->path = NULL; ki->xkbRules = strdup(XKB_DFLT_RULES); ki->xkbModel = strdup(XKB_DFLT_MODEL); ki->
[PATCH kdrive/ephyr v8 3/4] ephyr: enable option -sw-cursor by default in multi-seat mode
Option -seat passed to Xephyr requires -sw-cursor to be passed as well, otherwise the mouse cursor will remain invisible for the given seat. This patch takes care of enabling -sw-cursor if -seat is passed. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyrinit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 849a4e1..149ea98 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -373,6 +373,9 @@ OsVendorInit(void) { EPHYR_DBG("mark"); +if (SeatId) +hostx_use_sw_cursor(); + if (hostx_want_host_cursor()) ephyrFuncs.initCursor = -- 2.7.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v8 0/4] Xephyr input hot-plugging support and other additions for single-GPU multi-seat
This is the v8 of patch series which provides some missing parts for full single-GPU multi-seat support in Xephyr. This version is mainly for fixing purposes, since most of v7 patches are already merged. The main differences to v7 are the following: * Some fixes and clean-ups in patch that introduces hot-plugging feature, following discussions with Adam Jackson, Peter Hutterer, and Emil Velikov. - During tests, I realized that some issues regarding input hot-plugging with evdev driver in kdrive only seems to affect Debian/Ubuntu systems, so I've dropped some pieces of code written to address such issues at upstream level. * Some fixes and cahges in patch that introduces command-line options -xkb-layout et al., following Hutterer's advices. * The patch with a workaround to make keyboard LEDs work properly in Xephyr was dropped for now. After discussing with Hutterer, I've decided to search for a better solution, which I'll submit in a second moment. * A new patch is introduced to enable option -sw-cursor by default if -seat is passed. Example of systemd service unit "xorg@.service" to launch a bare Xorg server to be used by Xephyr: [Unit] Description=Service for Xorg server at display :%i [Service] ExecStart=/usr/bin/X :%i -seat __fake-seat__ -dpms -s 0 -nocursor SuccessExitStatus=0 1 # Not needed if Xorg is to be started via # socket-activation (see xorg@.socket below) [Install] WantedBy=display-manager.service NOTE: in this example, __fake-seat__ is a trick to ensure this bare Xorg server will neither touch VTs (like a seat0 X server does) nor grab input devices (like a non-seat0 X server does). Example of systemd socket unit "xorg@.socket" to be used in conjunction with service unit above (if Xorg was built with systemd socket-activation support): [Unit] Description=Socket for Xorg server at display :%i [Socket] ListenStream=/tmp/.X11-unix/X%i [Install] WantedBy=sockets.target Example of Xephyr-based seat configuration in LightDM 1.12 and newer, based on this patch series (provided that a bare X server on display number :90, with two outputs named LVDS and VGA, is already running): [Seat:seat-LVDS] xserver-command=env DISPLAY=:90 Xephyr -xkb-rules evdev -xkb-layout br -xkb-model abnt2 -output LVDS [Seat:seat-VGA] xserver-command=env DISPLAY=:90 Xephyr -xkb-rules evdev -xkb-layout br -xkb-model abnt2 -output VGA ** IDEAS FOR FURTHER STEPS ** * Write a new input driver for kdrive, based on libinput (or find a way to share the same input drivers between kdrive and Xorg itself). * Bring InputClass matching rules support (or something similar) to kdrive, so we don't need to rely on e.g. udev rules to retrieve XKB preperties. * Eventually search for a better integration with systemd-logind, so that Xephyr can be started in multi-seat mode without root privileges (may require root-less Xorg support in display managers). ** HISTORY ** In v7, ephyr input driver for kdrive won't be loaded in multi-seat mode, i.e. if -seat option is passed to Xephyr, so that it'll handle only its seat's input hardware. In this version, we've also dropped patch to add command-line options -host-display and -host-auth for Xephyr (use "env DISPLAY=... XAUTHORITY=... Xephyr" instead). v6 adds "-novtswitch" to the list of command-line arguments ignored by Xephyr. v5 only builds input hot-plugging for kdrive if one of CONFIG_UDEV or CONFIG_HAL options is enabled. v4 drops explicit option -input-hotplug. Since input hot-plugging support in Xephyr is very unlikely to be used outside multi-seat context, it's now automatically enabled if, and only if, -seat option is passed. v3 includes two patches: one that introduces a new flag to better distinguish between real keyboards and other key input devices (so that kdrive can grab keyboards only), and another one that prevents kdrive evdev driver from deliberately renaming keyboard and pointer devices if they are already named (e.g. from udev), with potential memory leaks. v2 fixes some problems found in v1, like double-free errors for some InputOption objects, and memory corruptions when a USB keyboard or mouse is unplugged and replugged several times, due to the fact that their FDs may not be successfully unregistered when they are unplugged. It also brings new patches for improving NewInputDeviceRequest() implementation in hw/kdrive/src/kinput.c (making use of KdParseKbdOptions() and KdParsePointerOptions() as requested), and some other minor changes. Some patches provide new command-line options to make it easier to launch Xephyr directly from display manager, rather than from within a user session. The most significant one introduces input hotplugging support for keyboards and pointers with both hal and udev backends. Laércio de Sousa (4): kdrive: introduce input hot-plugging support for udev and hal bac
[PATCH kdrive/ephyr v8 4/4] config/udev: better distinguish between real keyboards and other key input devices
This patch introduces a new flag ATTR_KEY for hotplugged input devices, so we can better distinguish between real keyboards (i.e. devices with udev property ID_INPUT_KEYBOARD="1") and other key input devices like lid switches, power buttons, etc. All supported hotplug backends (udev, hal, and wscons) will set both flags ATTR_KEY and ATTR_KEYBOARD for real keyboards, but udev backend will set ATTR_KEY, but not ATTR_KEYBOARD, for non-keyboard key input devices (hal and wscons will set both flags in any case). With this distinction, kdrive input hotplugging mechanism will be allowed to only grab real keyboards, as other key input devices are currently not supported. In order to don't break current behaviour, this patch will replace all ATTR_KEYBOARD occurrences with ATTR_KEY in hw/xfree86/common/xf86Xinput.c. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- config/hal.c | 2 +- config/udev.c | 4 config/wscons.c| 2 +- hw/kdrive/src/kinput.c | 4 +++- hw/xfree86/common/xf86Xinput.c | 2 +- include/input.h| 13 +++-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/config/hal.c b/config/hal.c index ea574ca..c76eced 100644 --- a/config/hal.c +++ b/config/hal.c @@ -170,7 +170,7 @@ device_added(LibHalContext * hal_ctx, const char *udi) free(hal_tags); if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL)) -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; if (libhal_device_query_capability(hal_ctx, udi, "input.mouse", NULL)) attrs.flags |= ATTR_POINTER; if (libhal_device_query_capability(hal_ctx, udi, "input.joystick", NULL)) diff --git a/config/udev.c b/config/udev.c index 08a954b..1a6e82a 100644 --- a/config/udev.c +++ b/config/udev.c @@ -240,6 +240,10 @@ device_added(struct udev_device *udev_device) } else if (!strcmp(key, "ID_INPUT_KEY")) { LOG_PROPERTY(path, key, value); +attrs.flags |= ATTR_KEY; +} +else if (!strcmp(key, "ID_INPUT_KEYBOARD")) { +LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; } else if (!strcmp(key, "ID_INPUT_MOUSE")) { diff --git a/config/wscons.c b/config/wscons.c index fb114bd..ee45675 100644 --- a/config/wscons.c +++ b/config/wscons.c @@ -163,7 +163,7 @@ wscons_add_keyboard(void) } kbd_config_done: -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; rc = NewInputDeviceRequest(input_options, , ); if (rc != Success) goto unwind; diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index e4966b7..958117b 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -2343,7 +2343,9 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, *pdev = ki->dixdev; } else { -ErrorF("unrecognised device identifier!\n"); +ErrorF("unrecognised device identifier: %s\n", + input_option_get_value(input_option_find(optionsdup, +"device"))); input_option_free_list(); return BadValue; } diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index a9ce62a..4f2e6c8 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -635,7 +635,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev, /* MatchIs* booleans */ if (iclass->is_keyboard.set && -iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEYBOARD)) +iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEY)) return FALSE; if (iclass->is_pointer.set && iclass->is_pointer.val != ! !(attrs->flags & ATTR_POINTER)) diff --git a/include/input.h b/include/input.h index d8bd9c6..19ef0c9 100644 --- a/include/input.h +++ b/include/input.h @@ -230,12 +230,13 @@ typedef struct _InputAttributes { uint32_t flags; } InputAttributes; -#define ATTR_KEYBOARD (1<<0) -#define ATTR_POINTER (1<<1) -#define ATTR_JOYSTICK (1<<2) -#define ATTR_TABLET (1<<3) -#define ATTR_TOUCHPAD (1<<4) -#define ATTR_TOUCHSCREEN (1<<5) +#define ATTR_KEY (1<<0) +#define ATTR_KEYBOARD (1<<1) +#define ATTR_POINTER (1<<2) +#define ATTR_JOYSTICK (1<<3) +#define ATTR_TABLET (1<<4) +#define ATTR_TOUCHPAD (1<<5) +#define ATTR_TOUCHSCREEN (1<<6) /* Key/Button has been run through all input processing and events sent to clients. */ #define KEY_PROCESSED 1 -- 2.7.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v8 2/4] kdrive: add options to set default XKB properties
This patch introduces convenient command-line options -xkb-rules, -xkb-model, -xkb-layout, -xkb-variant, and -xkb-options, to set default values for these properties. These options can be handful for cases in which compile-time default values don't match user locale, since kdrive doesn't support InputClass matching rules yet and not all Linux distros provide default rules to store these values in udev properties (which by the way is a discouraged practice). Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/kdrive.c | 50 ++ hw/kdrive/src/kinput.c | 16 +++- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 1817303..49064ef 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -89,6 +89,11 @@ char *kdSwitchCmd; DDXPointRec kdOrigin; Bool kdHasPointer = FALSE; Bool kdHasKbd = FALSE; +const char *kdGlobalXkbRules = NULL; +const char *kdGlobalXkbModel = NULL; +const char *kdGlobalXkbLayout = NULL; +const char *kdGlobalXkbVariant = NULL; +const char *kdGlobalXkbOptions = NULL; static Bool kdCaughtSignal = FALSE; @@ -455,6 +460,11 @@ KdUseMsg(void) ("-mouse driver [,n,,options]Specify the pointer driver and its options (n is the number of buttons)\n"); ErrorF ("-keybd driver [,,options] Specify the keyboard driver and its options\n"); +ErrorF("-xkb-rules Set default XkbRules value (can be overriden by -keybd options)\n"); +ErrorF("-xkb-model Set default XkbModel value (can be overriden by -keybd options)\n"); +ErrorF("-xkb-layout Set default XkbLayout value (can be overriden by -keybd options)\n"); +ErrorF("-xkb-variant Set default XkbVariant value (can be overriden by -keybd options)\n"); +ErrorF("-xkb-options Set default XkbOptions value (can be overriden by -keybd options)\n"); ErrorF("-zaphod Disable cursor screen switching\n"); ErrorF("-2button Emulate 3 button mouse\n"); ErrorF("-3button Disable 3 button mouse emulation\n"); @@ -563,6 +573,46 @@ KdProcessArgument(int argc, char **argv, int i) sscanf(argv[i], "vt%2d", ) == 1) { return 1; } +if (!strcmp(argv[i], "-xkb-rules")) { +if (i + 1 >= argc) { +UseMsg(); +FatalError("Missing argument for option -xkb-rules.\n"); +} +kdGlobalXkbRules = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkb-model")) { +if (i + 1 >= argc) { +UseMsg(); +FatalError("Missing argument for option -xkb-model.\n"); +} +kdGlobalXkbModel = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkb-layout")) { +if (i + 1 >= argc) { +UseMsg(); +FatalError("Missing argument for option -xkb-layout.\n"); +} +kdGlobalXkbLayout = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkb-variant")) { +if (i + 1 >= argc) { +UseMsg(); +FatalError("Missing argument for option -xkb-variant.\n"); +} +kdGlobalXkbVariant = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkb-options")) { +if (i + 1 >= argc) { +UseMsg(); +FatalError("Missing argument for option -xkb-options.\n"); +} +kdGlobalXkbOptions = argv[i + 1]; +return 2; +} if (!strcmp(argv[i], "-mouse") || !strcmp(argv[i], "-pointer")) { if (i + 1 >= argc) UseMsg(); diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index e2c081e..e4966b7 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -102,6 +102,12 @@ static int kdNumInputFds; extern Bool kdRawPointerCoordinates; +extern const char *kdGlobalXkbRules; +extern const char *kdGlobalXkbModel; +extern const char *kdGlobalXkbLayout; +extern const char *kdGlobalXkbVariant; +extern const char *kdGlobalXkbOptions; + static void KdSigio(int sig) { @@ -909,11 +915,11 @@ KdNewKeyboard(void) ki->options = NULL; ki->name = strdup("Generic Keyboard"); ki->path = NULL; -ki->xkbRules = strdup(XKB_DFLT_RULES); -ki->xkbModel = strdup(XKB_DFLT_MODEL); -ki->xkbLayout = strdup(XKB_DFLT_LAYOUT); -ki->xkbVariant = strdup(XKB_DFLT_VARIANT); -ki->xkbOptions = strdup(XKB_DFLT_OPTIONS); +ki->xkbRules = strdup(kdGlobalXkbRules ? kdGlobalXkbRules : XKB_DFLT_RULES); +ki->xkbModel = strdup(kdGlobalXkbModel ? kdGlobalXkbModel : XKB_DFLT_MODEL); +
Re: [PATCH kdrive/ephyr v7 3/9] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
2016-02-11 0:56 GMT-02:00 Peter Hutterer <peter.hutte...@who-t.net>: > we don't have a 1:1 mapping between devices and fd (e.g. wacom devices all > hang off a single fd). Even the fd itself is a DDX concept, so RemoveDevice > cannot close the fd. > > What should happen here though is that the pDev->public.devicePrivate > points > to something kdrive understands and that includes the fd. > Reading kdrive evdev sources, I've found that EvdevPtrDisable/EvdevKbdDisable functions do have a KdUnregisterFd() call. Example: static void EvdevPtrDisable(KdPointerInfo * pi) { Kevdev *ke; ke = pi->driverPrivate; if (!pi || !pi->driverPrivate) return; KdUnregisterFd(pi, ke->fd, TRUE); if (ioctl(ke->fd, EVIOCGRAB, 0) < 0) perror("Ungrabbing evdev mouse device failed"); free(ke); pi->driverPrivate = 0; } However, it seems to fail in my system, because I always get that "Ungrabbing evdev mouse device failed" error message. -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 3/9] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
2016-02-11 8:23 GMT-02:00 Laércio de Sousa < laercioso...@sme-mogidascruzes.sp.gov.br>: > 2016-02-11 0:56 GMT-02:00 Peter Hutterer <peter.hutte...@who-t.net>: > >> we don't have a 1:1 mapping between devices and fd (e.g. wacom devices all >> hang off a single fd). Even the fd itself is a DDX concept, so >> RemoveDevice >> cannot close the fd. >> >> What should happen here though is that the pDev->public.devicePrivate >> points >> to something kdrive understands and that includes the fd. >> > Reading kdrive evdev sources, I've found that > EvdevPtrDisable/EvdevKbdDisable functions > do have a KdUnregisterFd() call. Example: > > static void > EvdevPtrDisable(KdPointerInfo * pi) > { > Kevdev *ke; > > ke = pi->driverPrivate; > > if (!pi || !pi->driverPrivate) > return; > > KdUnregisterFd(pi, ke->fd, TRUE); > > if (ioctl(ke->fd, EVIOCGRAB, 0) < 0) > perror("Ungrabbing evdev mouse device failed"); > > free(ke); > pi->driverPrivate = 0; > } > > However, it seems to fail in my system, because I always get > that "Ungrabbing evdev mouse device failed" error message. > I'm convincing myself this is more a ploblem with kdrive evdev driver than with kdrive itself, so I'm tempted to keep that code in DeleteInputDeviceRequest() as is, with a mention that it's a kind of "safety measure against buggy drivers". What do you think? -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 3/9] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
2016-02-08 17:45 GMT-02:00 Adam Jackson <a...@nwnk.net>: > > This introduces a warning: > > kdrive.c:1217:1: warning: no previous prototype for > 'systemd_logind_release_fd' [-Wmissing-prototypes] > systemd_logind_release_fd(int _major, int _minor, int fd) > ^ > kdrive.c:1222:1: warning: no previous prototype for > 'systemd_logind_vtenter' [-Wmissing-prototypes] > systemd_logind_vtenter(void) ^ > OK. I've just introduced the prototypes in kdrive.c itself (so I don't need to #include ). These warnings are now gone. This seems like the sort of comment where the act of writing it is a > sign that the code must be wrong. Why is RemoveDevice not closing the > fd for you? > I'm not sure why it happens, but without this "redundant" check around RemoveDevice(), if I unplug the mouse, replug it and start moving it, Xephyr segfaults. -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 4/9] kdrive: update evdev keyboard LEDs (#22302)
This is the output of command "xinput list" for my latest Xephyr in multi-seat mode *without* this patch applied. ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ SIGMACHIP Usb Mouse id=6 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ HID 04f3:0103 id=7 [slave keyboard (3)] In this scenario, when I toggle NumLock or CapsLock, the keyboard reacts as expected (I mean, I can enable CapsLock and start typing capital letters, and I can enable NumLock and start typing numbers in my num pad), but the keyboard LED's are always *off*. 2016-02-08 17:52 GMT-02:00 Adam Jackson <a...@nwnk.net>: > On Fri, 2015-12-11 at 11:43 -0200, Laércio de Sousa wrote: > > From: Mikhail Krivtsov <mikhail.krivt...@gmail.com> > > > > When one hits {Num,Caps,Scroll}Lock key on a Xephyr's keyboard, > > keyboard itself works as expected but LEDs are not updated > > and always stay in off. > > > > Currently logical LEDs are propagated to physical keyboard LEDs > > for "CoreKeyboard" only. All "kdrive" keyboards are not > > "CoreKeyboard" and LEDs of "kdrive" keyboards are always "dead". > > > > One possible solution is cloning "CoreKeyboard" LEDs to all > > "kdrive" keyboards. > > Can you describe this scenario better? What does the output of 'xinput > list' look like when you encounter this? > > - ajax > -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 5/9] kdrive: add options to set default XKB properties
Em 9 de fev de 2016 05:49, "Peter Hutterer" <peter.hutte...@who-t.net> escreveu: > > On Tue, Feb 09, 2016 at 05:40:26AM -0200, Laércio de Sousa wrote: > > Em 9 de fev de 2016 02:24, "Peter Hutterer" <peter.hutte...@who-t.net> > > escreveu: > > > > > > On Fri, Dec 11, 2015 at 11:43:10AM -0200, Laércio de Sousa wrote: > > > > This patch introduces convenient command-line options -xkbrules, > > > > -xkbmodel, -xkblayout, -xkbvariant, and -xkboptions, to set default > > > > values for these properties. > > > > > > > > These options can be handful in cases where corresponding values can't > > > > be taken from devices' udev properties, and compile-time default > > > > values don't match user locale. > > > > > > > > Signed-off-by: Laércio de Sousa < > > laercioso...@sme-mogidascruzes.sp.gov.br> > > > > --- > > > > hw/kdrive/src/kdrive.c | 40 > > > > hw/kdrive/src/kinput.c | 16 +++- > > > > 2 files changed, 51 insertions(+), 5 deletions(-) > > > > > > > > diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c > > > > index 8930ace..1578458 100644 > > > > --- a/hw/kdrive/src/kdrive.c > > > > +++ b/hw/kdrive/src/kdrive.c > > > > @@ -85,6 +85,11 @@ char *kdSwitchCmd; > > > > DDXPointRec kdOrigin; > > > > Bool kdHasPointer = FALSE; > > > > Bool kdHasKbd = FALSE; > > > > +const char *kdGlobalXkbRules = NULL; > > > > +const char *kdGlobalXkbModel = NULL; > > > > +const char *kdGlobalXkbLayout = NULL; > > > > +const char *kdGlobalXkbVariant = NULL; > > > > +const char *kdGlobalXkbOptions = NULL; > > > > > > > > static Bool kdCaughtSignal = FALSE; > > > > > > > > @@ -451,6 +456,11 @@ KdUseMsg(void) > > > > ("-mouse driver [,n,,options]Specify the pointer driver > > and its options (n is the number of buttons)\n"); > > > > ErrorF > > > > ("-keybd driver [,,options] Specify the keyboard driver > > and its options\n"); > > > > +ErrorF("-xkbrulesSet default XkbRules value (can be > > overriden by -keybd options)\n"); > > > > +ErrorF("-xkbmodelSet default XkbModel value (can be > > overriden by -keybd options)\n"); > > > > +ErrorF("-xkblayout Set default XkbLayout value (can be > > overriden by -keybd options)\n"); > > > > +ErrorF("-xkbvariant Set default XkbVariant value (can be > > overriden by -keybd options)\n"); > > > > +ErrorF("-xkboptions Set default XkbOptions value (can be > > overriden by -keybd options)\n"); > > > > ErrorF("-zaphod Disable cursor screen switching\n"); > > > > ErrorF("-2button Emulate 3 button mouse\n"); > > > > ErrorF("-3button Disable 3 button mouse emulation\n"); > > > > @@ -559,6 +569,36 @@ KdProcessArgument(int argc, char **argv, int i) > > > > sscanf(argv[i], "vt%2d", ) == 1) { > > > > return 1; > > > > } > > > > +if (!strcmp(argv[i], "-xkbrules")) { > > > > +if (i + 1 >= argc) > > > > +UseMsg(); > > > > > > afaict UseMsg() doesn't actually exist, so you're accessing invalid memory > > > here. > > Many other kdrive-related command-line options call UseMsg() as well --- > > which in turn calls KdUseMsg(). > > urgh, sorry, typo: this should've read "exit", not "exist". All the other ones > work because they don't access the args after the UseMsg() call. Hmm... You're right. I've just read another patch I wrote for this series (which would introduce a new -host-display option to set DISPLAY in Xephyr environment, but I've dropped it): in that onde there was a exit(1) call after UseMsg(). I'll work on it when I come back to work tomorrow. Att. ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 5/9] kdrive: add options to set default XKB properties
Em 9 de fev de 2016 02:24, "Peter Hutterer"escreveu: > when we introduced the udev config backend we mostly agreed that we weren't > going to use udev as a config storage (which is how InputClass was > conceived). Debian ships them because there was some release timing conflict > where the udev patches where ready but the InputClass bits weren't but aside > from Debian I don't expect any distro to set the xkb config via udev. I wonder if kdrive could gain InputClass support, a new libinput driver or even share the same input drivers with Xorg itself, but I'm aware that hardware input direct support in kdrive is for a very particular use case (although it has a very large demand here in Brazil), so I would let this for a second moment. ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 0/9] Xephyr input hot-plugging support and other additions for single-GPU multi-seat
Thank you very much, Adam! I'll take a better look on remaining patches on Wednesday or Thursday and give you an answer ASAP. Kind regards. Em 8 de fev de 2016 18:13, "Adam Jackson" <a...@nwnk.net> escreveu: > On Fri, 2015-12-11 at 11:43 -0200, Laércio de Sousa wrote: > > > This is the v7 of patch series which provides some missing parts > > for full single-GPU multi-seat support in Xephyr. The main difference > > to v6 is that now ephyr input driver for kdrive won't be loaded > > in multi-seat mode, i.e. if -seat option is passed to Xephyr, so that > > it'll handle only its seat's input hardware. In this version, we've > > also dropped patch to add command-line options -host-display and > > -host-auth for Xephyr (use "env DISPLAY=... XAUTHORITY=... Xephyr" > instead). > > Apologies for being unbelievably slow to review this. 1 2 6 8 and 9 of > this series look fine, merged: > > To ssh://git.freedesktop.org/git/xorg/xserver >2c3e876..da69f2f master -> master > > 3 through 5 I have some concerns about (sent separately) and I also > dropped 7 since it didn't apply with those skipped. > > - ajax > ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH kdrive/ephyr v7 5/9] kdrive: add options to set default XKB properties
Em 8 de fev de 2016 17:54, "Adam Jackson"escreveu: > How are you in a scenario where you can pass these values to Xephyr on > the command line, but can't modify the udev properties? Well... What I really mean is a scenario where neither the Linux distro, nor the keyboard vendor, nor the sysadmin him(her)self provides any udev rules to set XKB properties. For example, I know there are some distros that ship a set of default udev rules to set XKB properties, but not all of them do it (at least the one I used when I wrote this patch didn't). ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 6/9] kdrive: don't let evdev driver overwrite existing device names
KDrive evdev driver deliberately name grabbed devices as "Evdev mouse" or "Evdev keyboard". This patch will make it skip this step if grabbed devices are already named (i.e. from udev). Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/linux/evdev.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c index fecbae4..57a6dbf 100644 --- a/hw/kdrive/linux/evdev.c +++ b/hw/kdrive/linux/evdev.c @@ -220,7 +220,8 @@ EvdevPtrInit(KdPointerInfo * pi) close(fd); -pi->name = strdup("Evdev mouse"); +if (!pi->name) +pi->name = strdup("Evdev mouse"); return Success; } @@ -390,7 +391,8 @@ EvdevKbdInit(KdKeyboardInfo * ki) close(fd); -ki->name = strdup("Evdev keyboard"); +if (!ki->name) +ki->name = strdup("Evdev keyboard"); readMapping(ki); -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 4/9] kdrive: update evdev keyboard LEDs (#22302)
From: Mikhail Krivtsov <mikhail.krivt...@gmail.com> When one hits {Num,Caps,Scroll}Lock key on a Xephyr's keyboard, keyboard itself works as expected but LEDs are not updated and always stay in off. Currently logical LEDs are propagated to physical keyboard LEDs for "CoreKeyboard" only. All "kdrive" keyboards are not "CoreKeyboard" and LEDs of "kdrive" keyboards are always "dead". One possible solution is cloning "CoreKeyboard" LEDs to all "kdrive" keyboards. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=22302 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/linux/evdev.c | 11 --- hw/kdrive/src/kinput.c | 23 +++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c index 63e8409..fecbae4 100644 --- a/hw/kdrive/linux/evdev.c +++ b/hw/kdrive/linux/evdev.c @@ -440,10 +440,16 @@ EvdevKbdEnable(KdKeyboardInfo * ki) static void EvdevKbdLeds(KdKeyboardInfo * ki, int leds) { -/*struct input_event event; +struct input_event event; Kevdev *ke; +if (!ki) return; // This shouldn't happen but just for safety. -ki->driverPrivate = ke; +ke = ki->driverPrivate; +if (!ke) { + ErrorF("[%s:%u:%s] can't update LEDs of _disabled_ evdev keyboard\n", + __FILE__, __LINE__, __FUNCTION__); + return; +} memset(, 0, sizeof(event)); @@ -466,7 +472,6 @@ EvdevKbdLeds(KdKeyboardInfo * ki, int leds) event.code = LED_COMPOSE; event.value = leds & (1 << 3) ? 1 : 0; write(ke->fd, (char *) , sizeof(event)); -*/ } static void diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 682b63a..e9a5f24 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -618,6 +618,28 @@ KdSetLed(KdKeyboardInfo * ki, int led, Bool on) KdSetLeds(ki, ki->dixdev->kbdfeed->ctrl.leds); } +/* + * For unknown reason, logical keyboard LEDs are propagated to physical + * keyboard LEDs for "CoreKeyboard" only. All "kdrive" keyboards are + * not "CoreKeyboard" and LEDs of "kdrive" keyboards are always "dead". + * As workaround, the following function will clone "CoreKeyboard" LEDs + * to all "kdrive" keyboards. + */ +static void +KdCloneCoreLEDs(void) +{ +DeviceIntPtr pCoreKeyboard = inputInfo.keyboard; +if (pCoreKeyboard && pCoreKeyboard->kbdfeed) { + Leds leds = pCoreKeyboard->kbdfeed->ctrl.leds; + KdKeyboardInfo *tmp; + for (tmp = kdKeyboards; tmp; tmp = tmp->next) { + if (tmp->leds != leds) { +KdSetLeds(tmp, tmp->leds = leds); + } +} +} +} + void KdSetPointerMatrix(KdPointerMatrix * matrix) { @@ -2163,6 +2185,7 @@ ProcessInputEvents(void) if (kdSwitchPending) KdProcessSwitch(); KdCheckLock(); +KdCloneCoreLEDs(); } /* At the moment, absolute/relative is up to the client. */ -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 8/9] ephyr: ignore "-novtswitch", "-sharevts", and "-layout seatXXX" command-line options
Multi-seat-capable display managers commonly pass command-line options like "-novtswitch", "-sharevts", or "-layout seat" to Xorg server, but Xephyr currently refuses to start if these options are passed to it, which may break Xephyr-based single-GPU multiseat setups. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyrinit.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index d86baf2..09ada96 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -369,6 +369,13 @@ ddxProcessArgument(int argc, char **argv, int i) EphyrWantNoHostGrab = 1; return 1; } +else if (!strcmp(argv[i], "-sharevts") || + !strcmp(argv[i], "-novtswitch")) { +return 1; +} +else if (!strcmp(argv[i], "-layout")) { +return 2; +} return KdProcessArgument(argc, argv, i); } -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 0/9] Xephyr input hot-plugging support and other additions for single-GPU multi-seat
PLEASE NOTE: Xephyr is NOT my preferred approach for single-GPU multi-seat configuration (mainly due to its current evdev-based limited support for handling input devices --- no touchpads, no touchscreens, no joysticks), but it's the easiest one to implement in the moment. The best approach by far (in Linux specifically) would require KMS device node splitting, as proposed in https://dvdhrm.wordpress.com/2013/09/01/splitting-drm-and-kms-device-nodes/. Until such a solution is completely implemented and supported by video drivers, the most common approach for single-GPU multi-seat configuration is based on nested X servers, i.e. a bare Xorg server spanning all desired video outputs, on top of which we launch a nested X server for each output. My preferred approach in this case would be Xorg itself with xf86-video-nested driver, but the latter is currently unmaintained, and I have no knowledge about video drivers and no spare time to maintain it. The other approach (historically the most used one) is Xephyr: it's currently actively maintained, it has reasonable graphics performance (compared to xf86-video-nested) and it has a minimal support for input devices (keyboard and mouse only), but it still have some gaps for a more comfortable multi-seat configuration. This patch series intend to fill them. This is the v7 of patch series which provides some missing parts for full single-GPU multi-seat support in Xephyr. The main difference to v6 is that now ephyr input driver for kdrive won't be loaded in multi-seat mode, i.e. if -seat option is passed to Xephyr, so that it'll handle only its seat's input hardware. In this version, we've also dropped patch to add command-line options -host-display and -host-auth for Xephyr (use "env DISPLAY=... XAUTHORITY=... Xephyr" instead). Example of Xephyr-based seat configuration in LightDM 1.12 or newer based on this patch series (provided that a bare X server on display number :90, with two outputs named LVDS and VGA, is already running): [Seat:seat-LVDS] xserver-command=env DISPLAY=:90 Xephyr -dpi 96 -sw-cursor -xkbrules evdev -xkblayout br -xkbmodel abnt2 -output LVDS [Seat:seat-VGA] xserver-command=evn DISPLAY=:90 Xephyr -dpi 96 -sw-cursor -xkbrules evdev -xkblayout br -xkbmodel abnt2 -output VGA ** HISTORY ** v6 adds "-novtswitch" to the list of command-line arguments ignored by Xephyr. v5 only builds input hot-plugging for kdrive if one of CONFIG_UDEV or CONFIG_HAL options is enabled. v4 drops explicit option -input-hotplug. Since input hot-plugging support in Xephyr is very unlikely to be used outside multi-seat context, it's now automatically enabled if, and only if, -seat option is passed. v3 includes two patches: one that introduces a new flag to better distinguish between real keyboards and other key input devices (so that kdrive can grab keyboards only), and another one that prevents kdrive evdev driver from deliberately renaming keyboard and pointer devices if they are already named (e.g. from udev), with potential memory leaks. v2 fixes some problems found in v1, like double-free errors for some InputOption objects, and memory corruptions when a USB keyboard or mouse is unplugged and replugged several times, due to the fact that their FDs may not be successfully unregistered when they are unplugged. It also brings new patches for improving NewInputDeviceRequest() implementation in hw/kdrive/src/kinput.c (making use of KdParseKbdOptions() and KdParsePointerOptions() as requested), and some other minor changes. Some patches provide new command-line options to make it easier to launch Xephyr directly from display manager, rather than from within a user session. One of them fixes an issue where Xephyr keyboards' LEDs are not toggled when NumLock, CapsLock, and ScrollLock are pressed. The most significant one introduces input hotplugging support for keyboards and pointers with both hal and udev backends. Laércio de Sousa (8): kdrive: fix up NewInputDeviceRequest() implementation kdrive: set "evdev" driver for input devices automatically, if available. kdrive: introduce input hot-plugging support for udev and hal backends (#33140) kdrive: add options to set default XKB properties kdrive: don't let evdev driver overwrite existing device names config/udev: better distinguish between real keyboards and other key input devices ephyr: ignore "-novtswitch", "-sharevts", and "-layout seatXXX" command-line options ephyr: don't load ephyr input driver if -seat option is passed Mikhail Krivtsov (1): kdrive: update evdev keyboard LEDs (#22302) config/hal.c | 2 +- config/udev.c | 4 + config/wscons.c| 2 +- hw/kdrive/ephyr/ephyrinit.c| 42 +++-- hw/kdrive/linux/evdev.c| 17 +- hw/kdrive/src/Makefile.am | 8 + hw/kdrive/src/kdrive.c | 79 ++ hw/kdrive/src/ki
[PATCH kdrive/ephyr v7 1/9] kdrive: fix up NewInputDeviceRequest() implementation
This patch simplifies NewInputDeviceRequest() implementation in kinput.c, making use of improved KdParseKbdOptions()/KdParsePointerOptions() and merging several "if (ki)"/"if (pi)" clauses. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/kinput.c | 76 -- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 1fdaa52..980fd3e 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -1091,6 +1091,8 @@ KdParseKbdOptions(KdKeyboardInfo * ki) ki->xkbOptions = strdup(value); else if (!strcasecmp(key, "device")) ki->path = strdup(value); +else if (!strcasecmp(key, "driver")) +ki->driver = KdFindKeyboardDriver(value); else ErrorF("Kbd option key (%s) of value (%s) not assigned!\n", key, value); @@ -1171,18 +1173,20 @@ KdParsePointerOptions(KdPointerInfo * pi) const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); -if (!strcmp(key, "emulatemiddle")) +if (!strcasecmp(key, "emulatemiddle")) pi->emulateMiddleButton = TRUE; -else if (!strcmp(key, "noemulatemiddle")) +else if (!strcasecmp(key, "noemulatemiddle")) pi->emulateMiddleButton = FALSE; -else if (!strcmp(key, "transformcoord")) +else if (!strcasecmp(key, "transformcoord")) pi->transformCoordinates = TRUE; -else if (!strcmp(key, "rawcoord")) +else if (!strcasecmp(key, "rawcoord")) pi->transformCoordinates = FALSE; else if (!strcasecmp(key, "device")) pi->path = strdup(value); else if (!strcasecmp(key, "protocol")) pi->protocol = strdup(value); +else if (!strcasecmp(key, "driver")) +pi->driver = KdFindPointerDriver(value); else ErrorF("Pointer option key (%s) of value (%s) not assigned!\n", key, value); @@ -2152,68 +2156,48 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, #endif } -if (!ki && !pi) { -ErrorF("unrecognised device identifier!\n"); -return BadValue; -} - -/* FIXME: change this code below to use KdParseKbdOptions and - * KdParsePointerOptions */ -nt_list_for_each_entry(option, options, list.next) { -const char *key = input_option_get_key(option); -const char *value = input_option_get_value(option); +if (pi) { +pi->options = options; +KdParsePointerOptions(pi); -if (strcmp(key, "device") == 0) { -if (pi && value) -pi->path = strdup(value); -else if (ki && value) -ki->path = strdup(value); -} -else if (strcmp(key, "driver") == 0) { -if (pi) { -pi->driver = KdFindPointerDriver(value); -if (!pi->driver) { -ErrorF("couldn't find driver!\n"); -KdFreePointer(pi); -return BadValue; -} -pi->options = options; -} -else if (ki) { -ki->driver = KdFindKeyboardDriver(value); -if (!ki->driver) { -ErrorF("couldn't find driver!\n"); -KdFreeKeyboard(ki); -return BadValue; -} -ki->options = options; -} +if (!pi->driver) { +ErrorF("couldn't find driver!\n"); +KdFreePointer(pi); +return BadValue; } -} -if (pi) { if (KdAddPointer(pi) != Success || ActivateDevice(pi->dixdev, TRUE) != Success || EnableDevice(pi->dixdev, TRUE) != TRUE) { ErrorF("couldn't add or enable pointer\n"); return BadImplementation; } + +*pdev = pi->dixdev; } else if (ki) { +ki->options = options; +KdParseKbdOptions(ki); + +if (!ki->driver) { +ErrorF("couldn't find driver!\n"); +KdFreeKeyboard(ki); +return BadValue; +} + if (KdAddKeyboard(ki) != Success || ActivateDevice(ki->dixdev, TRUE) != Success || EnableDevice(ki->dixdev, TRUE) != TRUE) { ErrorF("couldn't add or enable keyboard\n"); return BadImplementation; } -} -if (p
[PATCH kdrive/ephyr v7 2/9] kdrive: set "evdev" driver for input devices automatically, if available.
If kdrive input driver "evdev" is available, no other driver was explicitly set for a given input device, and its kernel device node is /dev/input/event*, this patch will make kdrive set "evdev" driver automatically for such device. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/kinput.c | 25 + 1 file changed, 25 insertions(+) diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 980fd3e..3a1c6a0 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -51,6 +51,11 @@ #include "inpututils.h" #include "optionstr.h" +#ifdef KDRIVE_EVDEV +#define DEV_INPUT_EVENT_PREFIX "/dev/input/event" +#define DEV_INPUT_EVENT_PREFIX_LEN (sizeof(DEV_INPUT_EVENT_PREFIX) - 1) +#endif + #define AtomFromName(x) MakeAtom(x, strlen(x), 1) struct KdConfigDevice { @@ -1097,6 +1102,16 @@ KdParseKbdOptions(KdKeyboardInfo * ki) ErrorF("Kbd option key (%s) of value (%s) not assigned!\n", key, value); } + +#ifdef KDRIVE_EVDEV +if (!ki->driver && ki->path != NULL && +strncasecmp(ki->path, +DEV_INPUT_EVENT_PREFIX, +DEV_INPUT_EVENT_PREFIX_LEN) == 0) { +ki->driver = KdFindKeyboardDriver("evdev"); +ki->options = input_option_new(ki->options, "driver", "evdev"); +} +#endif } KdKeyboardInfo * @@ -1191,6 +1206,16 @@ KdParsePointerOptions(KdPointerInfo * pi) ErrorF("Pointer option key (%s) of value (%s) not assigned!\n", key, value); } + +#ifdef KDRIVE_EVDEV +if (!pi->driver && pi->path != NULL && +strncasecmp(pi->path, +DEV_INPUT_EVENT_PREFIX, +DEV_INPUT_EVENT_PREFIX_LEN) == 0) { +pi->driver = KdFindPointerDriver("evdev"); +pi->options = input_option_new(pi->options, "driver", "evdev"); +} +#endif } KdPointerInfo * -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 7/9] config/udev: better distinguish between real keyboards and other key input devices
This patch introduces a new flag ATTR_KEY for hotplugged input devices, so we can better distinguish between real keyboards (i.e. devices with udev property ID_INPUT_KEYBOARD="1") and other key input devices like lid switches, power buttons, etc. All supported hotplug backends (udev, hal, and wscons) will set both flags ATTR_KEY and ATTR_KEYBOARD for real keyboards, but udev backend will set ATTR_KEY, but not ATTR_KEYBOARD, for non-keyboard key input devices (hal and wscons will set both flags in any case). With this distinction, kdrive input hotplugging mechanism will be allowed to only grab real keyboards, as other key input devices are currently not supported. In order to don't break current behaviour, this patch will replace all ATTR_KEYBOARD occurrences with ATTR_KEY in hw/xfree86/common/xf86Xinput.c. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- config/hal.c | 2 +- config/udev.c | 4 config/wscons.c| 2 +- hw/kdrive/src/kinput.c | 4 +++- hw/xfree86/common/xf86Xinput.c | 2 +- include/input.h| 13 +++-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/config/hal.c b/config/hal.c index ea574ca..c76eced 100644 --- a/config/hal.c +++ b/config/hal.c @@ -170,7 +170,7 @@ device_added(LibHalContext * hal_ctx, const char *udi) free(hal_tags); if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL)) -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; if (libhal_device_query_capability(hal_ctx, udi, "input.mouse", NULL)) attrs.flags |= ATTR_POINTER; if (libhal_device_query_capability(hal_ctx, udi, "input.joystick", NULL)) diff --git a/config/udev.c b/config/udev.c index 08a954b..1a6e82a 100644 --- a/config/udev.c +++ b/config/udev.c @@ -240,6 +240,10 @@ device_added(struct udev_device *udev_device) } else if (!strcmp(key, "ID_INPUT_KEY")) { LOG_PROPERTY(path, key, value); +attrs.flags |= ATTR_KEY; +} +else if (!strcmp(key, "ID_INPUT_KEYBOARD")) { +LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; } else if (!strcmp(key, "ID_INPUT_MOUSE")) { diff --git a/config/wscons.c b/config/wscons.c index fb114bd..ee45675 100644 --- a/config/wscons.c +++ b/config/wscons.c @@ -163,7 +163,7 @@ wscons_add_keyboard(void) } kbd_config_done: -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; rc = NewInputDeviceRequest(input_options, , ); if (rc != Success) goto unwind; diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 0acf82e..277f6ad 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -2366,7 +2366,9 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, *pdev = ki->dixdev; } else { -ErrorF("unrecognised device identifier!\n"); +ErrorF("unrecognised device identifier: %s\n", + input_option_get_value(input_option_find(optionsdup, +"device"))); input_option_free_list(); return BadValue; } diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index c56a2b9..b362d27 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -632,7 +632,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev, /* MatchIs* booleans */ if (iclass->is_keyboard.set && -iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEYBOARD)) +iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEY)) return FALSE; if (iclass->is_pointer.set && iclass->is_pointer.val != ! !(attrs->flags & ATTR_POINTER)) diff --git a/include/input.h b/include/input.h index d8bd9c6..19ef0c9 100644 --- a/include/input.h +++ b/include/input.h @@ -230,12 +230,13 @@ typedef struct _InputAttributes { uint32_t flags; } InputAttributes; -#define ATTR_KEYBOARD (1<<0) -#define ATTR_POINTER (1<<1) -#define ATTR_JOYSTICK (1<<2) -#define ATTR_TABLET (1<<3) -#define ATTR_TOUCHPAD (1<<4) -#define ATTR_TOUCHSCREEN (1<<5) +#define ATTR_KEY (1<<0) +#define ATTR_KEYBOARD (1<<1) +#define ATTR_POINTER (1<<2) +#define ATTR_JOYSTICK (1<<3) +#define ATTR_TABLET (1<<4) +#define ATTR_TOUCHPAD (1<<5) +#define ATTR_TOUCHSCREEN (1<<6) /* Key/Button has been run through all input processing and events sent to clients. */ #define KEY_PROCESSED 1 -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 9/9] ephyr: don't load ephyr input driver if -seat option is passed
When used for single-GPU multi-seat purposes, there's no need to enable ephyr virtual input devices, since Xephyr is supposed to handle its own hardware devices. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyrinit.c | 35 ++- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 09ada96..da43382 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -94,29 +94,30 @@ InitInput(int argc, char **argv) KdKeyboardInfo *ki; KdPointerInfo *pi; -KdAddKeyboardDriver(); #ifdef KDRIVE_EVDEV KdAddKeyboardDriver(); -#endif -KdAddPointerDriver(); -#ifdef KDRIVE_EVDEV KdAddPointerDriver(); #endif -if (!kdHasKbd) { -ki = KdNewKeyboard(); -if (!ki) -FatalError("Couldn't create Xephyr keyboard\n"); -ki->driver = -KdAddKeyboard(ki); -} +if (!SeatId) { +KdAddKeyboardDriver(); +KdAddPointerDriver(); -if (!kdHasPointer) { -pi = KdNewPointer(); -if (!pi) -FatalError("Couldn't create Xephyr pointer\n"); -pi->driver = -KdAddPointer(pi); +if (!kdHasKbd) { +ki = KdNewKeyboard(); +if (!ki) +FatalError("Couldn't create Xephyr keyboard\n"); +ki->driver = +KdAddKeyboard(ki); +} + +if (!kdHasPointer) { +pi = KdNewPointer(); +if (!pi) +FatalError("Couldn't create Xephyr pointer\n"); +pi->driver = +KdAddPointer(pi); +} } KdInitInput(); -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 5/9] kdrive: add options to set default XKB properties
This patch introduces convenient command-line options -xkbrules, -xkbmodel, -xkblayout, -xkbvariant, and -xkboptions, to set default values for these properties. These options can be handful in cases where corresponding values can't be taken from devices' udev properties, and compile-time default values don't match user locale. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/kdrive.c | 40 hw/kdrive/src/kinput.c | 16 +++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 8930ace..1578458 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -85,6 +85,11 @@ char *kdSwitchCmd; DDXPointRec kdOrigin; Bool kdHasPointer = FALSE; Bool kdHasKbd = FALSE; +const char *kdGlobalXkbRules = NULL; +const char *kdGlobalXkbModel = NULL; +const char *kdGlobalXkbLayout = NULL; +const char *kdGlobalXkbVariant = NULL; +const char *kdGlobalXkbOptions = NULL; static Bool kdCaughtSignal = FALSE; @@ -451,6 +456,11 @@ KdUseMsg(void) ("-mouse driver [,n,,options]Specify the pointer driver and its options (n is the number of buttons)\n"); ErrorF ("-keybd driver [,,options] Specify the keyboard driver and its options\n"); +ErrorF("-xkbrulesSet default XkbRules value (can be overriden by -keybd options)\n"); +ErrorF("-xkbmodelSet default XkbModel value (can be overriden by -keybd options)\n"); +ErrorF("-xkblayout Set default XkbLayout value (can be overriden by -keybd options)\n"); +ErrorF("-xkbvariant Set default XkbVariant value (can be overriden by -keybd options)\n"); +ErrorF("-xkboptions Set default XkbOptions value (can be overriden by -keybd options)\n"); ErrorF("-zaphod Disable cursor screen switching\n"); ErrorF("-2button Emulate 3 button mouse\n"); ErrorF("-3button Disable 3 button mouse emulation\n"); @@ -559,6 +569,36 @@ KdProcessArgument(int argc, char **argv, int i) sscanf(argv[i], "vt%2d", ) == 1) { return 1; } +if (!strcmp(argv[i], "-xkbrules")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbRules = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkbmodel")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbModel = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkblayout")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbLayout = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkbvariant")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbVariant = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkboptions")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbOptions = argv[i + 1]; +return 2; +} if (!strcmp(argv[i], "-mouse") || !strcmp(argv[i], "-pointer")) { if (i + 1 >= argc) UseMsg(); diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index e9a5f24..0acf82e 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -102,6 +102,12 @@ static int kdNumInputFds; extern Bool kdRawPointerCoordinates; +extern const char *kdGlobalXkbRules; +extern const char *kdGlobalXkbModel; +extern const char *kdGlobalXkbLayout; +extern const char *kdGlobalXkbVariant; +extern const char *kdGlobalXkbOptions; + static void KdSigio(int sig) { @@ -931,11 +937,11 @@ KdNewKeyboard(void) ki->options = NULL; ki->name = strdup("Generic Keyboard"); ki->path = NULL; -ki->xkbRules = strdup(XKB_DFLT_RULES); -ki->xkbModel = strdup(XKB_DFLT_MODEL); -ki->xkbLayout = strdup(XKB_DFLT_LAYOUT); -ki->xkbVariant = strdup(XKB_DFLT_VARIANT); -ki->xkbOptions = strdup(XKB_DFLT_OPTIONS); +ki->xkbRules = strdup(kdGlobalXkbRules ? kdGlobalXkbRules : XKB_DFLT_RULES); +ki->xkbModel = strdup(kdGlobalXkbModel ? kdGlobalXkbModel : XKB_DFLT_MODEL); +ki->xkbLayout = strdup(kdGlobalXkbLayout ? kdGlobalXkbLayout : XKB_DFLT_LAYOUT); +ki->xkbVariant = strdup(kdGlobalXkbVariant ? kdGlobalXkbVariant :XKB_DFLT_VARIANT); +ki->xkbOptions = strdup(kdGlobalXkbOptions ? kdGlobalXkbOptions : XKB_DFLT_OPTIONS); return ki; } -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH kdrive/ephyr v7 3/9] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
This patch introduces input hot-plugging support for kdrive-based applications in multi-seat context. This feature is enabled by passing -seat option with desired seat name. All keyboard/mouse devices assigned to that seat will be automatically grabbed by kdrive. It supports udev and hal backends for input hot-plugging support. Another patches may be required for wscons backend. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=33140 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/Makefile.am | 8 ++ hw/kdrive/src/kdrive.c| 39 + hw/kdrive/src/kinfo.c | 4 + hw/kdrive/src/kinput.c| 212 +- 4 files changed, 241 insertions(+), 22 deletions(-) diff --git a/hw/kdrive/src/Makefile.am b/hw/kdrive/src/Makefile.am index d69f0dd..b7f94b0 100644 --- a/hw/kdrive/src/Makefile.am +++ b/hw/kdrive/src/Makefile.am @@ -23,3 +23,11 @@ libkdrive_la_SOURCES = \ kshadow.c \ $(KDRIVE_XV_SOURCES) \ $(top_srcdir)/mi/miinitext.c + +if CONFIG_UDEV +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +else +if CONFIG_HAL +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +endif +endif diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index dddbe6e..8930ace 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -45,6 +45,10 @@ #include +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include +#endif + typedef struct _kdDepths { CARD8 depth; CARD8 bpp; @@ -1125,6 +1129,11 @@ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) KdAddScreen(pScreenInfo, screen, argc, argv); OsRegisterSigWrapper(KdSignalWrapper); + +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +if (SeatId) /* Enable input hot-plugging */ +config_pre_init(); +#endif } void @@ -1143,3 +1152,33 @@ DPMSSupported(void) { return FALSE; } + +/* These stubs can be safely removed once we can + * split input and GPU parts in hotplug.h et al. */ +#ifdef CONFIG_UDEV_KMS +void +NewGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} + +void +DeleteGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} +#endif + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor) +{ +return NULL; +} + +void +systemd_logind_release_fd(int _major, int _minor, int fd) +{ +} + +void +systemd_logind_vtenter(void) +{ +} diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c index 01ae1e4..f91d575 100644 --- a/hw/kdrive/src/kinfo.c +++ b/hw/kdrive/src/kinfo.c @@ -134,6 +134,7 @@ KdFreePointer(KdPointerInfo * pi) free(pi->name); free(pi->path); input_option_free_list(>options); +pi->next = NULL; free(pi); } @@ -145,6 +146,9 @@ KdFreeKeyboard(KdKeyboardInfo * ki) free(ki->xkbRules); free(ki->xkbModel); free(ki->xkbLayout); +free(ki->xkbVariant); +free(ki->xkbOptions); +input_option_free_list(>options); ki->next = NULL; free(ki); } diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 3a1c6a0..682b63a 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -51,6 +51,10 @@ #include "inpututils.h" #include "optionstr.h" +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include +#endif + #ifdef KDRIVE_EVDEV #define DEV_INPUT_EVENT_PREFIX "/dev/input/event" #define DEV_INPUT_EVENT_PREFIX_LEN (sizeof(DEV_INPUT_EVENT_PREFIX) - 1) @@ -407,7 +411,8 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff) #endif if (!pi->driver) { if (!pi->driverPrivate) { -ErrorF("no driver specified for %s\n", pi->name); +ErrorF("no driver specified for pointer device \"%s\" (%s)\n", + pi->name ? pi->name : "(unnamed)", pi->path); return BadImplementation; } @@ -727,7 +732,8 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) #endif if (!ki->driver) { if (!ki->driverPrivate) { -ErrorF("no driver specified!\n"); +ErrorF("no driver specified for keyboard device \"%s\" (%s)\n", + ki->name ? ki->name : "(unnamed)", ki->path); return BadImplementation; } @@ -901,6 +907,8 @@ KdNewKeyboard(void) ki->bellDuration = 200; ki->next = NULL; ki->options = NULL; +ki->name = strdup("Generic Keyboard"); +ki->path = NULL; ki->xkbRules = strdup(XKB_DFLT_RULES); ki->xkbModel = strdup(XKB_DFLT_MODEL); ki->xkbLayout = strdup(XKB_DFLT_LAYOUT); @@ -1084,18 +1092,52 @@ KdParseKbdOptions(KdKeyboardInfo * ki) const char *key = input_option_get_key(option); const
Re: [PATCH RFC kdrive/ephyr v2] Match host X server's keymap
2015-12-08 16:55 GMT-02:00 Uli Schlachter <psyc...@znc.in>: > Could you check xcb_get_extension_data(HostX.conn, _xkb_id)->present > first? > I don't know why XKB's UseExtension has a supported field, but without this > suggested check, the XCB connection will just go in an error state if the > XKB > connection is not actually present. > Done here. Thanks! > > +if (!controls_r) { > > +EPHYR_LOG_ERROR("Couldn't get XKB keyboard controls."); > > +return FALSE; > > For this one you check for errors, with the following ones you do not. Is > there > a reason for that? > Sincerely, there's not. I'm including the other checks as well. Thanks! > Also, even though it will never matter much, could you first send all the > requests and then get the replies? > I've reorganized the code to send all requests at beginning and process the replies as they are needed. I'm submitting a v3 right now. Thank you very much! -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH RFC kdrive/ephyr v3] Match host X server's keymap
Analogous to Xnest implementation at 83fef4235db86343477b4ec9858c6ba35e1aa7d9. v3 changes: - Several changes in XCB code following Uli Schlachter's advices. v2 changes: - Keep struct KdKeyboardInfo untouched. - Move XkbApplyMappingChange()+XkbDDXChangeControls() call to EphyrKeyboardInit(), since it doesn't apply for e.g. kdrive evdev driver. - Call kdrive keyboard driver's Init() after InitKeyboardDeviceStruct(), so we can apply keymap change within EphyrKeyboardInit(), as described above. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac| 2 +- hw/kdrive/ephyr/ephyr.c | 30 --- hw/kdrive/ephyr/hostx.c | 131 +--- hw/kdrive/ephyr/hostx.h | 9 +--- hw/kdrive/src/kinput.c | 8 +-- 5 files changed, 155 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 2e38efa..933addc 100644 --- a/configure.ac +++ b/configure.ac @@ -2391,7 +2391,7 @@ if test "$KDRIVE" = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" +XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb" if test "x$XV" = xyes; then XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" fi diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 896bac5..a477ecc 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -54,7 +54,6 @@ extern Bool ephyr_glamor; KdKeyboardInfo *ephyrKbd; KdPointerInfo *ephyrMouse; -EphyrKeySyms ephyrKeySyms; Bool ephyrNoDRI = FALSE; Bool ephyrNoXV = FALSE; @@ -1367,16 +1366,35 @@ KdPointerDriver EphyrMouseDriver = { static Status EphyrKeyboardInit(KdKeyboardInfo * ki) { +int i; +KeySymsRec keySyms; +CARD8 modmap[MAP_LENGTH]; +XkbControlsRec controls; + ki->driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); -hostx_load_keymap(); -if (!ephyrKeySyms.minKeyCode) { + +if (hostx_load_keymap(, modmap, ) && keySyms.map != NULL) { +XkbApplyMappingChange(ki->dixdev, , + keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); +XkbDDXChangeControls(ki->dixdev, , ); +free(keySyms.map); +} + +if (!keySyms.minKeyCode) { ErrorF("Couldn't load keymap from host\n"); return BadAlloc; } -ki->minScanCode = ephyrKeySyms.minKeyCode; -ki->maxScanCode = ephyrKeySyms.maxKeyCode; -free(ki->name); + +ki->minScanCode = keySyms.minKeyCode; +ki->maxScanCode = keySyms.maxKeyCode; + +if (ki->name != NULL) { +free(ki->name); +} + ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 49516bb..47cb97c 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef XF86DRI #include #include @@ -90,8 +91,6 @@ static EphyrHostXVars HostX; static int HostXWantDamageDebug = 0; -extern EphyrKeySyms ephyrKeySyms; - extern Bool EphyrWantResize; char *ephyrResName = NULL; @@ -1086,18 +1085,136 @@ hostx_paint_debug_rect(KdScreenInfo *screen, nanosleep(, NULL); } -void -hostx_load_keymap(void) +Bool +hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls) { int min_keycode, max_keycode; - +int map_width; +size_t i, j; +int keymap_len; +xcb_keysym_t *keymap; +xcb_keycode_t *modifier_map; +xcb_get_keyboard_mapping_cookie_t mapping_c; +xcb_get_keyboard_mapping_reply_t *mapping_r; +xcb_get_modifier_mapping_cookie_t modifier_c; +xcb_get_modifier_mapping_reply_t *modifier_r; +xcb_xkb_use_extension_cookie_t use_c; +xcb_xkb_use_extension_reply_t *use_r; +xcb_xkb_get_controls_cookie_t controls_c; +xcb_xkb_get_controls_reply_t *controls_r; + +/* First of all, collect host X server's + * min_keycode and max_keycode, which are + * independent from XKB support. */ min_keycode = xcb_get_setup(HostX.conn)->min_keycode; max_keycode = xcb_get_setup(HostX.conn)->max_keycode; EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode); -ephyrKeySyms.minKeyCode = min_keycode; -ephyrKeySyms.maxKeyCode = max_keycode; +keySyms->minKeyCode = min_keycode; +keySyms->maxKeyCode = max_keycode; + +/* Check for XKB availabitity in host X server */ +if (!hostx_has_extension(_xkb_id)) { +
[PATCH RFC kdrive/ephyr v4] Match host X server's keymap
Analogous to Xnest implementation at 83fef4235db86343477b4ec9858c6ba35e1aa7d9. v4 changes: - Just a last-minute simplification in EphyrKeyboardInit(): there's no need to test explicitely if keySyms.map is NULL anymore, because hostx_load_keymap() now returns FALSE if that one can't be allocated. v3 changes: - Several changes in XCB code following Uli Schlachter's advices. v2 changes: - Keep struct KdKeyboardInfo untouched. - Move XkbApplyMappingChange()+XkbDDXChangeControls() call to EphyrKeyboardInit(), since it doesn't apply for e.g. kdrive evdev driver. - Call kdrive keyboard driver's Init() after InitKeyboardDeviceStruct(), so we can apply keymap change within EphyrKeyboardInit(), as described above. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac| 2 +- hw/kdrive/ephyr/ephyr.c | 30 --- hw/kdrive/ephyr/hostx.c | 131 +--- hw/kdrive/ephyr/hostx.h | 9 +--- hw/kdrive/src/kinput.c | 8 +-- 5 files changed, 155 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 2e38efa..933addc 100644 --- a/configure.ac +++ b/configure.ac @@ -2391,7 +2391,7 @@ if test "$KDRIVE" = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" +XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb" if test "x$XV" = xyes; then XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" fi diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 896bac5..0973b2b 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -54,7 +54,6 @@ extern Bool ephyr_glamor; KdKeyboardInfo *ephyrKbd; KdPointerInfo *ephyrMouse; -EphyrKeySyms ephyrKeySyms; Bool ephyrNoDRI = FALSE; Bool ephyrNoXV = FALSE; @@ -1367,16 +1366,35 @@ KdPointerDriver EphyrMouseDriver = { static Status EphyrKeyboardInit(KdKeyboardInfo * ki) { +int i; +KeySymsRec keySyms; +CARD8 modmap[MAP_LENGTH]; +XkbControlsRec controls; + ki->driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); -hostx_load_keymap(); -if (!ephyrKeySyms.minKeyCode) { + +if (hostx_load_keymap(, modmap, )) { +XkbApplyMappingChange(ki->dixdev, , + keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); +XkbDDXChangeControls(ki->dixdev, , ); +free(keySyms.map); +} + +if (!keySyms.minKeyCode) { ErrorF("Couldn't load keymap from host\n"); return BadAlloc; } -ki->minScanCode = ephyrKeySyms.minKeyCode; -ki->maxScanCode = ephyrKeySyms.maxKeyCode; -free(ki->name); + +ki->minScanCode = keySyms.minKeyCode; +ki->maxScanCode = keySyms.maxKeyCode; + +if (ki->name != NULL) { +free(ki->name); +} + ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 49516bb..47cb97c 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef XF86DRI #include #include @@ -90,8 +91,6 @@ static EphyrHostXVars HostX; static int HostXWantDamageDebug = 0; -extern EphyrKeySyms ephyrKeySyms; - extern Bool EphyrWantResize; char *ephyrResName = NULL; @@ -1086,18 +1085,136 @@ hostx_paint_debug_rect(KdScreenInfo *screen, nanosleep(, NULL); } -void -hostx_load_keymap(void) +Bool +hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls) { int min_keycode, max_keycode; - +int map_width; +size_t i, j; +int keymap_len; +xcb_keysym_t *keymap; +xcb_keycode_t *modifier_map; +xcb_get_keyboard_mapping_cookie_t mapping_c; +xcb_get_keyboard_mapping_reply_t *mapping_r; +xcb_get_modifier_mapping_cookie_t modifier_c; +xcb_get_modifier_mapping_reply_t *modifier_r; +xcb_xkb_use_extension_cookie_t use_c; +xcb_xkb_use_extension_reply_t *use_r; +xcb_xkb_get_controls_cookie_t controls_c; +xcb_xkb_get_controls_reply_t *controls_r; + +/* First of all, collect host X server's + * min_keycode and max_keycode, which are + * independent from XKB support. */ min_keycode = xcb_get_setup(HostX.conn)->min_keycode; max_keycode = xcb_get_setup(HostX.conn)->max_keycode; EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode); -ephyrKeySyms.minKeyCode = min_keycode; -ephyrKeySyms.maxKeyCode = max_keycode; +
[PATCH RFC kdrive/ephyr] Match host X server's keymap
Analogous to Xnest implementation at 83fef4235db86343477b4ec9858c6ba35e1aa7d9. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac| 2 +- hw/kdrive/ephyr/ephyr.c | 19 +++--- hw/kdrive/ephyr/hostx.c | 98 ++--- hw/kdrive/ephyr/hostx.h | 9 + hw/kdrive/src/kdrive.h | 4 ++ hw/kdrive/src/kinput.c | 11 ++ 6 files changed, 123 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 2e38efa..933addc 100644 --- a/configure.ac +++ b/configure.ac @@ -2391,7 +2391,7 @@ if test "$KDRIVE" = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" +XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb" if test "x$XV" = xyes; then XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" fi diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 896bac5..a949f26 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -54,7 +54,6 @@ extern Bool ephyr_glamor; KdKeyboardInfo *ephyrKbd; KdPointerInfo *ephyrMouse; -EphyrKeySyms ephyrKeySyms; Bool ephyrNoDRI = FALSE; Bool ephyrNoXV = FALSE; @@ -1367,16 +1366,24 @@ KdPointerDriver EphyrMouseDriver = { static Status EphyrKeyboardInit(KdKeyboardInfo * ki) { +int i; + ki->driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); -hostx_load_keymap(); -if (!ephyrKeySyms.minKeyCode) { +ki->keymapLoaded = hostx_load_keymap(>keySyms, ki->modmap, >controls); + +if (!ki->keySyms.minKeyCode) { ErrorF("Couldn't load keymap from host\n"); return BadAlloc; } -ki->minScanCode = ephyrKeySyms.minKeyCode; -ki->maxScanCode = ephyrKeySyms.maxKeyCode; -free(ki->name); + +ki->minScanCode = ki->keySyms.minKeyCode; +ki->maxScanCode = ki->keySyms.maxKeyCode; + +if (ki->name != NULL) { +free(ki->name); +} + ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 49516bb..249b210 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef XF86DRI #include #include @@ -90,8 +91,6 @@ static EphyrHostXVars HostX; static int HostXWantDamageDebug = 0; -extern EphyrKeySyms ephyrKeySyms; - extern Bool EphyrWantResize; char *ephyrResName = NULL; @@ -1086,18 +1085,105 @@ hostx_paint_debug_rect(KdScreenInfo *screen, nanosleep(, NULL); } -void -hostx_load_keymap(void) +Bool +hostx_load_keymap(KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr controls) { int min_keycode, max_keycode; +int map_width; +size_t i, j; +int keymap_len; +xcb_keysym_t *keymap; +xcb_keycode_t *modifier_map; +xcb_get_keyboard_mapping_cookie_t mapping_c; +xcb_get_keyboard_mapping_reply_t *mapping_r; +xcb_get_modifier_mapping_cookie_t modifier_c; +xcb_get_modifier_mapping_reply_t *modifier_r; +xcb_xkb_use_extension_cookie_t use_c; +xcb_xkb_use_extension_reply_t *use_r; +xcb_xkb_get_controls_cookie_t controls_c; +xcb_xkb_get_controls_reply_t *controls_r; min_keycode = xcb_get_setup(HostX.conn)->min_keycode; max_keycode = xcb_get_setup(HostX.conn)->max_keycode; EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode); -ephyrKeySyms.minKeyCode = min_keycode; -ephyrKeySyms.maxKeyCode = max_keycode; +keySyms->minKeyCode = min_keycode; +keySyms->maxKeyCode = max_keycode; + +use_c = xcb_xkb_use_extension(HostX.conn, + XCB_XKB_MAJOR_VERSION, + XCB_XKB_MINOR_VERSION); +use_r = xcb_xkb_use_extension_reply(HostX.conn, use_c, NULL); + +if (!use_r) { +EPHYR_LOG_ERROR("Couldn't use XKB extension."); +return FALSE; +} else if (!use_r->supported) { +EPHYR_LOG_ERROR("XKB extension is not supported in X server."); +free(use_r); +return FALSE; +} + +free(use_r); + +controls_c = xcb_xkb_get_controls(HostX.conn, + XCB_XKB_ID_USE_CORE_KBD); +controls_r = xcb_xkb_get_controls_reply(HostX.conn, +controls_c, +NULL); + +if (!controls_r) { +EPHYR_LOG_ERROR("Couldn't get XKB keyboard controls."); +return FALSE; +} + +mapping_c = xcb_get_keyboard_mapping(HostX.conn, +
Re: [PATCH v3 06/10] kdrive: add options to set default XKB properties
2015-04-05 3:22 GMT-03:00 Jeremy Huddleston Sequoia <jerem...@apple.com>: > While you're at it, would you mind updating Xephyr to support matching the > parent server's keyboard layout (similar to what Xnest does, cf: > 83fef4235db86343477b4ec9858c6ba35e1aa7d9)? I never got around to doing > that. > I'm investigating this right now. I have a working sample in my xf86-video-nested fork, using xcb-xkb, that I wanna try to port to Xephyr. Do you know if I can call XkbApplyMappingChange()+XkbDDXChangeControls() before InitKeyboardDeviceStruct()? For example, I would like to call XkbApplyMappingChange()+XkbDDXChangeControls() inside EphyrKeyboardInit(), which is called before InitKeyboardDeviceStruct() in kdrive/kinput.c. Kind regards, -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xfree86 v2] systemd-logind.c: don't parse VT settings for non-seat0 X servers
Since non-seat0 X servers no longer touch VTs, I believe these settings are unnecessary. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/xfree86/os-support/linux/systemd-logind.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index 2612d9e..13784d1 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -38,6 +38,7 @@ #include "xf86.h" #include "xf86platformBus.h" #include "xf86Xinput.h" +#include "globals.h" #include "systemd-logind.h" @@ -615,7 +616,7 @@ static struct dbus_core_hook core_hook = { int systemd_logind_init(void) { -if (linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { +if (!ServerIsNotSeat0() && linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { LogMessage(X_INFO, "systemd-logind: logind integration requires -keeptty and " "-keeptty was not provided, disabling logind integration\n"); -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xfree86] systemd-logind.c: don't parse VT settings for non-seat0 X servers
> Ugh, sorry about that, I was under the assumption that ServerIsNotSeat0 is a function, > so that the patch would just work, so I did not test it. > > Laércio, fixing this requires adding a #include "globals.h" to systemd-logind.c, > can you do a v2 with this fixed please ? Sure! I'll do it tomorrow. Kind regards, ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xfree86] systemd-logind.c: don't parse VT settings for non-seat0 X servers
Since non-seat0 X servers no longer touch VTs since release 1.16, I believe these settings are unnecessary. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/xfree86/os-support/linux/systemd-logind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index 2612d9e..0b82b7f 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -615,7 +615,7 @@ static struct dbus_core_hook core_hook = { int systemd_logind_init(void) { -if (linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { +if (!ServerIsNotSeat0() && linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { LogMessage(X_INFO, "systemd-logind: logind integration requires -keeptty and " "-keeptty was not provided, disabling logind integration\n"); -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested v4 07/11] Don't load nested input driver if Xorg is started with option "-seat (...)"
When used for single-GPU multi-seat purposes, there's no need to load nestedinput driver, since nested Xorg will grab input devices assigned to the seat in question. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> Conflicts: src/driver.c --- src/driver.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/driver.c b/src/driver.c index 8aa53b2..2d5f9a5 100644 --- a/src/driver.c +++ b/src/driver.c @@ -181,6 +181,8 @@ typedef struct NestedPrivate { ShadowUpdateProc update; } NestedPrivate, *NestedPrivatePtr; +Bool enableNestedInput; + #define PNESTED(p) ((NestedPrivatePtr)((p)->driverPrivate)) #define PCLIENTDATA(p) (PNESTED(p)->clientData) @@ -190,12 +192,16 @@ static pointer NestedSetup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; +enableNestedInput = !SeatId; + if (!setupDone) { setupDone = TRUE; - + xf86AddDriver(, module, HaveDriverFuncs); -xf86AddInputDriver(, module, 0); - + +if (enableNestedInput) +xf86AddInputDriver(, module, 0); + return (pointer)1; } else { if (errmaj) @@ -634,7 +640,9 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL) // Schedule the NestedInputLoadDriver function to load once the // input core is initialized. -TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); + +if (enableNestedInput) +TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); miClearVisualTypes(); if (!miSetVisualTypesAndMasks(pScrn->depth, -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested v4 09/11] Introduce a new XCB client backend, and make it the default one.
This patch brings up a new XCB backend client, translated from original xlibclient.c, and based on latest Xephyr code. This XCB backend brings some improvements already present in Xephyr, like fullscreen and output support. This patch will also change configure.ac to make the new XCB backend the default one for building the driver. For switching back to Xlib backend, pass configure option --with-backend=xlib. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac|5 +- src/Makefile.am |9 +- src/client.h|1 - src/xcbclient.c | 1095 ++- 4 files changed, 1094 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 0664e91..51710f0 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_ARG_WITH([backend], AS_HELP_STRING([--with-backend=NAME], [Backend to be used when building the driver. Available options: xlib, xcb (default: xlib)]), [BACKEND="$withval"], -[BACKEND=xlib]) +[BACKEND=xcb]) AC_SUBST([BACKEND]) # Store the list of server defined optional extensions in REQUIRED_MODULES @@ -71,6 +71,9 @@ case "$BACKEND" in xlib) PKG_CHECK_MODULES(XEXT, xext) ;; +xcb) +PKG_CHECK_MODULES(XCB, xcb xcb-aux xcb-icccm xcb-image xcb-shm xcb-randr xcb-xkb) +;; esac DRIVER_NAME=nested diff --git a/src/Makefile.am b/src/Makefile.am index 44dc656..33d223a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,14 +18,15 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # -# Author: Paulo Zanoni <pzan...@mandriva.com> +# Authors: Paulo Zanoni <pzan...@mandriva.com> +# Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> # -AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) $(XCB_CFLAGS) nested_drv_la_LTLIBRARIES = nested_drv.la nested_drv_la_LDFLAGS = -module -avoid-version -nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) +nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XCB_LIBS) nested_drv_ladir = @moduledir@/drivers -nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h xlibclient.c client.h compat-api.h +nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h @BACKEND@client.c client.h compat-api.h diff --git a/src/client.h b/src/client.h index 30319c2..c9093f7 100644 --- a/src/client.h +++ b/src/client.h @@ -32,7 +32,6 @@ #include #include -#include "xf86Cursor.h" #include diff --git a/src/xcbclient.c b/src/xcbclient.c index d10887b..4ad04e2 100644 --- a/src/xcbclient.c +++ b/src/xcbclient.c @@ -20,16 +20,1091 @@ * * Authors: * - * Paulo Zanoni <pzan...@mandriva.com> - * Tuan Bui <tuanbui...@gmail.com> - * Colin Cornaby <colin.corn...@mac.com> - * Timothy Fleck <tim.cs@gmail.com> - * Colin Hill <colin.james.h...@gmail.com> - * Weseung Hwang <wese...@gmail.com> - * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ -#include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -/* The idea for this driver is that we can change the "client" backend, so we - * can use xlib, xcb or even something else if we're not on top of X */ +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "client.h" +#include "nested_input.h" + +#define BUF_LEN 256 + +extern Bool enableNestedInput; +extern char *display; + +static xcb_atom_t atom_WM_DELETE_WINDOW; + +typedef struct _Output { +const char *name; +int x; +int y; +int width; +int height; +} Output; + +struct NestedClientPrivate { +/* Host X server data */ +int screenNumber; +xcb_connection_t *conn; +xcb_visualtype_t *visual; +xcb_window_t rootWindow; +xcb_gcontext_t gc; +xcb_cursor_t emptyCursor; +Bool usingShm; + +/* Nested X server window data */ +xcb_window_t window; +int scrnIndex; +int x; +int y; +unsigned int width; +unsigned int height; +Bool usingFullscreen; +xcb_image_t *img; +xcb_shm_segment_info_t shminfo; +DeviceIntPtr dev; /* The pointer to the input device. Passed back to the + * input driver when posting input events. */ + +/* Common data */ +uint32_t attrs[2]; +uint32_t attr_mask; +}; + +static Bool +_nested_client_connection_has_error(int scrnIndex, +xcb_connection_t *conn) { +const char *displayName = getenv("DISPLAY"); + +switch (xcb_connection_has_error(conn)) { +case XCB_CONN_ER
[PATCH xf86-video-nested v4 10/11] Update README and TODO.
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- README | 60 ++-- TODO | 8 +--- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/README b/README index 12a2fc6..352c4af 100644 --- a/README +++ b/README @@ -3,68 +3,61 @@ xf86-video-nested: driver to run Xorg on top of Xorg or something else = Usage = This is how I test it: -X -config my.conf -noreset -retro :1 -(if your Xorg server is old you might need "-sharevts vt7", in case your -bottom-layer X runs on vt7) +Xorg :1 -config my.conf -noreset -retro My xorg.conf: -- begin xorg.conf -- +# Omit this section if -seat option is to be passed to Xorg Section "ServerFlags" -Option "AutoEnableDevices" "false" +Option "AutoAddGPU" "false" Option "AutoAddDevices" "false" -Option "AllowEmptyInput" "true" +Option "AutoEnableDevices" "false" EndSection Section "Device" -Identifier "device1" +Identifier "Nested virtual video device" Driver "nested" -Option "Display" ":0" # you can omit this +Option "Display" ":0" # you can omit this +Option "Xauthority" "/var/run/Xauthority/:0" # you can omit this EndSection +# you can omit this section Section "Screen" -Identifier "screen1" -Device "device1" +Identifier "Nested virtual screen" +Device "Nested virtual video device" DefaultDepth 24 -Option "Origin" "100 100" # you can omit this +Option "Origin" "100 100" # you can omit this SubSection "Display" Depth 24 Modes "640x480" EndSubSection EndSection - -Section "ServerLayout" -Identifier "layout1" -Screen "screen1" -EndSection -- end xorg.conf -- -Mouse and keyboard input events from the client window are forwarded to the nested -xserver, so no mouse/keyboard drivers are needed. +This driver provides an integrated input driver, so that mouse +and keyboard input events from the client window are forwarded +to the nested xserver. This driver is not enabled if -seat option is +passed to Xorg, making it suitable for single-GPU multi-seat. You can also have more than one screen with this driver. Here's an example of a -xorg.conf with 2 screens and a mouse: +xorg.conf with 2 screens: -- begin xorg.conf -- Section "ServerFlags" -Option "AutoEnableDevices" "false" +Option "AutoAddGPU" "false" Option "AutoAddDevices" "false" -Option "AllowEmptyInput" "true" -EndSection - -Section "Device" -Identifier "device1" -Driver "nested" +Option "AutoEnableDevices" "false" EndSection Section "Device" -Identifier "device2" +Identifier "Nested virtual video device" Driver "nested" EndSection Section "Screen" -Identifier "screen1" -Device "device1" +Identifier "Nested virtual screen 1" +Device "Nested virtual video device" DefaultDepth 24 SubSection "Display" Depth 24 @@ -73,8 +66,8 @@ Section "Screen" EndSection Section "Screen" -Identifier "screen2" -Device "device1" +Identifier "Nested virtual screen 2" +Device "Nested virtual video device" DefaultDepth 24 SubSection "Display" Depth 24 @@ -83,9 +76,8 @@ Section "Screen" EndSection Section "ServerLayout" -Identifier "layout1" -Screen "screen1" -Screen "screen2" RightOf "screen1" -InputDevice "mouse1" +Identifier "Nested virtual layout" +Screen "Nested virtual screen 1" +Screen "Nested virtual screen 2" RightOf "Nested virtual screen 1" EndSection -- end xorg.conf -- diff --git a/TODO b/TODO index aed9ca2..a2dd71a 100644 --- a/TODO +++ b/TODO @@ -9,14 +9,16 @@ TODO - implement FreeScreen? (http://www.x.org/archive/X11R6.8.2/doc/DESIGN6.html#38) - implement the code that validates depths, implement other checks - compare Xlib's bpp with pScrn's bpp? is it needed? other similar checks? -- add some Option "fullscreen"? (for Multiseat) -- write the xcb backend - write other backends (for different window systems, or maybe using portable libraries like SDL or Qt) - ability to detach from
[PATCH xf86-video-nested v4 11/11] Update overall coding style (braces and if-clauses)
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/driver.c | 464 ++--- src/nested_input.c | 155 -- 2 files changed, 294 insertions(+), 325 deletions(-) diff --git a/src/driver.c b/src/driver.c index 2d5f9a5..bae243a 100644 --- a/src/driver.c +++ b/src/driver.c @@ -52,6 +52,10 @@ #include "client.h" #include "nested_input.h" +#ifndef HW_SKIP_CONSOLE +#define HW_SKIP_CONSOLE 4 +#endif + #define NESTED_VERSION 0 #define NESTED_NAME "NESTED" #define NESTED_DRIVER_NAME "nested" @@ -199,14 +203,16 @@ NestedSetup(pointer module, pointer opts, int *errmaj, int *errmin) { xf86AddDriver(, module, HaveDriverFuncs); -if (enableNestedInput) +if (enableNestedInput) { xf86AddInputDriver(, module, 0); +} return (pointer)1; } else { -if (errmaj) +if (errmaj) { *errmaj = LDR_ONCEONLY; - +} + return NULL; } } @@ -228,24 +234,21 @@ NestedProbe(DriverPtr drv, int flags) { int numDevSections; GDevPtr *devSections; int i; - ScrnInfoPtr pScrn; int entityIndex; -if (flags & PROBE_DETECT) +if (flags & PROBE_DETECT) { return FALSE; - -if ((numDevSections = xf86MatchDevice(NESTED_DRIVER_NAME, - )) <= 0) { +} else if ((numDevSections = xf86MatchDevice(NESTED_DRIVER_NAME, + )) <= 0) { return FALSE; -} - -if (numDevSections > 0) { +} else if (numDevSections > 0) { for(i = 0; i < numDevSections; i++) { pScrn = NULL; entityIndex = xf86ClaimNoSlot(drv, NESTED_CHIP, devSections[i], TRUE); pScrn = xf86AllocateScreen(drv, 0); + if (pScrn) { xf86AddEntityToScreen(pScrn, entityIndex); pScrn->driverVersion = NESTED_VERSION; @@ -263,16 +266,12 @@ NestedProbe(DriverPtr drv, int flags) { foundScreen = TRUE; } } -} -free(devSections); -return foundScreen; +free(devSections); +return foundScreen; +} } -#ifndef HW_SKIP_CONSOLE -#define HW_SKIP_CONSOLE 4 -#endif - static Bool NestedDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) { CARD32 *flag; @@ -280,16 +279,15 @@ NestedDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) { /* XXX implement */ switch(op) { -case GET_REQUIRED_HW_INTERFACES: -flag = (CARD32*)ptr; -(*flag) = HW_SKIP_CONSOLE; -return TRUE; - -case RR_GET_INFO: -case RR_SET_CONFIG: -case RR_GET_MODE_MM: -default: -return FALSE; +case GET_REQUIRED_HW_INTERFACES: +flag = (CARD32*)ptr; +(*flag) = HW_SKIP_CONSOLE; +return TRUE; +case RR_GET_INFO: +case RR_SET_CONFIG: +case RR_GET_MODE_MM: +default: +return FALSE; } } @@ -298,12 +296,15 @@ static Bool NestedAllocatePrivate(ScrnInfoPtr pScrn) { xf86Msg(X_WARNING, "NestedAllocatePrivate called for an already " "allocated private!\n"); return FALSE; -} +} else { +pScrn->driverPrivate = xnfcalloc(sizeof(NestedPrivate), 1); -pScrn->driverPrivate = xnfcalloc(sizeof(NestedPrivate), 1); -if (pScrn->driverPrivate == NULL) -return FALSE; -return TRUE; +if (pScrn->driverPrivate == NULL) { +return FALSE; +} else { +return TRUE; +} +} } static void NestedFreePrivate(ScrnInfoPtr pScrn) { @@ -311,10 +312,10 @@ static void NestedFreePrivate(ScrnInfoPtr pScrn) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Double freeing NestedPrivate!\n"); return; +} else { +free(pScrn->driverPrivate); +pScrn->driverPrivate = NULL; } - -free(pScrn->driverPrivate); -pScrn->driverPrivate = NULL; } /* Data from here is valid to all server generations */ @@ -325,131 +326,121 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedPreInit\n"); -if (flags & PROBE_DETECT) +if (flags & PROBE_DETECT) { return FALSE; - -if (!NestedAllocatePrivate(pScrn)) { +} else if (!NestedAllocatePrivate(pScrn)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to allocate private\n"); return FALSE; -} - -pNested = PNESTED(pScrn); -pNested->originX = 0; -pNested->originY = 0; -pNested->fullWidth = 0; -pNested->fullHeight = 0; -pNested->ful
[PATCH xf86-video-nested v4 03/11] Add preliminary support for screen options "Fullscreen" and "Output" in xorg.conf
This patch introduces support for new screen options in xorg.conf, namely: "Fullscreen" and "Output". They are expected to work exactly as command-line options -fullscreen and -output for Xephyr, allowing to open nested Xorg window in fullscreen mode (restricted to given host X server output if option "Output" is set). In order to achieve this, NestedClientCheckDisplay() needs to be extended to allow collecting fullscreen geometry from host X server while checking if it's ready for connections, which has to be implemented on each backend client. NestedClientCreateScreen() also was extended to include a boolean argument that tells backend client if it needs to set appropriate fullscreen hint for nested Xorg window. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/client.h | 8 - src/driver.c | 99 src/xlibclient.c | 8 - 3 files changed, 85 insertions(+), 30 deletions(-) diff --git a/src/client.h b/src/client.h index 7f46844..30319c2 100644 --- a/src/client.h +++ b/src/client.h @@ -39,11 +39,17 @@ struct NestedClientPrivate; typedef struct NestedClientPrivate *NestedClientPrivatePtr; -Bool NestedClientCheckDisplay(); +Bool NestedClientCheckDisplay(int scrnIndex, + const char *output, + int *width, + int *height, + int *x, + int *y); Bool NestedClientValidDepth(int depth); NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, +Bool wantFullscreenHint, int width, int height, int originX, diff --git a/src/driver.c b/src/driver.c index 0c2f26a..af70127 100644 --- a/src/driver.c +++ b/src/driver.c @@ -97,7 +97,9 @@ void NestedPrintMode(ScrnInfoPtr p, DisplayModePtr m); typedef enum { OPTION_DISPLAY, OPTION_XAUTHORITY, -OPTION_ORIGIN +OPTION_ORIGIN, +OPTION_FULLSCREEN, +OPTION_OUTPUT } NestedOpts; typedef enum { @@ -113,10 +115,12 @@ static SymTabRec NestedChipsets[] = { * port NestedClient to something that's not Xlib/Xcb we might need to add some * custom options */ static OptionInfoRec NestedOptions[] = { -{ OPTION_DISPLAY,"Display",OPTV_STRING, {0}, FALSE }, -{ OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE }, -{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, -{ -1,NULL, OPTV_NONE, {0}, FALSE } +{ OPTION_DISPLAY,"Display",OPTV_STRING, {0}, FALSE }, +{ OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE }, +{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, +{ OPTION_FULLSCREEN, "Fullscreen", OPTV_BOOLEAN, {0}, FALSE }, +{ OPTION_OUTPUT, "Output", OPTV_STRING, {0}, FALSE }, +{ -1,NULL, OPTV_NONE,{0}, FALSE } }; _X_EXPORT DriverRec NESTED = { @@ -167,6 +171,10 @@ _X_EXPORT XF86ModuleData nestedModuleData = { typedef struct NestedPrivate { int originX; int originY; +int fullWidth; +int fullHeight; +Bool fullscreen; +const char *output; NestedClientPrivatePtr clientData; CreateScreenResourcesProcPtr CreateScreenResources; CloseScreenProcPtr CloseScreen; @@ -321,6 +329,10 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { pNested = PNESTED(pScrn); pNested->originX = 0; pNested->originY = 0; +pNested->fullWidth = 0; +pNested->fullHeight = 0; +pNested->fullscreen = FALSE; +pNested->output = NULL; if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) return FALSE; @@ -370,9 +382,25 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { pNested->originX, pNested->originY); } +if (xf86GetOptValBool(NestedOptions, OPTION_FULLSCREEN, >fullscreen)) +xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fullscreen mode %s\n", + pNested->fullscreen ? "enabled" : "disabled"); + +if (xf86IsOptionSet(NestedOptions, OPTION_OUTPUT)) { +pNested->output = xf86GetOptValString(NestedOptions, + OPTION_OUTPUT); +xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Targeting host X server output \"%s\"\n", + pNested->output); +} + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); -if (!NestedClientCheckDisplay()) { +if (!NestedClientCheckDisplay(pScrn->scrnIndex, + pNested
[PATCH xf86-video-nested v4 02/11] Add support for option "Xauthority" in xorg.conf
With this patch, one can set explicitly an authorization file for "nested" video driver in xorg.conf section "Device". It also removes member displayName from NestedPrivate struct, replacing it with DISPLAY environment variable wherever it's needed. Example: Section "Device" Identifier "Nested virtual video device" Driver "nested" Option "Display" ":0" Option "Xauthority" "/var/run/Xauthority/:0" EndSection If no such an option is defined in xorg.conf, the value defined in environment variable XAUTHORITY will be used, as before. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/client.h | 3 +-- src/driver.c | 39 +++ src/xlibclient.c | 7 +++ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/client.h b/src/client.h index a066ea8..7f46844 100644 --- a/src/client.h +++ b/src/client.h @@ -39,12 +39,11 @@ struct NestedClientPrivate; typedef struct NestedClientPrivate *NestedClientPrivatePtr; -Bool NestedClientCheckDisplay(const char *displayName); +Bool NestedClientCheckDisplay(); Bool NestedClientValidDepth(int depth); NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, -const char *displayName, int width, int height, int originX, diff --git a/src/driver.c b/src/driver.c index 2cedee0..0c2f26a 100644 --- a/src/driver.c +++ b/src/driver.c @@ -96,6 +96,7 @@ void NestedPrintMode(ScrnInfoPtr p, DisplayModePtr m); typedef enum { OPTION_DISPLAY, +OPTION_XAUTHORITY, OPTION_ORIGIN } NestedOpts; @@ -112,9 +113,10 @@ static SymTabRec NestedChipsets[] = { * port NestedClient to something that's not Xlib/Xcb we might need to add some * custom options */ static OptionInfoRec NestedOptions[] = { -{ OPTION_DISPLAY, "Display", OPTV_STRING, {0}, FALSE }, -{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, -{ -1, NULL, OPTV_NONE, {0}, FALSE } +{ OPTION_DISPLAY,"Display",OPTV_STRING, {0}, FALSE }, +{ OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE }, +{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, +{ -1,NULL, OPTV_NONE, {0}, FALSE } }; _X_EXPORT DriverRec NESTED = { @@ -163,7 +165,6 @@ _X_EXPORT XF86ModuleData nestedModuleData = { /* These stuff should be valid to all server generations */ typedef struct NestedPrivate { -const char *displayName; int originX; int originY; NestedClientPrivatePtr clientData; @@ -304,6 +305,7 @@ static void NestedFreePrivate(ScrnInfoPtr pScrn) { /* Data from here is valid to all server generations */ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { NestedPrivatePtr pNested; +const char *displayName = getenv("DISPLAY"); const char *originString = NULL; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedPreInit\n"); @@ -317,6 +319,8 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { } pNested = PNESTED(pScrn); +pNested->originX = 0; +pNested->originY = 0; if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) return FALSE; @@ -339,34 +343,38 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, NestedOptions); if (xf86IsOptionSet(NestedOptions, OPTION_DISPLAY)) { -pNested->displayName = xf86GetOptValString(NestedOptions, - OPTION_DISPLAY); +displayName = xf86GetOptValString(NestedOptions, + OPTION_DISPLAY); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using display \"%s\"\n", - pNested->displayName); -} else { -pNested->displayName = NULL; + displayName); +setenv("DISPLAY", displayName, 1); +} + +if (xf86IsOptionSet(NestedOptions, OPTION_XAUTHORITY)) { +setenv("XAUTHORITY", + xf86GetOptValString(NestedOptions, + OPTION_XAUTHORITY), 1); } if (xf86IsOptionSet(NestedOptions, OPTION_ORIGIN)) { originString = xf86GetOptValString(NestedOptions, OPTION_ORIGIN); + if (sscanf(originString, "%d %d", >originX, ->originY) != 2) { + >originY) != 2) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid value for option \"Origin\"\n"); return FALSE; } +
[PATCH xf86-video-nested v4 08/11] Remove expurious device when using nested input.
Because nestedinput is currently not recognized by Xorg as a suitable core pointer, it will automatically add "", with devpath /dev/input/mice and "mouse" driver, which may interfere with nested virtual pointer device. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/nested_input.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nested_input.c b/src/nested_input.c index 39f696f..9a6303e 100644 --- a/src/nested_input.c +++ b/src/nested_input.c @@ -357,7 +357,8 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) { InputOption* options = NULL; options = input_option_new(options, "Identifier", "Nested virtual generic input device"); options = input_option_new(options, "Driver", "nestedinput"); - +options = input_option_new(options, "CorePointer", "on"); + // Invoke NewInputDeviceRequest to call the PreInit function of // the driver. int ret = NewInputDeviceRequest(options, NULL, ); @@ -378,6 +379,13 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) { // Send the device to the client so that the client can send the // device back to the input driver when events are being posted. NestedClientSetDevicePtr(clientData, dev); + +/* XXX: Find a better way to make Xorg recognize nestedinput + * as the first core pointer. */ +pInfo = xf86LookupInput(""); + +if (pInfo) +DeleteInputDeviceRequest(pInfo->dev); } void -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested v4 05/11] Fix an "array index out of bounds" error in _nested_input_init_buttons().
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/nested_input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nested_input.c b/src/nested_input.c index 9d2e0d3..0d584c8 100644 --- a/src/nested_input.c +++ b/src/nested_input.c @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -192,7 +193,7 @@ _nested_input_init_buttons(DeviceIntPtr device) { CARD8 *map; Atom buttonLabels[NUM_MOUSE_BUTTONS] = {0}; -map = calloc(NUM_MOUSE_BUTTONS, sizeof(CARD8)); +map = calloc(NUM_MOUSE_BUTTONS + 1, sizeof(CARD8)); int i; for (i = 0; i < NUM_MOUSE_BUTTONS; i++) -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested v4 00/11] xf86-video-nested revival
Despite the large version bump, this is indeed the second time I submit the full patch series. I did it because I've sent previously a v2 and v3 of some patches only. This version fixes some memory leaks and brings some changes to XCB client, following Uli Schlachter's advices. Almost one year after my previous patch series (http://lists.x.org/archives/xorg-devel/2014-October/044501.html), I'm bringing up this new one to improve xf86-video-nested driver. I've implemented a new XCB backend client, trying to pair it with latest Xephyr code, so that we can port any Xephyr optimizations to this driver. For this series, I've added all the xcb-xkb missing parts to get keymap translation from bottom-layer Xorg to nested one working properly, so this new backend can replace Xlib completely. My main motivation for this driver is making single-GPU multi-seat configuration (i.e. launching nested X servers on top of a bare X server spanning all available video outputs) more reliable, so I'm disabling integrated nested input driver if -seat option is passed to nested Xorg. However, I believe it can also be handy for testing purposes, since it allows running Xorg itself nested in a window within user session. Compared to Xephyr, this driver still lacks some graphical optimizations, GLAMOR support, etc., but it's still a much better approach for multi-seat, because Xorg itself provides better input devices handling than kdrive. I need help to port any relevant features present in Xephyr to this XCB backend. Laércio de Sousa (11): Fix compilation warnings. Add support for option "Xauthority" in xorg.conf Add preliminary support for screen options "Fullscreen" and "Output" in xorg.conf Add configure option for choosing driver backend Fix an "array index out of bounds" error in _nested_input_init_buttons(). Fix several memory leaks detected by valgrind. Don't load nested input driver if Xorg is started with option "-seat (...)" Remove expurious device when using nested input. Introduce a new XCB client backend, and make it the default one. Update README and TODO. Update overall coding style (braces and if-clauses) README | 60 ++- TODO |8 +- configure.ac | 25 +- src/Makefile.am|9 +- src/client.h | 25 +- src/driver.c | 546 ++ src/nested_input.c | 187 + src/xcbclient.c| 1095 +++- src/xlibclient.c | 14 +- 9 files changed, 1563 insertions(+), 406 deletions(-) -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested v4 01/11] Fix compilation warnings.
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/client.h | 19 ++- src/driver.c | 19 ++- src/xlibclient.c | 5 +++-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/client.h b/src/client.h index 4c73b3c..a066ea8 100644 --- a/src/client.h +++ b/src/client.h @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -38,18 +39,18 @@ struct NestedClientPrivate; typedef struct NestedClientPrivate *NestedClientPrivatePtr; -Bool NestedClientCheckDisplay(char *displayName); +Bool NestedClientCheckDisplay(const char *displayName); Bool NestedClientValidDepth(int depth); -NestedClientPrivatePtr NestedClientCreateScreen(intscrnIndex, -char *displayName, -intwidth, -intheight, -intoriginX, -intoriginY, -intdepth, -intbitsPerPixel, +NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, +const char *displayName, +int width, +int height, +int originX, +int originY, +int depth, +int bitsPerPixel, Pixel *retRedMask, Pixel *retGreenMask, Pixel *retBlueMask); diff --git a/src/driver.c b/src/driver.c index 68b7aa8..2cedee0 100644 --- a/src/driver.c +++ b/src/driver.c @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -162,16 +163,16 @@ _X_EXPORT XF86ModuleData nestedModuleData = { /* These stuff should be valid to all server generations */ typedef struct NestedPrivate { -char*displayName; -int originX; -int originY; -NestedClientPrivatePtr clientData; +const char *displayName; +int originX; +int originY; +NestedClientPrivatePtr clientData; CreateScreenResourcesProcPtr CreateScreenResources; -CloseScreenProcPtr CloseScreen; -ShadowUpdateProc update; +CloseScreenProcPtr CloseScreen; +ShadowUpdateProc update; } NestedPrivate, *NestedPrivatePtr; -#define PNESTED(p)((NestedPrivatePtr)((p)->driverPrivate)) +#define PNESTED(p) ((NestedPrivatePtr)((p)->driverPrivate)) #define PCLIENTDATA(p) (PNESTED(p)->clientData) /*static ScrnInfoPtr NESTEDScrn;*/ @@ -303,7 +304,7 @@ static void NestedFreePrivate(ScrnInfoPtr pScrn) { /* Data from here is valid to all server generations */ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { NestedPrivatePtr pNested; -char *originString = NULL; +const char *originString = NULL; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedPreInit\n"); @@ -504,7 +505,7 @@ NestedAddMode(ScrnInfoPtr pScrn, int width, int height) { len = strlen(nameBuf); mode->name = XNFalloc(len+1); -strcpy(mode->name, nameBuf); +strcpy((char *)mode->name, nameBuf); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Adding mode %s\n", mode->name); diff --git a/src/xlibclient.c b/src/xlibclient.c index f7fe652..a1fa39a 100644 --- a/src/xlibclient.c +++ b/src/xlibclient.c @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -78,7 +79,7 @@ struct NestedClientPrivate { /* Checks if a display is open */ Bool -NestedClientCheckDisplay(char *displayName) { +NestedClientCheckDisplay(const char *displayName) { Display *d; d = XOpenDisplay(displayName); @@ -159,7 +160,7 @@ NestedClientTryXShm(NestedClientPrivatePtr pPriv, int scrnIndex, int width, int NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, - char *displayName, + const char *displayName
[PATCH v3 xf86-video-nested 07/10] Don't load nested input driver if Xorg is started with option "-seat (...)"
When used for single-GPU multi-seat purposes, there's no need to load nestedinput driver, since nested Xorg will grab input devices assigned to the seat in question. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> Conflicts: src/driver.c --- src/driver.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/driver.c b/src/driver.c index cafa895..9fb4334 100644 --- a/src/driver.c +++ b/src/driver.c @@ -183,6 +183,8 @@ typedef struct NestedPrivate { ShadowUpdateProc update; } NestedPrivate, *NestedPrivatePtr; +Bool enableNestedInput; + #define PNESTED(p) ((NestedPrivatePtr)((p)->driverPrivate)) #define PCLIENTDATA(p) (PNESTED(p)->clientData) @@ -192,12 +194,16 @@ static pointer NestedSetup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; +enableNestedInput = !SeatId; + if (!setupDone) { setupDone = TRUE; - + xf86AddDriver(, module, HaveDriverFuncs); -xf86AddInputDriver(, module, 0); - + +if (enableNestedInput) +xf86AddInputDriver(, module, 0); + return (pointer)1; } else { if (errmaj) @@ -635,7 +641,9 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL) // Schedule the NestedInputLoadDriver function to load once the // input core is initialized. -TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); + +if (enableNestedInput) +TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); miClearVisualTypes(); if (!miSetVisualTypesAndMasks(pScrn->depth, -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v3 xf86-video-nested 06/10] Fix several memory leaks detected by valgrind.
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/driver.c | 6 ++ src/nested_input.c | 23 +-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/driver.c b/src/driver.c index 74c7d93..cafa895 100644 --- a/src/driver.c +++ b/src/driver.c @@ -580,6 +580,11 @@ NestedAddMode(ScrnInfoPtr pScrn, int width, int height) { // to force the initialization to wait until the input core is initialized. static CARD32 NestedMouseTimer(OsTimerPtr timer, CARD32 time, pointer arg) { +if (timer) { +TimerFree(timer); +timer = NULL; +} + NestedInputLoadDriver(arg); return 0; } @@ -713,6 +718,7 @@ NestedCloseScreen(CLOSE_SCREEN_ARGS_DECL) { NestedClientCloseScreen(PCLIENTDATA(pScrn)); pScreen->CloseScreen = PNESTED(pScrn)->CloseScreen; + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } diff --git a/src/nested_input.c b/src/nested_input.c index 0d584c8..2083c77 100644 --- a/src/nested_input.c +++ b/src/nested_input.c @@ -189,6 +189,7 @@ _nested_input_init_keyboard(DeviceIntPtr device) { } static int _nested_input_init_buttons(DeviceIntPtr device) { +int ret = Success; InputInfoPtr pInfo = device->public.devicePrivate; CARD8 *map; Atom buttonLabels[NUM_MOUSE_BUTTONS] = {0}; @@ -201,12 +202,11 @@ _nested_input_init_buttons(DeviceIntPtr device) { if (!InitButtonClassDeviceStruct(device, NUM_MOUSE_BUTTONS, buttonLabels, map)) { xf86Msg(X_ERROR, "%s: Failed to register buttons.\n", pInfo->name); - -free(map); -return BadAlloc; +ret = BadAlloc; } -return Success; +free(map); +return ret; } static int @@ -233,6 +233,11 @@ nested_input_on(OsTimerPtr timer, CARD32 time, pointer arg) { DeviceIntPtr device = arg; InputInfoPtr pInfo = device->public.devicePrivate; NestedInputDevicePtr pNestedInput = pInfo->private; + +if (timer) { +TimerFree(timer); +timer = NULL; +} if(device->public.on) { @@ -293,6 +298,12 @@ NestedInputControl(DeviceIntPtr device, int what) { static CARD32 nested_input_ready(OsTimerPtr timer, CARD32 time, pointer arg) { NestedClientPrivatePtr clientData = arg; + +if (timer) { +TimerFree(timer); +timer = NULL; +} + NestedClientCheckEvents(clientData); return 0; } @@ -344,8 +355,8 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) { // Create input options for our invocation to NewInputDeviceRequest. InputOption* options = NULL; -options = input_option_new(options, strdup("identifier"), strdup("nestedinput")); -options = input_option_new(options, strdup("driver"), strdup("nestedinput")); +options = input_option_new(options, "identifier", "Nested virtual generic input device"); +options = input_option_new(options, "driver", "nestedinput"); // Invoke NewInputDeviceRequest to call the PreInit function of // the driver. -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.
I will send a v3 patch with some last-minute fixes found right after v2. Hopefully all your advices are contempled now. Please tell me if you have any other concerns. Att. 2015-11-06 15:18 GMT-02:00 Uli Schlachter <psyc...@znc.in>: > Hi, > > Am 06.11.2015 um 14:10 schrieb Laércio de Sousa: > [...] > >>> +static void > >>> +_NestedClientSetWMClass(NestedClientPrivatePtr pPriv, > >>> +const char* wm_class) > >>> +{ > >>> +size_t class_len = strlen(wm_class) + 1; > >>> +char *class_hint = malloc(class_len); > >>> + > >>> +if (class_hint) > >>> +{ > >>> +strcpy(class_hint, wm_class); > >>> +xcb_change_property(pPriv->conn, > >>> +XCB_PROP_MODE_REPLACE, > >>> +pPriv->window, > >>> +XCB_ATOM_WM_CLASS, > >>> +XCB_ATOM_STRING, > >>> +8, > >>> +class_len, > >>> +class_hint); > >>> +free(class_hint); > >>> +} > >> > >> Why is this strcpy needed? > >> > > I've copied over this piece of code from Xephyr. In that context, > > class_hint stores a concatenation bewteen two strings, so that strcpy is > > needed, but here the WM_CLASS string is much more simple, so that strcpy > is > > not needed. I'll remove it. Thanks! > > Uhm, right. This wants to set WM_CLASS and WM_CLASS should contain "two" > strings > (the class and the instance), separated by a null byte. > > Sorry for not noticing this earlier, but isn't this code wrong then? > > https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.5 > > [...] > >>> +if (!ev) > >>> +{ > >>> +if (_NestedClientConnectionHasError(pPriv->scrnIndex, > >>> +pPriv->conn)) > >>> +{ > >>> +/* XXX: Is there a better way to do this? */ > >>> +xf86DrvMsg(pPriv->scrnIndex, > >>> + X_ERROR, > >>> + "Connection with host X server lost.\n"); > >>> +free(ev); > >>> +NestedClientCloseScreen(pPriv); > >>> +exit(1); > >>> +} > >>> + > >>> +break; > >>> +} > >>> + > >>> +switch (ev->response_type & ~0x80) > >>> +{ > >>> +case XCB_EXPOSE: > >>> +_NestedClientProcessExpose(pPriv, ev); > >>> +break; > >>> +case XCB_CLIENT_MESSAGE: > >>> +_NestedClientProcessClientMessage(pPriv, ev); > >>> +break; > >>> +case XCB_MOTION_NOTIFY: > >>> +_NestedClientProcessMotionNotify(pPriv, ev); > >>> +break; > >>> +case XCB_KEY_PRESS: > >>> +_NestedClientProcessKeyPress(pPriv, ev); > >>> +break; > >>> +case XCB_KEY_RELEASE: > >>> +_NestedClientProcessKeyRelease(pPriv, ev); > >>> +break; > >>> +case XCB_BUTTON_PRESS: > >>> +_NestedClientProcessButtonPress(pPriv, ev); > >>> +break; > >>> +case XCB_BUTTON_RELEASE: > >>> +_NestedClientProcessButtonRelease(pPriv, ev); > >>> +break; > >>> +} > >>> + > >>> +free(ev); > >>> +xcb_flush(pPriv->conn); > >> > >> Why is this flushing inside of the event loop? Wouldn't a flush after > the > >> loop > >> be enough? > >> > > Well... Comparing it with other XCB snippets I've found in the web, it > > seems this xcb_flush() call is not needed at all. Calling it right atfer > > window creation or redrawing (XCB_EXPOSE event only) should be enough, > > right? > [...] > > Well, it depends. Something should flush in the end in case there are any > requests still in XCB's output buffer (and nothing implicitly flushes them > by > waiting for a reply). So I think that having a call to xcb_flush() before > returning to this function should be added. If it does something, it just > prevented a bug and if it doesn't do anything, it's not expensive. ;-) > > Everything else seems fine, thanks. > > Uli > -- > "For saving the Earth.. and eating cheesecake!" > -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v3 xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.
This patch brings up a new XCB backend client, translated from original xlibclient.c, and based on latest Xephyr code. This XCB backend brings some improvements already present in Xephyr, like fullscreen and output support. This patch will also change configure.ac to make the new XCB backend the default one for building the driver. For switching back to Xlib backend, pass configure option --with-backend=xlib. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac|5 +- src/Makefile.am |9 +- src/xcbclient.c | 1096 ++- 3 files changed, 1095 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 0664e91..51710f0 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_ARG_WITH([backend], AS_HELP_STRING([--with-backend=NAME], [Backend to be used when building the driver. Available options: xlib, xcb (default: xlib)]), [BACKEND="$withval"], -[BACKEND=xlib]) +[BACKEND=xcb]) AC_SUBST([BACKEND]) # Store the list of server defined optional extensions in REQUIRED_MODULES @@ -71,6 +71,9 @@ case "$BACKEND" in xlib) PKG_CHECK_MODULES(XEXT, xext) ;; +xcb) +PKG_CHECK_MODULES(XCB, xcb xcb-aux xcb-icccm xcb-image xcb-shm xcb-randr xcb-xkb) +;; esac DRIVER_NAME=nested diff --git a/src/Makefile.am b/src/Makefile.am index 44dc656..33d223a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,14 +18,15 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # -# Author: Paulo Zanoni <pzan...@mandriva.com> +# Authors: Paulo Zanoni <pzan...@mandriva.com> +# Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> # -AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) $(XCB_CFLAGS) nested_drv_la_LTLIBRARIES = nested_drv.la nested_drv_la_LDFLAGS = -module -avoid-version -nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) +nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XCB_LIBS) nested_drv_ladir = @moduledir@/drivers -nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h xlibclient.c client.h compat-api.h +nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h @BACKEND@client.c client.h compat-api.h diff --git a/src/xcbclient.c b/src/xcbclient.c index d10887b..c901bb6 100644 --- a/src/xcbclient.c +++ b/src/xcbclient.c @@ -20,16 +20,1092 @@ * * Authors: * - * Paulo Zanoni <pzan...@mandriva.com> - * Tuan Bui <tuanbui...@gmail.com> - * Colin Cornaby <colin.corn...@mac.com> - * Timothy Fleck <tim.cs@gmail.com> - * Colin Hill <colin.james.h...@gmail.com> - * Weseung Hwang <wese...@gmail.com> - * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ -#include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -/* The idea for this driver is that we can change the "client" backend, so we - * can use xlib, xcb or even something else if we're not on top of X */ +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "client.h" + +#include "nested_input.h" + +#define BUF_LEN 256 + +#define MAX(a, b) (((a) <= (b)) ? (b) : (a)) + +extern Bool enableNestedInput; +extern char *display; + +static xcb_atom_t atom_WM_DELETE_WINDOW; + +typedef struct _Output { +const char *name; +int x; +int y; +unsigned int width; +unsigned int height; +} Output; + +struct NestedClientPrivate { +/* Host X server data */ +int screenNumber; +xcb_connection_t *conn; +xcb_visualtype_t *visual; +xcb_window_t rootWindow; +xcb_gcontext_t gc; +xcb_cursor_t emptyCursor; +Bool usingShm; + +/* Nested X server window data */ +xcb_window_t window; +int scrnIndex; +int x; +int y; +unsigned int width; +unsigned int height; +Bool usingFullscreen; +xcb_image_t *img; +xcb_shm_segment_info_t shminfo; +DeviceIntPtr dev; /* The pointer to the input device. Passed back to the + * input driver when posting input events. */ + +/* Common data */ +uint32_t attrs[2]; +uint32_t attr_mask; +}; + +static Bool +_nested_client_connection_has_error(int scrnIndex, +xcb_connection_t *conn) { +const char *displayName = getenv("DISPLAY"); + +switch (xcb_connection_has_error(conn)) { +case XCB_CONN_ERROR: +xf86DrvMsg(scrnIndex, + X_ERROR, + "Failed to conn
[PATCH v2 xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.
This patch brings up a new XCB backend client, translated from original xlibclient.c, and based on latest Xephyr code. This XCB backend brings some improvements already present in Xephyr, like fullscreen and output support. This patch will also change configure.ac to make the new XCB backend the default one for building the driver. For switching back to Xlib backend, pass configure option --with-backend=xlib. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac|5 +- src/Makefile.am |9 +- src/xcbclient.c | 1092 ++- 3 files changed, 1091 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 0664e91..51710f0 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_ARG_WITH([backend], AS_HELP_STRING([--with-backend=NAME], [Backend to be used when building the driver. Available options: xlib, xcb (default: xlib)]), [BACKEND="$withval"], -[BACKEND=xlib]) +[BACKEND=xcb]) AC_SUBST([BACKEND]) # Store the list of server defined optional extensions in REQUIRED_MODULES @@ -71,6 +71,9 @@ case "$BACKEND" in xlib) PKG_CHECK_MODULES(XEXT, xext) ;; +xcb) +PKG_CHECK_MODULES(XCB, xcb xcb-aux xcb-icccm xcb-image xcb-shm xcb-randr xcb-xkb) +;; esac DRIVER_NAME=nested diff --git a/src/Makefile.am b/src/Makefile.am index 44dc656..33d223a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,14 +18,15 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # -# Author: Paulo Zanoni <pzan...@mandriva.com> +# Authors: Paulo Zanoni <pzan...@mandriva.com> +# Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> # -AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) $(XCB_CFLAGS) nested_drv_la_LTLIBRARIES = nested_drv.la nested_drv_la_LDFLAGS = -module -avoid-version -nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) +nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XCB_LIBS) nested_drv_ladir = @moduledir@/drivers -nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h xlibclient.c client.h compat-api.h +nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h @BACKEND@client.c client.h compat-api.h diff --git a/src/xcbclient.c b/src/xcbclient.c index d10887b..5a59780 100644 --- a/src/xcbclient.c +++ b/src/xcbclient.c @@ -20,16 +20,1088 @@ * * Authors: * - * Paulo Zanoni <pzan...@mandriva.com> - * Tuan Bui <tuanbui...@gmail.com> - * Colin Cornaby <colin.corn...@mac.com> - * Timothy Fleck <tim.cs@gmail.com> - * Colin Hill <colin.james.h...@gmail.com> - * Weseung Hwang <wese...@gmail.com> - * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ -#include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -/* The idea for this driver is that we can change the "client" backend, so we - * can use xlib, xcb or even something else if we're not on top of X */ +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "client.h" + +#include "nested_input.h" + +#define BUF_LEN 256 + +#define MAX(a, b) (((a) <= (b)) ? (b) : (a)) + +extern Bool enableNestedInput; +extern char *display; + +static xcb_atom_t atom_WM_DELETE_WINDOW; + +typedef struct _Output { +const char *name; +int x; +int y; +unsigned int width; +unsigned int height; +} Output; + +struct NestedClientPrivate { +/* Host X server data */ +int screenNumber; +xcb_connection_t *conn; +xcb_visualtype_t *visual; +xcb_window_t rootWindow; +xcb_gcontext_t gc; +xcb_cursor_t emptyCursor; +Bool usingShm; + +/* Nested X server window data */ +xcb_window_t window; +int scrnIndex; +int x; +int y; +unsigned int width; +unsigned int height; +Bool usingFullscreen; +xcb_image_t *img; +xcb_shm_segment_info_t shminfo; +DeviceIntPtr dev; /* The pointer to the input device. Passed back to the + * input driver when posting input events. */ + +/* Common data */ +uint32_t attrs[2]; +uint32_t attr_mask; +}; + +static Bool +_nested_client_connection_has_error(int scrnIndex, +xcb_connection_t *conn) { +const char *displayName = getenv("DISPLAY"); + +switch (xcb_connection_has_error(conn)) { +case XCB_CONN_ERROR: +xf86DrvMsg(scrnIndex, + X_ERROR, + "Failed to connect to host X server at displ
Re: [PATCH xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.
xev->x, > > + xev->y, > > + xev->x + xev->width, > > + xev->y + xev->height); > > +} > > + > > +static inline void > > +_NestedClientProcessClientMessage(NestedClientPrivatePtr pPriv, > > + xcb_generic_event_t *ev) > > +{ > > +xcb_client_message_event_t *cmev = (xcb_client_message_event_t *)ev; > > + > > +if (cmev->data.data32[0] == atom_WM_DELETE_WINDOW) > > +{ > > +/* XXX: Is there a better way to do this? */ > > +xf86DrvMsg(pPriv->scrnIndex, > > + X_INFO, > > + "Nested client window closed.\n"); > > +free(ev); > > +exit(0); > > You can as well just let the WM kill you if that's all that you do. :-) > (No, I'm not totally serious) > I want to terminate nested Xorg properly when I click on its close window button. Without this exit(0) call, the window will be destroyed, but X server will keep running. My complain about this exit(0) is that such an "abrupt" termination may lead to memory leaks due to some allocated pointers not being properly free'd. Does it proceed? > > > +} > > +} > > + > [...] > > +void > > +NestedClientCheckEvents(NestedClientPrivatePtr pPriv) > > +{ > > +xcb_generic_event_t *ev; > > + > > +while (TRUE) > > +{ > > +ev = xcb_poll_for_event(pPriv->conn); > > In the name of micro-optimization I will mention > xcb_poll_for_queued_event() > once and then shut up again (the idea being to poll only in the first > iteration > and afterwards using poll_for_queued_event, but I don't think that this > really > makes much of a difference. > OK, it's quite easy to implement, so I'm changing the code here. Thank you for the suggestion! > > > +if (!ev) > > +{ > > +if (_NestedClientConnectionHasError(pPriv->scrnIndex, > > +pPriv->conn)) > > +{ > > +/* XXX: Is there a better way to do this? */ > > +xf86DrvMsg(pPriv->scrnIndex, > > + X_ERROR, > > + "Connection with host X server lost.\n"); > > +free(ev); > > +NestedClientCloseScreen(pPriv); > > +exit(1); > > +} > > + > > +break; > > +} > > + > > +switch (ev->response_type & ~0x80) > > +{ > > +case XCB_EXPOSE: > > +_NestedClientProcessExpose(pPriv, ev); > > +break; > > +case XCB_CLIENT_MESSAGE: > > +_NestedClientProcessClientMessage(pPriv, ev); > > +break; > > +case XCB_MOTION_NOTIFY: > > +_NestedClientProcessMotionNotify(pPriv, ev); > > +break; > > +case XCB_KEY_PRESS: > > +_NestedClientProcessKeyPress(pPriv, ev); > > +break; > > +case XCB_KEY_RELEASE: > > +_NestedClientProcessKeyRelease(pPriv, ev); > > +break; > > +case XCB_BUTTON_PRESS: > > +_NestedClientProcessButtonPress(pPriv, ev); > > +break; > > +case XCB_BUTTON_RELEASE: > > +_NestedClientProcessButtonRelease(pPriv, ev); > > +break; > > +} > > + > > +free(ev); > > +xcb_flush(pPriv->conn); > > Why is this flushing inside of the event loop? Wouldn't a flush after the > loop > be enough? > Well... Comparing it with other XCB snippets I've found in the web, it seems this xcb_flush() call is not needed at all. Calling it right atfer window creation or redrawing (XCB_EXPOSE event only) should be enough, right? > > > +} > > +} > [...] > > Besides the above (minor) points, this look good to me, but I don't really > have > much of a clue. > Once again, thank you very much for the appointments! -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested 10/10] Update README and TODO.
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- README | 60 ++-- TODO | 4 ++-- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/README b/README index 12a2fc6..352c4af 100644 --- a/README +++ b/README @@ -3,68 +3,61 @@ xf86-video-nested: driver to run Xorg on top of Xorg or something else = Usage = This is how I test it: -X -config my.conf -noreset -retro :1 -(if your Xorg server is old you might need "-sharevts vt7", in case your -bottom-layer X runs on vt7) +Xorg :1 -config my.conf -noreset -retro My xorg.conf: -- begin xorg.conf -- +# Omit this section if -seat option is to be passed to Xorg Section "ServerFlags" -Option "AutoEnableDevices" "false" +Option "AutoAddGPU" "false" Option "AutoAddDevices" "false" -Option "AllowEmptyInput" "true" +Option "AutoEnableDevices" "false" EndSection Section "Device" -Identifier "device1" +Identifier "Nested virtual video device" Driver "nested" -Option "Display" ":0" # you can omit this +Option "Display" ":0" # you can omit this +Option "Xauthority" "/var/run/Xauthority/:0" # you can omit this EndSection +# you can omit this section Section "Screen" -Identifier "screen1" -Device "device1" +Identifier "Nested virtual screen" +Device "Nested virtual video device" DefaultDepth 24 -Option "Origin" "100 100" # you can omit this +Option "Origin" "100 100" # you can omit this SubSection "Display" Depth 24 Modes "640x480" EndSubSection EndSection - -Section "ServerLayout" -Identifier "layout1" -Screen "screen1" -EndSection -- end xorg.conf -- -Mouse and keyboard input events from the client window are forwarded to the nested -xserver, so no mouse/keyboard drivers are needed. +This driver provides an integrated input driver, so that mouse +and keyboard input events from the client window are forwarded +to the nested xserver. This driver is not enabled if -seat option is +passed to Xorg, making it suitable for single-GPU multi-seat. You can also have more than one screen with this driver. Here's an example of a -xorg.conf with 2 screens and a mouse: +xorg.conf with 2 screens: -- begin xorg.conf -- Section "ServerFlags" -Option "AutoEnableDevices" "false" +Option "AutoAddGPU" "false" Option "AutoAddDevices" "false" -Option "AllowEmptyInput" "true" -EndSection - -Section "Device" -Identifier "device1" -Driver "nested" +Option "AutoEnableDevices" "false" EndSection Section "Device" -Identifier "device2" +Identifier "Nested virtual video device" Driver "nested" EndSection Section "Screen" -Identifier "screen1" -Device "device1" +Identifier "Nested virtual screen 1" +Device "Nested virtual video device" DefaultDepth 24 SubSection "Display" Depth 24 @@ -73,8 +66,8 @@ Section "Screen" EndSection Section "Screen" -Identifier "screen2" -Device "device1" +Identifier "Nested virtual screen 2" +Device "Nested virtual video device" DefaultDepth 24 SubSection "Display" Depth 24 @@ -83,9 +76,8 @@ Section "Screen" EndSection Section "ServerLayout" -Identifier "layout1" -Screen "screen1" -Screen "screen2" RightOf "screen1" -InputDevice "mouse1" +Identifier "Nested virtual layout" +Screen "Nested virtual screen 1" +Screen "Nested virtual screen 2" RightOf "Nested virtual screen 1" EndSection -- end xorg.conf -- diff --git a/TODO b/TODO index aed9ca2..a43f2fa 100644 --- a/TODO +++ b/TODO @@ -9,8 +9,6 @@ TODO - implement FreeScreen? (http://www.x.org/archive/X11R6.8.2/doc/DESIGN6.html#38) - implement the code that validates depths, implement other checks - compare Xlib's bpp with pScrn's bpp? is it needed? other similar checks? -- add some Option "fullscreen"? (for Multiseat) -- write the xcb backend - write other backends (for different window systems, or maybe using portable libraries like SDL or Qt) - ability to detach from one xserver and attach to other? @@ -20,3 +18,5 @@ TODO - improve the code that redraws the screen (damage tracking) - fully understand the fb/shadow code to get a clue on what's really going on =) - write a man page +- bring latest Xephyr optimizations (e.g. AccelMethod "glamor" support) to xcb client +- verify support for non-root Xorg. -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested 08/10] Remove expurious device when using nested input.
Because nestedinput is currently not recognized by Xorg as a suitable core pointer, it will automatically add "", with devpath /dev/input/mice and "mouse" driver, which may interfere with nested virtual pointer device. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/nested_input.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/nested_input.c b/src/nested_input.c index 1a8ba18..a874930 100644 --- a/src/nested_input.c +++ b/src/nested_input.c @@ -371,6 +371,13 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) { // Send the device to the client so that the client can send the // device back to the input driver when events are being posted. NestedClientSetDevicePtr(clientData, dev); + +/* XXX: Find a better way to make Xorg recognize nestedinput + * as the first core pointer. */ +pInfo = xf86LookupInput(""); + +if (pInfo) +DeleteInputDeviceRequest(pInfo->dev); } void -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested 07/10] Don't load nested input driver if Xorg is started with option "-seat (...)"
When used for single-GPU multi-seat purposes, there's no need to load nestedinput driver, since nested Xorg will grab input devices assigned to the seat in question. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/driver.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/driver.c b/src/driver.c index 7939ce7..6615a46 100644 --- a/src/driver.c +++ b/src/driver.c @@ -183,6 +183,7 @@ typedef struct NestedPrivate { ShadowUpdateProc update; } NestedPrivate, *NestedPrivatePtr; +Bool enableNestedInput; OsTimerPtr timer; #define PNESTED(p) ((NestedPrivatePtr)((p)->driverPrivate)) @@ -194,12 +195,16 @@ static pointer NestedSetup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; +enableNestedInput = !SeatId; + if (!setupDone) { setupDone = TRUE; - + xf86AddDriver(, module, HaveDriverFuncs); -xf86AddInputDriver(, module, 0); - + +if (enableNestedInput) +xf86AddInputDriver(, module, 0); + return (pointer)1; } else { if (errmaj) @@ -632,7 +637,8 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL) // Schedule the NestedInputLoadDriver function to load once the // input core is initialized. -timer = TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); +if (enableNestedInput) +timer = TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); miClearVisualTypes(); if (!miSetVisualTypesAndMasks(pScrn->depth, -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested 05/10] Fix an "array index out of bounds" error in _nested_input_init_buttons().
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/nested_input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nested_input.c b/src/nested_input.c index 9d2e0d3..0d584c8 100644 --- a/src/nested_input.c +++ b/src/nested_input.c @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -192,7 +193,7 @@ _nested_input_init_buttons(DeviceIntPtr device) { CARD8 *map; Atom buttonLabels[NUM_MOUSE_BUTTONS] = {0}; -map = calloc(NUM_MOUSE_BUTTONS, sizeof(CARD8)); +map = calloc(NUM_MOUSE_BUTTONS + 1, sizeof(CARD8)); int i; for (i = 0; i < NUM_MOUSE_BUTTONS; i++) -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested 03/10] Add preliminary support for screen options "Fullscreen" and "Output" in xorg.conf
This patch introduces support for new screen options in xorg.conf, namely: "Fullscreen" and "Output". They are expected to work exactly as command-line options -fullscreen and -output for Xephyr, allowing to open nested Xorg window in fullscreen mode (restricted to given host X server output if option "Output" is set). In order to achieve this, NestedClientCheckDisplay() needs to be extended to allow collecting fullscreen geometry from host X server while checking if it's ready for connections, which has to be implemented on each backend client. NestedClientCreateScreen() also was extended to include a boolean argument that tells backend client if it needs to set appropriate fullscreen hint for nested Xorg window. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/client.h | 8 - src/driver.c | 101 --- src/xlibclient.c | 8 - 3 files changed, 87 insertions(+), 30 deletions(-) diff --git a/src/client.h b/src/client.h index 7f46844..30319c2 100644 --- a/src/client.h +++ b/src/client.h @@ -39,11 +39,17 @@ struct NestedClientPrivate; typedef struct NestedClientPrivate *NestedClientPrivatePtr; -Bool NestedClientCheckDisplay(); +Bool NestedClientCheckDisplay(int scrnIndex, + const char *output, + int *width, + int *height, + int *x, + int *y); Bool NestedClientValidDepth(int depth); NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, +Bool wantFullscreenHint, int width, int height, int originX, diff --git a/src/driver.c b/src/driver.c index 0c2f26a..74c7d93 100644 --- a/src/driver.c +++ b/src/driver.c @@ -97,7 +97,9 @@ void NestedPrintMode(ScrnInfoPtr p, DisplayModePtr m); typedef enum { OPTION_DISPLAY, OPTION_XAUTHORITY, -OPTION_ORIGIN +OPTION_ORIGIN, +OPTION_FULLSCREEN, +OPTION_OUTPUT } NestedOpts; typedef enum { @@ -113,10 +115,14 @@ static SymTabRec NestedChipsets[] = { * port NestedClient to something that's not Xlib/Xcb we might need to add some * custom options */ static OptionInfoRec NestedOptions[] = { -{ OPTION_DISPLAY,"Display",OPTV_STRING, {0}, FALSE }, -{ OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE }, -{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, -{ -1,NULL, OPTV_NONE, {0}, FALSE } +{ OPTION_DISPLAY,"Display",OPTV_STRING, {0}, FALSE }, +{ OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE }, +{ OPTION_DISPLAY,"Display",OPTV_STRING, {0}, FALSE }, +{ OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE }, +{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, +{ OPTION_FULLSCREEN, "Fullscreen", OPTV_BOOLEAN, {0}, FALSE }, +{ OPTION_OUTPUT, "Output", OPTV_STRING, {0}, FALSE }, +{ -1,NULL, OPTV_NONE,{0}, FALSE } }; _X_EXPORT DriverRec NESTED = { @@ -167,6 +173,10 @@ _X_EXPORT XF86ModuleData nestedModuleData = { typedef struct NestedPrivate { int originX; int originY; +int fullWidth; +int fullHeight; +Bool fullscreen; +const char *output; NestedClientPrivatePtr clientData; CreateScreenResourcesProcPtr CreateScreenResources; CloseScreenProcPtr CloseScreen; @@ -321,6 +331,10 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { pNested = PNESTED(pScrn); pNested->originX = 0; pNested->originY = 0; +pNested->fullWidth = 0; +pNested->fullHeight = 0; +pNested->fullscreen = FALSE; +pNested->output = NULL; if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) return FALSE; @@ -370,9 +384,25 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { pNested->originX, pNested->originY); } +if (xf86GetOptValBool(NestedOptions, OPTION_FULLSCREEN, >fullscreen)) +xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fullscreen mode %s\n", + pNested->fullscreen ? "enabled" : "disabled"); + +if (xf86IsOptionSet(NestedOptions, OPTION_OUTPUT)) { +pNested->output = xf86GetOptValString(NestedOptions, + OPTION_OUTPUT); +xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Targeting host X server output \"%s\"\n", + pNested->output); +} + xf86ShowUnusedOptions
[PATCH xf86-video-nested 00/10] xf86-video-nested revival
Almost one year after my previous patch series (http://lists.x.org/archives/xorg-devel/2014-October/044501.html), I'm bringing up this new one to improve xf86-video-nested driver. I've implemented a new XCB backend client, trying to pair it with latest Xephyr code, so that we can port any Xephyr optimizations to this driver. For this series, I've added all the xcb-xkb missing parts to get keymap translation from bottom-layer Xorg to nested one working properly, so this new backend can replace Xlib completely. My main motivation for this driver is making single-GPU multi-seat configuration (i.e. launching nested X servers on top of a bare X server spanning all available video outputs) more reliable, so I'm disabling integrated nested input driver if -seat option is passed to nested Xorg. However, I believe it can also be handy for testing purposes, since it allows running Xorg itself nested in a window within user session. Compared to Xephyr, this driver still lacks some graphical optimizations, GLAMOR support, etc., but it's still a much better approach for multi-seat, because Xorg itself provides better input devices handling than kdrive. I need help to port any relevant features present in Xephyr to this XCB backend. Laércio de Sousa (10): Fix compilation warnings. Add support for option "Xauthority" in xorg.conf Add preliminary support for screen options "Fullscreen" and "Output" in xorg.conf Add configure option for choosing driver backend Fix an "array index out of bounds" error in _nested_input_init_buttons(). Fix several memory leaks detected by valgrind. Don't load nested input driver if Xorg is started with option "-seat (...)" Remove expurious device when using nested input. Introduce a new XCB client backend, and make it the default one. Update README and TODO. README | 60 ++- TODO |4 +- configure.ac | 25 +- src/Makefile.am|9 +- src/client.h | 24 +- src/driver.c | 167 +--- src/nested_input.c | 30 +- src/xcbclient.c| 1167 +++- src/xlibclient.c | 14 +- 9 files changed, 1375 insertions(+), 125 deletions(-) -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested 04/10] Add configure option for choosing driver backend
This patch will introduce a new configure option --with-backend=NAME, that will allow switching easily between available client backend implementations when building xf86-video-nested. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 32e9ab0..0664e91 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([xf86-video-nestedy], +AC_INIT([xf86-video-nested], [0.1.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xf86-video-nested]) @@ -50,6 +50,13 @@ AC_ARG_WITH(xorg-module-dir, [ --with-xorg-module-dir=DIR ], [ moduledir="$libdir/xorg/modules" ]) AC_SUBST(moduledir) +# Define a configure option for choosing the client backend when building driver +AC_ARG_WITH([backend], +AS_HELP_STRING([--with-backend=NAME], + [Backend to be used when building the driver. Available options: xlib, xcb (default: xlib)]), +[BACKEND="$withval"], +[BACKEND=xlib]) +AC_SUBST([BACKEND]) # Store the list of server defined optional extensions in REQUIRED_MODULES #XORG_DRIVER_CHECK_EXT(RANDR, randrproto) @@ -59,7 +66,12 @@ PKG_CHECK_MODULES(XORG, xorg-server xproto $REQUIRED_MODULES) # Checks for libraries. PKG_CHECK_MODULES(X11, x11) -PKG_CHECK_MODULES(XEXT, xext) + +case "$BACKEND" in +xlib) +PKG_CHECK_MODULES(XEXT, xext) +;; +esac DRIVER_NAME=nested AC_SUBST([DRIVER_NAME]) @@ -69,3 +81,9 @@ AC_CONFIG_FILES([ src/Makefile ]) AC_OUTPUT +AC_MSG_RESULT([ + $PACKAGE_NAME $VERSION + + moduledir: ${moduledir} + backend:${BACKEND} +]) -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.
This patch brings up a new XCB backend client, translated from original xlibclient.c, and based on latest Xephyr code. This XCB backend brings some improvements already present in Xephyr, like fullscreen and output support. This patch will also change configure.ac to make the new XCB backend the default one for building the driver. For switching back to Xlib backend, pass configure option --with-backend=xlib. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- configure.ac|5 +- src/Makefile.am |9 +- src/xcbclient.c | 1167 ++- 3 files changed, 1166 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 0664e91..51710f0 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_ARG_WITH([backend], AS_HELP_STRING([--with-backend=NAME], [Backend to be used when building the driver. Available options: xlib, xcb (default: xlib)]), [BACKEND="$withval"], -[BACKEND=xlib]) +[BACKEND=xcb]) AC_SUBST([BACKEND]) # Store the list of server defined optional extensions in REQUIRED_MODULES @@ -71,6 +71,9 @@ case "$BACKEND" in xlib) PKG_CHECK_MODULES(XEXT, xext) ;; +xcb) +PKG_CHECK_MODULES(XCB, xcb xcb-aux xcb-icccm xcb-image xcb-shm xcb-randr xcb-xkb) +;; esac DRIVER_NAME=nested diff --git a/src/Makefile.am b/src/Makefile.am index 44dc656..33d223a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,14 +18,15 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # -# Author: Paulo Zanoni <pzan...@mandriva.com> +# Authors: Paulo Zanoni <pzan...@mandriva.com> +# Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> # -AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) $(XCB_CFLAGS) nested_drv_la_LTLIBRARIES = nested_drv.la nested_drv_la_LDFLAGS = -module -avoid-version -nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) +nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XCB_LIBS) nested_drv_ladir = @moduledir@/drivers -nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h xlibclient.c client.h compat-api.h +nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h @BACKEND@client.c client.h compat-api.h diff --git a/src/xcbclient.c b/src/xcbclient.c index d10887b..ccae57c 100644 --- a/src/xcbclient.c +++ b/src/xcbclient.c @@ -20,16 +20,1163 @@ * * Authors: * - * Paulo Zanoni <pzan...@mandriva.com> - * Tuan Bui <tuanbui...@gmail.com> - * Colin Cornaby <colin.corn...@mac.com> - * Timothy Fleck <tim.cs@gmail.com> - * Colin Hill <colin.james.h...@gmail.com> - * Weseung Hwang <wese...@gmail.com> - * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ -#include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -/* The idea for this driver is that we can change the "client" backend, so we - * can use xlib, xcb or even something else if we're not on top of X */ +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "client.h" + +#include "nested_input.h" + +#define BUF_LEN 256 + +#define MAX(a, b) (((a) <= (b)) ? (b) : (a)) + +extern Bool enableNestedInput; +extern char *display; + +static xcb_atom_t atom_WM_DELETE_WINDOW; + +typedef struct _Output { +const char *name; +int x; +int y; +unsigned int width; +unsigned int height; +} Output; + +struct NestedClientPrivate { +/* Host X server data */ +int screenNumber; +xcb_connection_t *conn; +xcb_visualtype_t *visual; +xcb_window_t rootWindow; +xcb_gcontext_t gc; +xcb_cursor_t emptyCursor; +Bool usingShm; + +/* Nested X server window data */ +xcb_window_t window; +int scrnIndex; +int x; +int y; +unsigned int width; +unsigned int height; +Bool usingFullscreen; +xcb_image_t *img; +xcb_shm_segment_info_t shminfo; +DeviceIntPtr dev; // The pointer to the input device. Passed back to the + // input driver when posting input events. + +/* Common data */ +uint32_t attrs[2]; +uint32_t attr_mask; +}; + +static Bool +_NestedClientConnectionHasError(int scrnIndex, +xcb_connection_t *conn) +{ +const char *displayName = getenv("DISPLAY"); + +switch (xcb_connection_has_error(conn)) +{ +case XCB_CONN_ERROR: +xf86DrvMsg(scrnIndex, + X_ERROR, + "Failed to connect to host X server at displ
[PATCH xf86-video-nested 01/10] Fix compilation warnings.
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/client.h | 19 ++- src/driver.c | 19 ++- src/xlibclient.c | 5 +++-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/client.h b/src/client.h index 4c73b3c..a066ea8 100644 --- a/src/client.h +++ b/src/client.h @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -38,18 +39,18 @@ struct NestedClientPrivate; typedef struct NestedClientPrivate *NestedClientPrivatePtr; -Bool NestedClientCheckDisplay(char *displayName); +Bool NestedClientCheckDisplay(const char *displayName); Bool NestedClientValidDepth(int depth); -NestedClientPrivatePtr NestedClientCreateScreen(intscrnIndex, -char *displayName, -intwidth, -intheight, -intoriginX, -intoriginY, -intdepth, -intbitsPerPixel, +NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, +const char *displayName, +int width, +int height, +int originX, +int originY, +int depth, +int bitsPerPixel, Pixel *retRedMask, Pixel *retGreenMask, Pixel *retBlueMask); diff --git a/src/driver.c b/src/driver.c index 68b7aa8..2cedee0 100644 --- a/src/driver.c +++ b/src/driver.c @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -162,16 +163,16 @@ _X_EXPORT XF86ModuleData nestedModuleData = { /* These stuff should be valid to all server generations */ typedef struct NestedPrivate { -char*displayName; -int originX; -int originY; -NestedClientPrivatePtr clientData; +const char *displayName; +int originX; +int originY; +NestedClientPrivatePtr clientData; CreateScreenResourcesProcPtr CreateScreenResources; -CloseScreenProcPtr CloseScreen; -ShadowUpdateProc update; +CloseScreenProcPtr CloseScreen; +ShadowUpdateProc update; } NestedPrivate, *NestedPrivatePtr; -#define PNESTED(p)((NestedPrivatePtr)((p)->driverPrivate)) +#define PNESTED(p) ((NestedPrivatePtr)((p)->driverPrivate)) #define PCLIENTDATA(p) (PNESTED(p)->clientData) /*static ScrnInfoPtr NESTEDScrn;*/ @@ -303,7 +304,7 @@ static void NestedFreePrivate(ScrnInfoPtr pScrn) { /* Data from here is valid to all server generations */ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { NestedPrivatePtr pNested; -char *originString = NULL; +const char *originString = NULL; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedPreInit\n"); @@ -504,7 +505,7 @@ NestedAddMode(ScrnInfoPtr pScrn, int width, int height) { len = strlen(nameBuf); mode->name = XNFalloc(len+1); -strcpy(mode->name, nameBuf); +strcpy((char *)mode->name, nameBuf); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Adding mode %s\n", mode->name); diff --git a/src/xlibclient.c b/src/xlibclient.c index f7fe652..a1fa39a 100644 --- a/src/xlibclient.c +++ b/src/xlibclient.c @@ -27,6 +27,7 @@ * Colin Hill <colin.james.h...@gmail.com> * Weseung Hwang <wese...@gmail.com> * Nathaniel Way <nathanie...@hotmail.com> + * Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> */ #include @@ -78,7 +79,7 @@ struct NestedClientPrivate { /* Checks if a display is open */ Bool -NestedClientCheckDisplay(char *displayName) { +NestedClientCheckDisplay(const char *displayName) { Display *d; d = XOpenDisplay(displayName); @@ -159,7 +160,7 @@ NestedClientTryXShm(NestedClientPrivatePtr pPriv, int scrnIndex, int width, int NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, - char *displayName, + const char *displayName
[PATCH xf86-video-nested 02/10] Add support for option "Xauthority" in xorg.conf
With this patch, one can set explicitly an authorization file for "nested" video driver in xorg.conf section "Device". It also removes member displayName from NestedPrivate struct, replacing it with DISPLAY environment variable wherever it's needed. Example: Section "Device" Identifier "Nested virtual video device" Driver "nested" Option "Display" ":0" Option "Xauthority" "/var/run/Xauthority/:0" EndSection If no such an option is defined in xorg.conf, the value defined in environment variable XAUTHORITY will be used, as before. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/client.h | 3 +-- src/driver.c | 39 +++ src/xlibclient.c | 7 +++ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/client.h b/src/client.h index a066ea8..7f46844 100644 --- a/src/client.h +++ b/src/client.h @@ -39,12 +39,11 @@ struct NestedClientPrivate; typedef struct NestedClientPrivate *NestedClientPrivatePtr; -Bool NestedClientCheckDisplay(const char *displayName); +Bool NestedClientCheckDisplay(); Bool NestedClientValidDepth(int depth); NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex, -const char *displayName, int width, int height, int originX, diff --git a/src/driver.c b/src/driver.c index 2cedee0..0c2f26a 100644 --- a/src/driver.c +++ b/src/driver.c @@ -96,6 +96,7 @@ void NestedPrintMode(ScrnInfoPtr p, DisplayModePtr m); typedef enum { OPTION_DISPLAY, +OPTION_XAUTHORITY, OPTION_ORIGIN } NestedOpts; @@ -112,9 +113,10 @@ static SymTabRec NestedChipsets[] = { * port NestedClient to something that's not Xlib/Xcb we might need to add some * custom options */ static OptionInfoRec NestedOptions[] = { -{ OPTION_DISPLAY, "Display", OPTV_STRING, {0}, FALSE }, -{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, -{ -1, NULL, OPTV_NONE, {0}, FALSE } +{ OPTION_DISPLAY,"Display",OPTV_STRING, {0}, FALSE }, +{ OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE }, +{ OPTION_ORIGIN, "Origin", OPTV_STRING, {0}, FALSE }, +{ -1,NULL, OPTV_NONE, {0}, FALSE } }; _X_EXPORT DriverRec NESTED = { @@ -163,7 +165,6 @@ _X_EXPORT XF86ModuleData nestedModuleData = { /* These stuff should be valid to all server generations */ typedef struct NestedPrivate { -const char *displayName; int originX; int originY; NestedClientPrivatePtr clientData; @@ -304,6 +305,7 @@ static void NestedFreePrivate(ScrnInfoPtr pScrn) { /* Data from here is valid to all server generations */ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { NestedPrivatePtr pNested; +const char *displayName = getenv("DISPLAY"); const char *originString = NULL; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedPreInit\n"); @@ -317,6 +319,8 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { } pNested = PNESTED(pScrn); +pNested->originX = 0; +pNested->originY = 0; if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) return FALSE; @@ -339,34 +343,38 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) { xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, NestedOptions); if (xf86IsOptionSet(NestedOptions, OPTION_DISPLAY)) { -pNested->displayName = xf86GetOptValString(NestedOptions, - OPTION_DISPLAY); +displayName = xf86GetOptValString(NestedOptions, + OPTION_DISPLAY); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using display \"%s\"\n", - pNested->displayName); -} else { -pNested->displayName = NULL; + displayName); +setenv("DISPLAY", displayName, 1); +} + +if (xf86IsOptionSet(NestedOptions, OPTION_XAUTHORITY)) { +setenv("XAUTHORITY", + xf86GetOptValString(NestedOptions, + OPTION_XAUTHORITY), 1); } if (xf86IsOptionSet(NestedOptions, OPTION_ORIGIN)) { originString = xf86GetOptValString(NestedOptions, OPTION_ORIGIN); + if (sscanf(originString, "%d %d", >originX, ->originY) != 2) { + >originY) != 2) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid value for option \"Origin\"\n"); return FALSE; } +
[PATCH xf86-video-nested 06/10] Fix several memory leaks detected by valgrind.
Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- src/driver.c | 8 +++- src/nested_input.c | 20 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/driver.c b/src/driver.c index 74c7d93..7939ce7 100644 --- a/src/driver.c +++ b/src/driver.c @@ -183,6 +183,8 @@ typedef struct NestedPrivate { ShadowUpdateProc update; } NestedPrivate, *NestedPrivatePtr; +OsTimerPtr timer; + #define PNESTED(p) ((NestedPrivatePtr)((p)->driverPrivate)) #define PCLIENTDATA(p) (PNESTED(p)->clientData) @@ -630,7 +632,7 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL) // Schedule the NestedInputLoadDriver function to load once the // input core is initialized. -TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); +timer = TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); miClearVisualTypes(); if (!miSetVisualTypesAndMasks(pScrn->depth, @@ -713,6 +715,10 @@ NestedCloseScreen(CLOSE_SCREEN_ARGS_DECL) { NestedClientCloseScreen(PCLIENTDATA(pScrn)); pScreen->CloseScreen = PNESTED(pScrn)->CloseScreen; + +if (timer != NULL) +free(timer); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } diff --git a/src/nested_input.c b/src/nested_input.c index 0d584c8..1a8ba18 100644 --- a/src/nested_input.c +++ b/src/nested_input.c @@ -102,6 +102,8 @@ _X_EXPORT XF86ModuleData nestedInputModuleData = { }; +static OsTimerPtr input_on_timer, read_input_timer; + int NestedInputPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { NestedInputDevicePtr pNestedInput; @@ -122,6 +124,7 @@ NestedInputPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { void NestedInputUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { +free(read_input_timer); } static pointer @@ -189,6 +192,7 @@ _nested_input_init_keyboard(DeviceIntPtr device) { } static int _nested_input_init_buttons(DeviceIntPtr device) { +int ret = Success; InputInfoPtr pInfo = device->public.devicePrivate; CARD8 *map; Atom buttonLabels[NUM_MOUSE_BUTTONS] = {0}; @@ -201,12 +205,11 @@ _nested_input_init_buttons(DeviceIntPtr device) { if (!InitButtonClassDeviceStruct(device, NUM_MOUSE_BUTTONS, buttonLabels, map)) { xf86Msg(X_ERROR, "%s: Failed to register buttons.\n", pInfo->name); - -free(map); -return BadAlloc; +ret = BadAlloc; } -return Success; +free(map); +return ret; } static int @@ -270,7 +273,7 @@ NestedInputControl(DeviceIntPtr device, int what) { break; device->public.on = TRUE; -TimerSet(NULL, 0, 1, nested_input_on, device); +input_on_timer = TimerSet(NULL, 0, 1, nested_input_on, device); break; case DEVICE_OFF: xf86Msg(X_INFO, "%s: Off.\n", pInfo->name); @@ -282,6 +285,7 @@ NestedInputControl(DeviceIntPtr device, int what) { pInfo->fd = -1; device->public.on = FALSE; +free(input_on_timer); break; case DEVICE_CLOSE: break; @@ -300,7 +304,7 @@ nested_input_ready(OsTimerPtr timer, CARD32 time, pointer arg) { static void NestedInputReadInput(InputInfoPtr pInfo) { NestedInputDevicePtr pNestedInput = pInfo->private; -TimerSet(NULL, 0, 1, nested_input_ready, pNestedInput->clientData); +read_input_timer = TimerSet(NULL, 0, 1, nested_input_ready, pNestedInput->clientData); } #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 14 @@ -344,8 +348,8 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) { // Create input options for our invocation to NewInputDeviceRequest. InputOption* options = NULL; -options = input_option_new(options, strdup("identifier"), strdup("nestedinput")); -options = input_option_new(options, strdup("driver"), strdup("nestedinput")); +options = input_option_new(options, "identifier", "Nested virtual pointer"); +options = input_option_new(options, "driver", "nestedinput"); // Invoke NewInputDeviceRequest to call the PreInit function of // the driver. -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH v6 RFC 01/10] ephyr: allow passing explictly host X server display number and/or authorization file path
I'm not endorsing this patch anymore. It could be perfectly replaced with other approaches: * Rely on DM settings to set DISPLAY/XAUTHORITY variables * Set custom command "env DISPLAY=(...) XAUTHORITY=(...) Xephyr (...)" in DM settings Since patch 08/10 has already been merged, patches 02-07/10 and 09,10/10 still need to be reviewed. 2015-09-03 15:00 GMT-03:00 Laércio de Sousa < laercioso...@sme-mogidascruzes.sp.gov.br>: > This patch introduces two command-line options for Xephyr: > > * -host-display: set Xephyr DISPLAY environment variable >to host X server display number > * -host-auth:set Xephyr XAUTHORITY environment variable >to host X server authorization file path > > These options are particularly useful when Xephyr is launched > directly from display manager, because DISPLAY and/or XAUTHORITY > environment variables may not be set when it's launched. > > Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> > --- > hw/kdrive/ephyr/ephyrinit.c | 20 > 1 file changed, 20 insertions(+) > > diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c > index 8fbaf1d..0a42c96 100644 > --- a/hw/kdrive/ephyr/ephyrinit.c > +++ b/hw/kdrive/ephyr/ephyrinit.c > @@ -141,6 +141,8 @@ ddxUseMsg(void) > KdUseMsg(); > > ErrorF("\nXephyr Option Usage:\n"); > +ErrorF("-host-displayhost X server display number\n"); > +ErrorF("-host-auth host X server authorization file > path\n"); > ErrorF("-parent Use existing window as Xephyr root > win\n"); > ErrorF("-sw-cursor Render cursors in software in Xephyr\n"); > ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n"); > @@ -369,6 +371,24 @@ ddxProcessArgument(int argc, char **argv, int i) > EphyrWantNoHostGrab = 1; > return 2; > } > +else if (!strcmp(argv[i], "-host-display")) { > +if (i + 1 < argc) { > +setenv("DISPLAY", argv[i + 1], 1); > +return 2; > +} > + > +UseMsg(); > +exit(1); > +} > +else if (!strcmp(argv[i], "-host-auth")) { > + if (i + 1 < argc) { > +setenv("XAUTHORITY", argv[i + 1], 1); > +return 2; > +} > + > +UseMsg(); > +exit(1); > +} > > return KdProcessArgument(argc, argv, i); > } > -- > 2.5.0 > > -- *Laércio de Sousa* *Orientador de Informática* *Escola Municipal "Professor Eulálio Gruppi"* *Rua Ismael da Silva Mello, 559, Mogi Moderno* *Mogi das Cruzes - SPCEP 08717-390* Telefone: (11) 4726-8313 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 07/10] ephyr: ignore "-novtswitch", "-sharevts", and "-layout seatXXX" command-line options
Multiseat-capable display managers commonly pass command-line options like "-novtswitch", "-sharevts", or "-layout seat" to Xorg server, but Xephyr currently refuses to start if these options are passed to it, which may break Xephyr-based single-GPU multiseat setups. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyrinit.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 0a42c96..e41d376 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -389,6 +389,13 @@ ddxProcessArgument(int argc, char **argv, int i) UseMsg(); exit(1); } +else if (!strcmp(argv[i], "-sharevts") || + !strcmp(argv[i], "-novtswitch")) { +return 1; +} +else if (!strcmp(argv[i], "-layout")) { +return 2; +} return KdProcessArgument(argc, argv, i); } -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 08/10] ephyr: move host_has_extension() implementation to hostx.c
This is a trivial patch that moves host_has_extension() implementation from ephyr.c to hostx.c so that it can be called by hostx.c internal functions. Also rename function to hostx_has_extension() for consistency. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyr.c | 12 +--- hw/kdrive/ephyr/ephyrdriext.c | 4 ++-- hw/kdrive/ephyr/ephyrglxext.c | 2 +- hw/kdrive/ephyr/hostx.c | 16 hw/kdrive/ephyr/hostx.h | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index e6e72d3..1909a06 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -71,16 +71,6 @@ Bool EphyrWantResize = 0; Bool EphyrWantNoHostGrab = 0; Bool -host_has_extension(xcb_extension_t *extension) -{ -const xcb_query_extension_reply_t *rep; - -rep = xcb_get_extension_data(hostx_get_xcbconn(), extension); - -return rep && rep->present; -} - -Bool ephyrInitialize(KdCardInfo * card, EphyrPriv * priv) { OsSignal(SIGUSR1, hostx_handle_signal); @@ -670,7 +660,7 @@ ephyrInitScreen(ScreenPtr pScreen) } #endif /*XV*/ #ifdef XF86DRI -if (!ephyrNoDRI && !host_has_extension(_xf86dri_id)) { +if (!ephyrNoDRI && !hostx_has_extension(_xf86dri_id)) { EPHYR_LOG("host x does not support DRI. Disabling DRI forwarding\n"); ephyrNoDRI = TRUE; } diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c index 748b608..3703adf 100644 --- a/hw/kdrive/ephyr/ephyrdriext.c +++ b/hw/kdrive/ephyr/ephyrdriext.c @@ -1321,12 +1321,12 @@ ephyrDRIExtensionInit(ScreenPtr a_screen) EphyrDRIScreenPrivPtr screen_priv = NULL; EPHYR_LOG("enter\n"); -if (!host_has_extension(_xf86dri_id)) { +if (!hostx_has_extension(_xf86dri_id)) { EPHYR_LOG("host does not have DRI extension\n"); goto out; } EPHYR_LOG("host X does have DRI extension\n"); -if (!host_has_extension(_shape_id)) { +if (!hostx_has_extension(_shape_id)) { EPHYR_LOG("host does not have XShape extension\n"); goto out; } diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c index 248689e..c6d1569 100644 --- a/hw/kdrive/ephyr/ephyrglxext.c +++ b/hw/kdrive/ephyr/ephyrglxext.c @@ -84,7 +84,7 @@ ephyrHijackGLXExtension(void) { const void *(*dispatch_functions)[2]; -if (!host_has_extension(_glx_id)) { +if (!hostx_has_extension(_glx_id)) { EPHYR_LOG("host X does not have GLX\n"); return FALSE; } diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index dc265d5..5406938 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -99,6 +99,16 @@ int ephyrResNameFromCmd = 0; char *ephyrTitle = NULL; Bool ephyr_glamor = FALSE; +Bool +hostx_has_extension(xcb_extension_t *extension) +{ +const xcb_query_extension_reply_t *rep; + +rep = xcb_get_extension_data(HostX.conn, extension); + +return rep && rep->present; +} + static void hostx_set_fullscreen_hint(void); @@ -240,7 +250,7 @@ hostx_get_output_geometry(const char *output, xcb_randr_get_crtc_info_reply_t *crtc_info_r; /* First of all, check for extension */ -if (!xcb_get_extension_data(HostX.conn, _randr_id)->present) +if (!hostx_has_extension(_randr_id)) { fprintf(stderr, "\nHost X server does not support RANDR extension (or it's disabled).\n"); exit(1); @@ -422,7 +432,6 @@ hostx_init(void) char *tmpstr; char *class_hint; size_t class_len; -const xcb_query_extension_reply_t *shm_rep; xcb_screen_t *xscreen; xcb_rectangle_t rect = { 0, 0, 1, 1 }; @@ -632,8 +641,7 @@ hostx_init(void) } /* Try to get share memory ximages for a little bit more speed */ -shm_rep = xcb_get_extension_data(HostX.conn, _shm_id); -if (!shm_rep || !shm_rep->present || getenv("XEPHYR_NO_SHM")) { +if (!hostx_has_extension(_shm_id) || getenv("XEPHYR_NO_SHM")) { fprintf(stderr, "\nXephyr unable to use SHM XImages\n"); HostX.have_shm = FALSE; } diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index 93aaa50..9299e8d 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -182,7 +182,7 @@ int hostx_set_window_geometry(int a_win, EphyrBox * a_geo); int hostx_set_window_bounding_rectangles(int a_window, EphyrRect * a_rects, int a_num_rects); -int host_has_extension(xcb_extension_t *extension); +int hostx_has_extension(xcb_extension_t *extension); #ifdef XF86DRI int hostx_lookup_peer_window(void *a_local_window, -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 01/10] ephyr: allow passing explictly host X server display number and/or authorization file path
This patch introduces two command-line options for Xephyr: * -host-display: set Xephyr DISPLAY environment variable to host X server display number * -host-auth:set Xephyr XAUTHORITY environment variable to host X server authorization file path These options are particularly useful when Xephyr is launched directly from display manager, because DISPLAY and/or XAUTHORITY environment variables may not be set when it's launched. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/ephyr/ephyrinit.c | 20 1 file changed, 20 insertions(+) diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 8fbaf1d..0a42c96 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -141,6 +141,8 @@ ddxUseMsg(void) KdUseMsg(); ErrorF("\nXephyr Option Usage:\n"); +ErrorF("-host-displayhost X server display number\n"); +ErrorF("-host-auth host X server authorization file path\n"); ErrorF("-parent Use existing window as Xephyr root win\n"); ErrorF("-sw-cursor Render cursors in software in Xephyr\n"); ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n"); @@ -369,6 +371,24 @@ ddxProcessArgument(int argc, char **argv, int i) EphyrWantNoHostGrab = 1; return 2; } +else if (!strcmp(argv[i], "-host-display")) { +if (i + 1 < argc) { +setenv("DISPLAY", argv[i + 1], 1); +return 2; +} + +UseMsg(); +exit(1); +} +else if (!strcmp(argv[i], "-host-auth")) { +if (i + 1 < argc) { +setenv("XAUTHORITY", argv[i + 1], 1); +return 2; +} + +UseMsg(); +exit(1); +} return KdProcessArgument(argc, argv, i); } -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 09/10] config/udev: better distinguish between real keyboards and other key input devices
This patch introduces a new flag ATTR_KEY for hotplugged input devices, so we can better distinguish between real keyboards (i.e. devices with udev property ID_INPUT_KEYBOARD="1") and other key input devices like lid switches, power buttons, etc. All supported hotplug backends (udev, hal, and wscons) will set both flags ATTR_KEY and ATTR_KEYBOARD for real keyboards, but udev backend will set ATTR_KEY, but not ATTR_KEYBOARD, for non-keyboard key input devices (hal and wscons will set both flags in any case). With this distinction, kdrive input hotplugging mechanism will be allowed to only grab real keyboards, as other key input devices are currently not supported. In order to don't break current behaviour, this patch will replace all ATTR_KEYBOARD occurrences with ATTR_KEY in hw/xfree86/common/xf86Xinput.c. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- config/hal.c | 2 +- config/udev.c | 4 config/wscons.c| 2 +- hw/kdrive/src/kinput.c | 4 +++- hw/xfree86/common/xf86Xinput.c | 2 +- include/input.h| 13 +++-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/config/hal.c b/config/hal.c index ea574ca..c76eced 100644 --- a/config/hal.c +++ b/config/hal.c @@ -170,7 +170,7 @@ device_added(LibHalContext * hal_ctx, const char *udi) free(hal_tags); if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL)) -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; if (libhal_device_query_capability(hal_ctx, udi, "input.mouse", NULL)) attrs.flags |= ATTR_POINTER; if (libhal_device_query_capability(hal_ctx, udi, "input.joystick", NULL)) diff --git a/config/udev.c b/config/udev.c index 28c2658..958c95f 100644 --- a/config/udev.c +++ b/config/udev.c @@ -240,6 +240,10 @@ device_added(struct udev_device *udev_device) } else if (!strcmp(key, "ID_INPUT_KEY")) { LOG_PROPERTY(path, key, value); +attrs.flags |= ATTR_KEY; +} +else if (!strcmp(key, "ID_INPUT_KEYBOARD")) { +LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; } else if (!strcmp(key, "ID_INPUT_MOUSE")) { diff --git a/config/wscons.c b/config/wscons.c index fb114bd..ee45675 100644 --- a/config/wscons.c +++ b/config/wscons.c @@ -163,7 +163,7 @@ wscons_add_keyboard(void) } kbd_config_done: -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; rc = NewInputDeviceRequest(input_options, , ); if (rc != Success) goto unwind; diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 8510ccd..6594f4f 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -2401,7 +2401,9 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, *pdev = ki->dixdev; } else { -ErrorF("unrecognised device identifier!\n"); +ErrorF("unrecognised device identifier: %s\n", + input_option_get_value(input_option_find(optionsdup, +"device"))); input_option_free_list(); return BadValue; } diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index a5b0568..bb2fbb7 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -632,7 +632,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev, /* MatchIs* booleans */ if (iclass->is_keyboard.set && -iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEYBOARD)) +iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEY)) return FALSE; if (iclass->is_pointer.set && iclass->is_pointer.val != ! !(attrs->flags & ATTR_POINTER)) diff --git a/include/input.h b/include/input.h index d8bd9c6..19ef0c9 100644 --- a/include/input.h +++ b/include/input.h @@ -230,12 +230,13 @@ typedef struct _InputAttributes { uint32_t flags; } InputAttributes; -#define ATTR_KEYBOARD (1<<0) -#define ATTR_POINTER (1<<1) -#define ATTR_JOYSTICK (1<<2) -#define ATTR_TABLET (1<<3) -#define ATTR_TOUCHPAD (1<<4) -#define ATTR_TOUCHSCREEN (1<<5) +#define ATTR_KEY (1<<0) +#define ATTR_KEYBOARD (1<<1) +#define ATTR_POINTER (1<<2) +#define ATTR_JOYSTICK (1<<3) +#define ATTR_TABLET (1<<4) +#define ATTR_TOUCHPAD (1<<5) +#define ATTR_TOUCHSCREEN (1<<6) /* Key/Button has been run through all input processing and events sent to clients. */ #define KEY_PROCESSED 1 -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 02/10] kdrive: fix up NewInputDeviceRequest() implementation
This patch simplifies NewInputDeviceRequest() implementation in kinput.c, making use of improved KdParseKbdOptions()/KdParsePointerOptions() and merging several "if (ki)"/"if (pi)" clauses. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/kinput.c | 76 -- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 057f53b..12e9128 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -1080,6 +1080,8 @@ KdParseKbdOptions(KdKeyboardInfo * ki) ki->xkbOptions = strdup(value); else if (!strcasecmp(key, "device")) ki->path = strdup(value); +else if (!strcasecmp(key, "driver")) +ki->driver = KdFindKeyboardDriver(value); else ErrorF("Kbd option key (%s) of value (%s) not assigned!\n", key, value); @@ -1160,18 +1162,20 @@ KdParsePointerOptions(KdPointerInfo * pi) const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); -if (!strcmp(key, "emulatemiddle")) +if (!strcasecmp(key, "emulatemiddle")) pi->emulateMiddleButton = TRUE; -else if (!strcmp(key, "noemulatemiddle")) +else if (!strcasecmp(key, "noemulatemiddle")) pi->emulateMiddleButton = FALSE; -else if (!strcmp(key, "transformcoord")) +else if (!strcasecmp(key, "transformcoord")) pi->transformCoordinates = TRUE; -else if (!strcmp(key, "rawcoord")) +else if (!strcasecmp(key, "rawcoord")) pi->transformCoordinates = FALSE; else if (!strcasecmp(key, "device")) pi->path = strdup(value); else if (!strcasecmp(key, "protocol")) pi->protocol = strdup(value); +else if (!strcasecmp(key, "driver")) +pi->driver = KdFindPointerDriver(value); else ErrorF("Pointer option key (%s) of value (%s) not assigned!\n", key, value); @@ -2187,68 +2191,48 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, #endif } -if (!ki && !pi) { -ErrorF("unrecognised device identifier!\n"); -return BadValue; -} - -/* FIXME: change this code below to use KdParseKbdOptions and - * KdParsePointerOptions */ -nt_list_for_each_entry(option, options, list.next) { -const char *key = input_option_get_key(option); -const char *value = input_option_get_value(option); +if (pi) { +pi->options = options; +KdParsePointerOptions(pi); -if (strcmp(key, "device") == 0) { -if (pi && value) -pi->path = strdup(value); -else if (ki && value) -ki->path = strdup(value); -} -else if (strcmp(key, "driver") == 0) { -if (pi) { -pi->driver = KdFindPointerDriver(value); -if (!pi->driver) { -ErrorF("couldn't find driver!\n"); -KdFreePointer(pi); -return BadValue; -} -pi->options = options; -} -else if (ki) { -ki->driver = KdFindKeyboardDriver(value); -if (!ki->driver) { -ErrorF("couldn't find driver!\n"); -KdFreeKeyboard(ki); -return BadValue; -} -ki->options = options; -} +if (!pi->driver) { +ErrorF("couldn't find driver!\n"); +KdFreePointer(pi); +return BadValue; } -} -if (pi) { if (KdAddPointer(pi) != Success || ActivateDevice(pi->dixdev, TRUE) != Success || EnableDevice(pi->dixdev, TRUE) != TRUE) { ErrorF("couldn't add or enable pointer\n"); return BadImplementation; } + +*pdev = pi->dixdev; } else if (ki) { +ki->options = options; +KdParseKbdOptions(ki); + +if (!ki->driver) { +ErrorF("couldn't find driver!\n"); +KdFreeKeyboard(ki); +return BadValue; +} + if (KdAddKeyboard(ki) != Success || ActivateDevice(ki->dixdev, TRUE) != Success || EnableDevice(ki->dixdev, TRUE) != TRUE) { ErrorF("couldn't add or enable keyboard\n"); return BadImplementation; } -} -if (p
[PATCH v6 RFC 03/10] kdrive: set "evdev" driver for input devices automatically, if available.
If kdrive input driver "evdev" is available, no other driver was explicitly set for a given input device, and its kernel device node is /dev/input/event*, this patch will make kdrive set "evdev" driver automatically for such device. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/kinput.c | 25 + 1 file changed, 25 insertions(+) diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 12e9128..a0c1565 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -51,6 +51,11 @@ #include "inpututils.h" #include "optionstr.h" +#ifdef KDRIVE_EVDEV +#define DEV_INPUT_EVENT_PREFIX "/dev/input/event" +#define DEV_INPUT_EVENT_PREFIX_LEN (sizeof(DEV_INPUT_EVENT_PREFIX) - 1) +#endif + #define AtomFromName(x) MakeAtom(x, strlen(x), 1) struct KdConfigDevice { @@ -1086,6 +1091,16 @@ KdParseKbdOptions(KdKeyboardInfo * ki) ErrorF("Kbd option key (%s) of value (%s) not assigned!\n", key, value); } + +#ifdef KDRIVE_EVDEV +if (!ki->driver && ki->path != NULL && +strncasecmp(ki->path, +DEV_INPUT_EVENT_PREFIX, +DEV_INPUT_EVENT_PREFIX_LEN) == 0) { +ki->driver = KdFindKeyboardDriver("evdev"); +ki->options = input_option_new(ki->options, "driver", "evdev"); +} +#endif } KdKeyboardInfo * @@ -1180,6 +1195,16 @@ KdParsePointerOptions(KdPointerInfo * pi) ErrorF("Pointer option key (%s) of value (%s) not assigned!\n", key, value); } + +#ifdef KDRIVE_EVDEV +if (!pi->driver && pi->path != NULL && +strncasecmp(pi->path, +DEV_INPUT_EVENT_PREFIX, +DEV_INPUT_EVENT_PREFIX_LEN) == 0) { +pi->driver = KdFindPointerDriver("evdev"); +pi->options = input_option_new(pi->options, "driver", "evdev"); +} +#endif } KdPointerInfo * -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 04/10] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
This patch introduces input hot-plugging support for kdrive-based applications in multi-seat context. This feature is enabled by passing -seat option with desired seat name. All keyboard/mouse devices assigned to that seat will be automatically grabbed by kdrive. It supports udev and hal backends for input hot-plugging support. Another patches may be required for wscons backend. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=33140 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/Makefile.am | 8 ++ hw/kdrive/src/kdrive.c| 39 + hw/kdrive/src/kinfo.c | 4 + hw/kdrive/src/kinput.c| 212 +- 4 files changed, 241 insertions(+), 22 deletions(-) diff --git a/hw/kdrive/src/Makefile.am b/hw/kdrive/src/Makefile.am index d69f0dd..b7f94b0 100644 --- a/hw/kdrive/src/Makefile.am +++ b/hw/kdrive/src/Makefile.am @@ -23,3 +23,11 @@ libkdrive_la_SOURCES = \ kshadow.c \ $(KDRIVE_XV_SOURCES) \ $(top_srcdir)/mi/miinitext.c + +if CONFIG_UDEV +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +else +if CONFIG_HAL +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +endif +endif diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index dddbe6e..8930ace 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -45,6 +45,10 @@ #include +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include +#endif + typedef struct _kdDepths { CARD8 depth; CARD8 bpp; @@ -1125,6 +1129,11 @@ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) KdAddScreen(pScreenInfo, screen, argc, argv); OsRegisterSigWrapper(KdSignalWrapper); + +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +if (SeatId) /* Enable input hot-plugging */ +config_pre_init(); +#endif } void @@ -1143,3 +1152,33 @@ DPMSSupported(void) { return FALSE; } + +/* These stubs can be safely removed once we can + * split input and GPU parts in hotplug.h et al. */ +#ifdef CONFIG_UDEV_KMS +void +NewGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} + +void +DeleteGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} +#endif + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor) +{ +return NULL; +} + +void +systemd_logind_release_fd(int _major, int _minor, int fd) +{ +} + +void +systemd_logind_vtenter(void) +{ +} diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c index 01ae1e4..f91d575 100644 --- a/hw/kdrive/src/kinfo.c +++ b/hw/kdrive/src/kinfo.c @@ -134,6 +134,7 @@ KdFreePointer(KdPointerInfo * pi) free(pi->name); free(pi->path); input_option_free_list(>options); +pi->next = NULL; free(pi); } @@ -145,6 +146,9 @@ KdFreeKeyboard(KdKeyboardInfo * ki) free(ki->xkbRules); free(ki->xkbModel); free(ki->xkbLayout); +free(ki->xkbVariant); +free(ki->xkbOptions); +input_option_free_list(>options); ki->next = NULL; free(ki); } diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index a0c1565..49c8bb6 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -51,6 +51,10 @@ #include "inpututils.h" #include "optionstr.h" +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include +#endif + #ifdef KDRIVE_EVDEV #define DEV_INPUT_EVENT_PREFIX "/dev/input/event" #define DEV_INPUT_EVENT_PREFIX_LEN (sizeof(DEV_INPUT_EVENT_PREFIX) - 1) @@ -396,7 +400,8 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff) #endif if (!pi->driver) { if (!pi->driverPrivate) { -ErrorF("no driver specified for %s\n", pi->name); +ErrorF("no driver specified for pointer device \"%s\" (%s)\n", + pi->name ? pi->name : "(unnamed)", pi->path); return BadImplementation; } @@ -716,7 +721,8 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) #endif if (!ki->driver) { if (!ki->driverPrivate) { -ErrorF("no driver specified!\n"); +ErrorF("no driver specified for keyboard device \"%s\" (%s)\n", + ki->name ? ki->name : "(unnamed)", ki->path); return BadImplementation; } @@ -890,6 +896,8 @@ KdNewKeyboard(void) ki->bellDuration = 200; ki->next = NULL; ki->options = NULL; +ki->name = strdup("Generic Keyboard"); +ki->path = NULL; ki->xkbRules = strdup(XKB_DFLT_RULES); ki->xkbModel = strdup(XKB_DFLT_MODEL); ki->xkbLayout = strdup(XKB_DFLT_LAYOUT); @@ -1073,18 +1081,52 @@ KdParseKbdOptions(KdKeyboardInfo * ki) const char *key = input_option_get_key(option); const
[PATCH v6 RFC 05/10] kdrive: update evdev keyboard LEDs (#22302)
From: Mikhail Krivtsov <mikhail.krivt...@gmail.com> When one hits {Num,Caps,Scroll}Lock key on a Xephyr's keyboard, keyboard itself works as expected but LEDs are not updated and always stay in off. Currently logical LEDs are propagated to physical keyboard LEDs for "CoreKeyboard" only. All "kdrive" keyboards are not "CoreKeyboard" and LEDs of "kdrive" keyboards are always "dead". One possible solution is cloning "CoreKeyboard" LEDs to all "kdrive" keyboards. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=22302 Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/linux/evdev.c | 11 --- hw/kdrive/src/kinput.c | 23 +++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c index 63e8409..fecbae4 100644 --- a/hw/kdrive/linux/evdev.c +++ b/hw/kdrive/linux/evdev.c @@ -440,10 +440,16 @@ EvdevKbdEnable(KdKeyboardInfo * ki) static void EvdevKbdLeds(KdKeyboardInfo * ki, int leds) { -/*struct input_event event; +struct input_event event; Kevdev *ke; +if (!ki) return; // This shouldn't happen but just for safety. -ki->driverPrivate = ke; +ke = ki->driverPrivate; +if (!ke) { + ErrorF("[%s:%u:%s] can't update LEDs of _disabled_ evdev keyboard\n", + __FILE__, __LINE__, __FUNCTION__); + return; +} memset(, 0, sizeof(event)); @@ -466,7 +472,6 @@ EvdevKbdLeds(KdKeyboardInfo * ki, int leds) event.code = LED_COMPOSE; event.value = leds & (1 << 3) ? 1 : 0; write(ke->fd, (char *) , sizeof(event)); -*/ } static void diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 49c8bb6..1da4537 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -607,6 +607,28 @@ KdSetLed(KdKeyboardInfo * ki, int led, Bool on) KdSetLeds(ki, ki->dixdev->kbdfeed->ctrl.leds); } +/* + * For unknown reason, logical keyboard LEDs are propagated to physical + * keyboard LEDs for "CoreKeyboard" only. All "kdrive" keyboards are + * not "CoreKeyboard" and LEDs of "kdrive" keyboards are always "dead". + * As workaround, the following function will clone "CoreKeyboard" LEDs + * to all "kdrive" keyboards. + */ +static void +KdCloneCoreLEDs(void) +{ +DeviceIntPtr pCoreKeyboard = inputInfo.keyboard; +if (pCoreKeyboard && pCoreKeyboard->kbdfeed) { + Leds leds = pCoreKeyboard->kbdfeed->ctrl.leds; + KdKeyboardInfo *tmp; + for (tmp = kdKeyboards; tmp; tmp = tmp->next) { + if (tmp->leds != leds) { +KdSetLeds(tmp, tmp->leds = leds); + } +} +} +} + void KdSetPointerMatrix(KdPointerMatrix * matrix) { @@ -2198,6 +2220,7 @@ ProcessInputEvents(void) if (kdSwitchPending) KdProcessSwitch(); KdCheckLock(); +KdCloneCoreLEDs(); } /* At the moment, absolute/relative is up to the client. */ -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 00/10] Xephyr input hotplugging support and other additions for single-GPU multi-seat
MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sorry for the insistence, but now that xorg-server 1.18 is on its way, I would really appreciate if someone could review this patch series in time for 1.18 release, so it can hopefully appear in next Ubuntu LTS/Debian stable release. However, input handling support in kdrive seems currently unmaintained, am I right? PLEASE NOTE: Xephyr is NOT my preferred approach for single-GPU multi-seat configuration (mainly due to its current evdev-based limited support for handling input devices --- no touchpads, no touchscreens, no joysticks), but it's the easiest one to implement in the moment. The best approach by far (in Linux specifically) would require KMS device node splitting, as proposed in https://dvdhrm.wordpress.com/2013/09/01/splitting-drm-and-kms-device-nodes/. Until such a solution is completely implemented and supported by video drivers, the most common approach for single-GPU multi-seat configuration is based on nested X servers, i.e. a bare Xorg server spanning all desired video outputs, on top of which we launch a nested X server for each output. My preferred approach in this case would be Xorg itself with xf86-video-nested driver, but the latter is currently unmaintained, and I have no knowledge about video drivers and no spare time to maintain it. The other approach (historically the most used one) is Xephyr: it's currently actively maintained, it has reasonable graphics performance (compared to xf86-video-nested) and it has a minimal support for input devices (keyboard and mouse only), but it still have some gaps for a more comfortable multi-seat configuration. This patch series intend to fill them. This is the v6 of patch series which provides some missing parts for full single-GPU multi-seat support in Xephyr. The main difference to v5 is that now Xephyr also ignores option "-novtswitch" (passed by default for seat0 in some DMs), so that it can be also used as a seat0 X server in a strict single-GPU dual-seat setup (my previous tests only involve a dual-GPU 3-seat setup, where seat0 X server is completely decoupled from the other ones). Example of Xephyr-based seat configuration in LightDM 1.12 or newer based on this patch series (provided that a bare X server on display number :90, with two outputs named LVDS and VGA, is already running): [Seat:seat-LVDS] xserver-command=Xephyr -dpi 96 -sw-cursor -xkbrules evdev -xkblayout br -xkbmodel abnt2 -host-display :90 -output LVDS [Seat:seat-VGA] xserver-command=Xephyr -dpi 96 -sw-cursor -xkbrules evdev -xkblayout br -xkbmodel abnt2 -host-display :90 -output VGA ** HISTORY ** v5 only builds input-hotplugging for kdrive if one of CONFIG_UDEV or CONFIG_HAL options is enabled. v4 drops explicit option -input-hotplug. Since input hot-plugging support in Xephyr is very unlikely to be used outside multi-seat context, it's now automatically enabled if, and only if, -seat option is passed. v3 includes two patches: one that introduces a new flag to better distinguish between real keyboards and other key input devices (so that kdrive can grab keyboards only), and another one that prevents kdrive evdev driver from deliberately renaming keyboard and pointer devices if they are already named (e.g. from udev), with potential memory leaks. v2 fixes some problems found in v1, like double-free errors for some InputOption objects, and memory corruptions when a USB keyboard or mouse is unplugged and replugged several times, due to the fact that their FDs may not be successfully unregistered when they are unplugged. It also brings new patches for improving NewInputDeviceRequest() implementation in hw/kdrive/src/kinput.c (making use of KdParseKbdOptions() and KdParsePointerOptions() as requested), and some other minor changes. Some patches provide new command-line options to make it easier to launch Xephyr directly from display manager, rather than from within a user session. One of them fixes an issue where Xephyr keyboards' LEDs are not toggled when NumLock, CapsLock, and ScrollLock are pressed. The most significant one introduces input hotplugging support for keyboards and pointers with both hal and udev backends. Laércio de Sousa (9): ephyr: allow passing explictly host X server display number and/or authorization file path kdrive: fix up NewInputDeviceRequest() implementation kdrive: set "evdev" driver for input devices automatically, if available. kdrive: introduce input hot-plugging support for udev and hal backends (#33140) kdrive: add options to set default XKB properties ephyr: ignore "-novtswitch", "-sharevts", and "-layout seatXXX" command-line options ephyr: move host_has_extension() implementation to hostx.c config/udev: better distinguish between real keyboards and other key input devices kdrive: don't let evdev driver overwrite existing device names Mikhail
[PATCH v6 RFC 06/10] kdrive: add options to set default XKB properties
This patch introduces convenient command-line options -xkbrules, -xkbmodel, -xkblayout, -xkbvariant, and -xkboptions, to set default values for these properties. These options can be handful in cases where corresponding values can't be taken from devices' udev properties, and compile-time default values don't match user locale. Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/src/kdrive.c | 40 hw/kdrive/src/kinput.c | 16 +++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 8930ace..1578458 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -85,6 +85,11 @@ char *kdSwitchCmd; DDXPointRec kdOrigin; Bool kdHasPointer = FALSE; Bool kdHasKbd = FALSE; +const char *kdGlobalXkbRules = NULL; +const char *kdGlobalXkbModel = NULL; +const char *kdGlobalXkbLayout = NULL; +const char *kdGlobalXkbVariant = NULL; +const char *kdGlobalXkbOptions = NULL; static Bool kdCaughtSignal = FALSE; @@ -451,6 +456,11 @@ KdUseMsg(void) ("-mouse driver [,n,,options]Specify the pointer driver and its options (n is the number of buttons)\n"); ErrorF ("-keybd driver [,,options] Specify the keyboard driver and its options\n"); +ErrorF("-xkbrulesSet default XkbRules value (can be overriden by -keybd options)\n"); +ErrorF("-xkbmodelSet default XkbModel value (can be overriden by -keybd options)\n"); +ErrorF("-xkblayout Set default XkbLayout value (can be overriden by -keybd options)\n"); +ErrorF("-xkbvariant Set default XkbVariant value (can be overriden by -keybd options)\n"); +ErrorF("-xkboptions Set default XkbOptions value (can be overriden by -keybd options)\n"); ErrorF("-zaphod Disable cursor screen switching\n"); ErrorF("-2button Emulate 3 button mouse\n"); ErrorF("-3button Disable 3 button mouse emulation\n"); @@ -559,6 +569,36 @@ KdProcessArgument(int argc, char **argv, int i) sscanf(argv[i], "vt%2d", ) == 1) { return 1; } +if (!strcmp(argv[i], "-xkbrules")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbRules = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkbmodel")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbModel = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkblayout")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbLayout = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkbvariant")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbVariant = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], "-xkboptions")) { +if (i + 1 >= argc) +UseMsg(); +kdGlobalXkbOptions = argv[i + 1]; +return 2; +} if (!strcmp(argv[i], "-mouse") || !strcmp(argv[i], "-pointer")) { if (i + 1 >= argc) UseMsg(); diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 1da4537..8510ccd 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -102,6 +102,12 @@ static int kdNumInputFds; extern Bool kdRawPointerCoordinates; +extern const char *kdGlobalXkbRules; +extern const char *kdGlobalXkbModel; +extern const char *kdGlobalXkbLayout; +extern const char *kdGlobalXkbVariant; +extern const char *kdGlobalXkbOptions; + static void KdSigio(int sig) { @@ -920,11 +926,11 @@ KdNewKeyboard(void) ki->options = NULL; ki->name = strdup("Generic Keyboard"); ki->path = NULL; -ki->xkbRules = strdup(XKB_DFLT_RULES); -ki->xkbModel = strdup(XKB_DFLT_MODEL); -ki->xkbLayout = strdup(XKB_DFLT_LAYOUT); -ki->xkbVariant = strdup(XKB_DFLT_VARIANT); -ki->xkbOptions = strdup(XKB_DFLT_OPTIONS); +ki->xkbRules = strdup(kdGlobalXkbRules ? kdGlobalXkbRules : XKB_DFLT_RULES); +ki->xkbModel = strdup(kdGlobalXkbModel ? kdGlobalXkbModel : XKB_DFLT_MODEL); +ki->xkbLayout = strdup(kdGlobalXkbLayout ? kdGlobalXkbLayout : XKB_DFLT_LAYOUT); +ki->xkbVariant = strdup(kdGlobalXkbVariant ? kdGlobalXkbVariant :XKB_DFLT_VARIANT); +ki->xkbOptions = strdup(kdGlobalXkbOptions ? kdGlobalXkbOptions : XKB_DFLT_OPTIONS); return ki; } -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v6 RFC 10/10] kdrive: don't let evdev driver overwrite existing device names
KDrive evdev driver deliberately name grabbed devices as "Evdev mouse" or "Evdev keyboard". This patch will make it skip this step if grabbed devices are already named (i.e. from udev). Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br> --- hw/kdrive/linux/evdev.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c index fecbae4..57a6dbf 100644 --- a/hw/kdrive/linux/evdev.c +++ b/hw/kdrive/linux/evdev.c @@ -220,7 +220,8 @@ EvdevPtrInit(KdPointerInfo * pi) close(fd); -pi->name = strdup("Evdev mouse"); +if (!pi->name) +pi->name = strdup("Evdev mouse"); return Success; } @@ -390,7 +391,8 @@ EvdevKbdInit(KdKeyboardInfo * ki) close(fd); -ki->name = strdup("Evdev keyboard"); +if (!ki->name) +ki->name = strdup("Evdev keyboard"); readMapping(ki); -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v5 RESEND RFC 10/10] kdrive: don't let evdev driver overwrite existing device names
KDrive evdev driver deliberately name grabbed devices as Evdev mouse or Evdev keyboard. This patch will make it skip this step if grabbed devices are already named (i.e. from udev). Signed-off-by: Laércio de Sousa laercioso...@sme-mogidascruzes.sp.gov.br --- hw/kdrive/linux/evdev.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c index fecbae4..57a6dbf 100644 --- a/hw/kdrive/linux/evdev.c +++ b/hw/kdrive/linux/evdev.c @@ -220,7 +220,8 @@ EvdevPtrInit(KdPointerInfo * pi) close(fd); -pi-name = strdup(Evdev mouse); +if (!pi-name) +pi-name = strdup(Evdev mouse); return Success; } @@ -390,7 +391,8 @@ EvdevKbdInit(KdKeyboardInfo * ki) close(fd); -ki-name = strdup(Evdev keyboard); +if (!ki-name) +ki-name = strdup(Evdev keyboard); readMapping(ki); -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v5 RESEND RFC 04/10] kdrive: introduce input hot-plugging support for udev and hal backends (#33140)
This patch introduces input hot-plugging support for kdrive-based applications in multi-seat context. This feature is enabled by passing -seat option with desired seat name. All keyboard/mouse devices assigned to that seat will be automatically grabbed by kdrive. It supports udev and hal backends for input hot-plugging support. Another patches may be required for wscons backend. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=33140 Signed-off-by: Laércio de Sousa laercioso...@sme-mogidascruzes.sp.gov.br --- hw/kdrive/src/Makefile.am | 8 ++ hw/kdrive/src/kdrive.c| 39 + hw/kdrive/src/kinfo.c | 4 + hw/kdrive/src/kinput.c| 212 +- 4 files changed, 241 insertions(+), 22 deletions(-) diff --git a/hw/kdrive/src/Makefile.am b/hw/kdrive/src/Makefile.am index d69f0dd..b7f94b0 100644 --- a/hw/kdrive/src/Makefile.am +++ b/hw/kdrive/src/Makefile.am @@ -23,3 +23,11 @@ libkdrive_la_SOURCES = \ kshadow.c \ $(KDRIVE_XV_SOURCES) \ $(top_srcdir)/mi/miinitext.c + +if CONFIG_UDEV +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +else +if CONFIG_HAL +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +endif +endif diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index dddbe6e..8930ace 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -45,6 +45,10 @@ #include signal.h +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include hotplug.h +#endif + typedef struct _kdDepths { CARD8 depth; CARD8 bpp; @@ -1125,6 +1129,11 @@ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) KdAddScreen(pScreenInfo, screen, argc, argv); OsRegisterSigWrapper(KdSignalWrapper); + +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +if (SeatId) /* Enable input hot-plugging */ +config_pre_init(); +#endif } void @@ -1143,3 +1152,33 @@ DPMSSupported(void) { return FALSE; } + +/* These stubs can be safely removed once we can + * split input and GPU parts in hotplug.h et al. */ +#ifdef CONFIG_UDEV_KMS +void +NewGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} + +void +DeleteGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} +#endif + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor) +{ +return NULL; +} + +void +systemd_logind_release_fd(int _major, int _minor, int fd) +{ +} + +void +systemd_logind_vtenter(void) +{ +} diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c index 01ae1e4..f91d575 100644 --- a/hw/kdrive/src/kinfo.c +++ b/hw/kdrive/src/kinfo.c @@ -134,6 +134,7 @@ KdFreePointer(KdPointerInfo * pi) free(pi-name); free(pi-path); input_option_free_list(pi-options); +pi-next = NULL; free(pi); } @@ -145,6 +146,9 @@ KdFreeKeyboard(KdKeyboardInfo * ki) free(ki-xkbRules); free(ki-xkbModel); free(ki-xkbLayout); +free(ki-xkbVariant); +free(ki-xkbOptions); +input_option_free_list(ki-options); ki-next = NULL; free(ki); } diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index a0c1565..49c8bb6 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -51,6 +51,10 @@ #include inpututils.h #include optionstr.h +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include hotplug.h +#endif + #ifdef KDRIVE_EVDEV #define DEV_INPUT_EVENT_PREFIX /dev/input/event #define DEV_INPUT_EVENT_PREFIX_LEN (sizeof(DEV_INPUT_EVENT_PREFIX) - 1) @@ -396,7 +400,8 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff) #endif if (!pi-driver) { if (!pi-driverPrivate) { -ErrorF(no driver specified for %s\n, pi-name); +ErrorF(no driver specified for pointer device \%s\ (%s)\n, + pi-name ? pi-name : (unnamed), pi-path); return BadImplementation; } @@ -716,7 +721,8 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) #endif if (!ki-driver) { if (!ki-driverPrivate) { -ErrorF(no driver specified!\n); +ErrorF(no driver specified for keyboard device \%s\ (%s)\n, + ki-name ? ki-name : (unnamed), ki-path); return BadImplementation; } @@ -890,6 +896,8 @@ KdNewKeyboard(void) ki-bellDuration = 200; ki-next = NULL; ki-options = NULL; +ki-name = strdup(Generic Keyboard); +ki-path = NULL; ki-xkbRules = strdup(XKB_DFLT_RULES); ki-xkbModel = strdup(XKB_DFLT_MODEL); ki-xkbLayout = strdup(XKB_DFLT_LAYOUT); @@ -1073,18 +1081,52 @@ KdParseKbdOptions(KdKeyboardInfo * ki) const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); -if (strcasecmp(key, XkbRules) == 0) +if ( +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +strcasecmp(key, xkb_rules) == 0 || +#endif +strcasecmp(key, XkbRules
[PATCH v5 RESEND RFC 06/10] kdrive: add options to set default XKB properties
This patch introduces convenient command-line options -xkbrules, -xkbmodel, -xkblayout, -xkbvariant, and -xkboptions, to set default values for these properties. These options can be handful in cases where corresponding values can't be taken from devices' udev properties, and compile-time default values don't match user locale. Signed-off-by: Laércio de Sousa laercioso...@sme-mogidascruzes.sp.gov.br --- hw/kdrive/src/kdrive.c | 40 hw/kdrive/src/kinput.c | 16 +++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 8930ace..1578458 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -85,6 +85,11 @@ char *kdSwitchCmd; DDXPointRec kdOrigin; Bool kdHasPointer = FALSE; Bool kdHasKbd = FALSE; +const char *kdGlobalXkbRules = NULL; +const char *kdGlobalXkbModel = NULL; +const char *kdGlobalXkbLayout = NULL; +const char *kdGlobalXkbVariant = NULL; +const char *kdGlobalXkbOptions = NULL; static Bool kdCaughtSignal = FALSE; @@ -451,6 +456,11 @@ KdUseMsg(void) (-mouse driver [,n,,options]Specify the pointer driver and its options (n is the number of buttons)\n); ErrorF (-keybd driver [,,options] Specify the keyboard driver and its options\n); +ErrorF(-xkbrulesSet default XkbRules value (can be overriden by -keybd options)\n); +ErrorF(-xkbmodelSet default XkbModel value (can be overriden by -keybd options)\n); +ErrorF(-xkblayout Set default XkbLayout value (can be overriden by -keybd options)\n); +ErrorF(-xkbvariant Set default XkbVariant value (can be overriden by -keybd options)\n); +ErrorF(-xkboptions Set default XkbOptions value (can be overriden by -keybd options)\n); ErrorF(-zaphod Disable cursor screen switching\n); ErrorF(-2button Emulate 3 button mouse\n); ErrorF(-3button Disable 3 button mouse emulation\n); @@ -559,6 +569,36 @@ KdProcessArgument(int argc, char **argv, int i) sscanf(argv[i], vt%2d, kdVirtualTerminal) == 1) { return 1; } +if (!strcmp(argv[i], -xkbrules)) { +if (i + 1 = argc) +UseMsg(); +kdGlobalXkbRules = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], -xkbmodel)) { +if (i + 1 = argc) +UseMsg(); +kdGlobalXkbModel = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], -xkblayout)) { +if (i + 1 = argc) +UseMsg(); +kdGlobalXkbLayout = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], -xkbvariant)) { +if (i + 1 = argc) +UseMsg(); +kdGlobalXkbVariant = argv[i + 1]; +return 2; +} +if (!strcmp(argv[i], -xkboptions)) { +if (i + 1 = argc) +UseMsg(); +kdGlobalXkbOptions = argv[i + 1]; +return 2; +} if (!strcmp(argv[i], -mouse) || !strcmp(argv[i], -pointer)) { if (i + 1 = argc) UseMsg(); diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 1da4537..8510ccd 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -102,6 +102,12 @@ static int kdNumInputFds; extern Bool kdRawPointerCoordinates; +extern const char *kdGlobalXkbRules; +extern const char *kdGlobalXkbModel; +extern const char *kdGlobalXkbLayout; +extern const char *kdGlobalXkbVariant; +extern const char *kdGlobalXkbOptions; + static void KdSigio(int sig) { @@ -920,11 +926,11 @@ KdNewKeyboard(void) ki-options = NULL; ki-name = strdup(Generic Keyboard); ki-path = NULL; -ki-xkbRules = strdup(XKB_DFLT_RULES); -ki-xkbModel = strdup(XKB_DFLT_MODEL); -ki-xkbLayout = strdup(XKB_DFLT_LAYOUT); -ki-xkbVariant = strdup(XKB_DFLT_VARIANT); -ki-xkbOptions = strdup(XKB_DFLT_OPTIONS); +ki-xkbRules = strdup(kdGlobalXkbRules ? kdGlobalXkbRules : XKB_DFLT_RULES); +ki-xkbModel = strdup(kdGlobalXkbModel ? kdGlobalXkbModel : XKB_DFLT_MODEL); +ki-xkbLayout = strdup(kdGlobalXkbLayout ? kdGlobalXkbLayout : XKB_DFLT_LAYOUT); +ki-xkbVariant = strdup(kdGlobalXkbVariant ? kdGlobalXkbVariant :XKB_DFLT_VARIANT); +ki-xkbOptions = strdup(kdGlobalXkbOptions ? kdGlobalXkbOptions : XKB_DFLT_OPTIONS); return ki; } -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v5 RESEND RFC 08/10] ephyr: move host_has_extension() implementation to hostx.c
This is a trivial patch that moves host_has_extension() implementation from ephyr.c to hostx.c so that it can be called by hostx.c internal functions. Also rename function to hostx_has_extension() for consistency. Signed-off-by: Laércio de Sousa laercioso...@sme-mogidascruzes.sp.gov.br --- hw/kdrive/ephyr/ephyr.c | 12 +--- hw/kdrive/ephyr/ephyrdriext.c | 4 ++-- hw/kdrive/ephyr/ephyrglxext.c | 2 +- hw/kdrive/ephyr/hostx.c | 16 hw/kdrive/ephyr/hostx.h | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 164ebdc..1f7eb5f 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -71,16 +71,6 @@ Bool EphyrWantResize = 0; Bool EphyrWantNoHostGrab = 0; Bool -host_has_extension(xcb_extension_t *extension) -{ -const xcb_query_extension_reply_t *rep; - -rep = xcb_get_extension_data(hostx_get_xcbconn(), extension); - -return rep rep-present; -} - -Bool ephyrInitialize(KdCardInfo * card, EphyrPriv * priv) { OsSignal(SIGUSR1, hostx_handle_signal); @@ -670,7 +660,7 @@ ephyrInitScreen(ScreenPtr pScreen) } #endif /*XV*/ #ifdef XF86DRI -if (!ephyrNoDRI !host_has_extension(xcb_xf86dri_id)) { +if (!ephyrNoDRI !hostx_has_extension(xcb_xf86dri_id)) { EPHYR_LOG(host x does not support DRI. Disabling DRI forwarding\n); ephyrNoDRI = TRUE; } diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c index 748b608..3703adf 100644 --- a/hw/kdrive/ephyr/ephyrdriext.c +++ b/hw/kdrive/ephyr/ephyrdriext.c @@ -1321,12 +1321,12 @@ ephyrDRIExtensionInit(ScreenPtr a_screen) EphyrDRIScreenPrivPtr screen_priv = NULL; EPHYR_LOG(enter\n); -if (!host_has_extension(xcb_xf86dri_id)) { +if (!hostx_has_extension(xcb_xf86dri_id)) { EPHYR_LOG(host does not have DRI extension\n); goto out; } EPHYR_LOG(host X does have DRI extension\n); -if (!host_has_extension(xcb_shape_id)) { +if (!hostx_has_extension(xcb_shape_id)) { EPHYR_LOG(host does not have XShape extension\n); goto out; } diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c index 248689e..c6d1569 100644 --- a/hw/kdrive/ephyr/ephyrglxext.c +++ b/hw/kdrive/ephyr/ephyrglxext.c @@ -84,7 +84,7 @@ ephyrHijackGLXExtension(void) { const void *(*dispatch_functions)[2]; -if (!host_has_extension(xcb_glx_id)) { +if (!hostx_has_extension(xcb_glx_id)) { EPHYR_LOG(host X does not have GLX\n); return FALSE; } diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index dc265d5..5406938 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -99,6 +99,16 @@ int ephyrResNameFromCmd = 0; char *ephyrTitle = NULL; Bool ephyr_glamor = FALSE; +Bool +hostx_has_extension(xcb_extension_t *extension) +{ +const xcb_query_extension_reply_t *rep; + +rep = xcb_get_extension_data(HostX.conn, extension); + +return rep rep-present; +} + static void hostx_set_fullscreen_hint(void); @@ -240,7 +250,7 @@ hostx_get_output_geometry(const char *output, xcb_randr_get_crtc_info_reply_t *crtc_info_r; /* First of all, check for extension */ -if (!xcb_get_extension_data(HostX.conn, xcb_randr_id)-present) +if (!hostx_has_extension(xcb_randr_id)) { fprintf(stderr, \nHost X server does not support RANDR extension (or it's disabled).\n); exit(1); @@ -422,7 +432,6 @@ hostx_init(void) char *tmpstr; char *class_hint; size_t class_len; -const xcb_query_extension_reply_t *shm_rep; xcb_screen_t *xscreen; xcb_rectangle_t rect = { 0, 0, 1, 1 }; @@ -632,8 +641,7 @@ hostx_init(void) } /* Try to get share memory ximages for a little bit more speed */ -shm_rep = xcb_get_extension_data(HostX.conn, xcb_shm_id); -if (!shm_rep || !shm_rep-present || getenv(XEPHYR_NO_SHM)) { +if (!hostx_has_extension(xcb_shm_id) || getenv(XEPHYR_NO_SHM)) { fprintf(stderr, \nXephyr unable to use SHM XImages\n); HostX.have_shm = FALSE; } diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index 93aaa50..9299e8d 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -182,7 +182,7 @@ int hostx_set_window_geometry(int a_win, EphyrBox * a_geo); int hostx_set_window_bounding_rectangles(int a_window, EphyrRect * a_rects, int a_num_rects); -int host_has_extension(xcb_extension_t *extension); +int hostx_has_extension(xcb_extension_t *extension); #ifdef XF86DRI int hostx_lookup_peer_window(void *a_local_window, -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v5 RESEND RFC 09/10] config/udev: better distinguish between real keyboards and other key input devices
This patch introduces a new flag ATTR_KEY for hotplugged input devices, so we can better distinguish between real keyboards (i.e. devices with udev property ID_INPUT_KEYBOARD=1) and other key input devices like lid switches, power buttons, etc. All supported hotplug backends (udev, hal, and wscons) will set both flags ATTR_KEY and ATTR_KEYBOARD for real keyboards, but udev backend will set ATTR_KEY, but not ATTR_KEYBOARD, for non-keyboard key input devices (hal and wscons will set both flags in any case). With this distinction, kdrive input hotplugging mechanism will be allowed to only grab real keyboards, as other key input devices are currently not supported. In order to don't break current behaviour, this patch will replace all ATTR_KEYBOARD occurrences with ATTR_KEY in hw/xfree86/common/xf86Xinput.c. Signed-off-by: Laércio de Sousa laercioso...@sme-mogidascruzes.sp.gov.br --- config/hal.c | 2 +- config/udev.c | 4 config/wscons.c| 2 +- hw/kdrive/src/kinput.c | 4 +++- hw/xfree86/common/xf86Xinput.c | 2 +- include/input.h| 13 +++-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/config/hal.c b/config/hal.c index ea574ca..c76eced 100644 --- a/config/hal.c +++ b/config/hal.c @@ -170,7 +170,7 @@ device_added(LibHalContext * hal_ctx, const char *udi) free(hal_tags); if (libhal_device_query_capability(hal_ctx, udi, input.keys, NULL)) -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; if (libhal_device_query_capability(hal_ctx, udi, input.mouse, NULL)) attrs.flags |= ATTR_POINTER; if (libhal_device_query_capability(hal_ctx, udi, input.joystick, NULL)) diff --git a/config/udev.c b/config/udev.c index 28c2658..958c95f 100644 --- a/config/udev.c +++ b/config/udev.c @@ -240,6 +240,10 @@ device_added(struct udev_device *udev_device) } else if (!strcmp(key, ID_INPUT_KEY)) { LOG_PROPERTY(path, key, value); +attrs.flags |= ATTR_KEY; +} +else if (!strcmp(key, ID_INPUT_KEYBOARD)) { +LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; } else if (!strcmp(key, ID_INPUT_MOUSE)) { diff --git a/config/wscons.c b/config/wscons.c index fb114bd..ee45675 100644 --- a/config/wscons.c +++ b/config/wscons.c @@ -163,7 +163,7 @@ wscons_add_keyboard(void) } kbd_config_done: -attrs.flags |= ATTR_KEYBOARD; +attrs.flags |= ATTR_KEY | ATTR_KEYBOARD; rc = NewInputDeviceRequest(input_options, attrs, dev); if (rc != Success) goto unwind; diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 8510ccd..6594f4f 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -2401,7 +2401,9 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, *pdev = ki-dixdev; } else { -ErrorF(unrecognised device identifier!\n); +ErrorF(unrecognised device identifier: %s\n, + input_option_get_value(input_option_find(optionsdup, +device))); input_option_free_list(optionsdup); return BadValue; } diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index a5b0568..bb2fbb7 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -632,7 +632,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev, /* MatchIs* booleans */ if (iclass-is_keyboard.set -iclass-is_keyboard.val != ! !(attrs-flags ATTR_KEYBOARD)) +iclass-is_keyboard.val != ! !(attrs-flags ATTR_KEY)) return FALSE; if (iclass-is_pointer.set iclass-is_pointer.val != ! !(attrs-flags ATTR_POINTER)) diff --git a/include/input.h b/include/input.h index d8bd9c6..19ef0c9 100644 --- a/include/input.h +++ b/include/input.h @@ -230,12 +230,13 @@ typedef struct _InputAttributes { uint32_t flags; } InputAttributes; -#define ATTR_KEYBOARD (10) -#define ATTR_POINTER (11) -#define ATTR_JOYSTICK (12) -#define ATTR_TABLET (13) -#define ATTR_TOUCHPAD (14) -#define ATTR_TOUCHSCREEN (15) +#define ATTR_KEY (10) +#define ATTR_KEYBOARD (11) +#define ATTR_POINTER (12) +#define ATTR_JOYSTICK (13) +#define ATTR_TABLET (14) +#define ATTR_TOUCHPAD (15) +#define ATTR_TOUCHSCREEN (16) /* Key/Button has been run through all input processing and events sent to clients. */ #define KEY_PROCESSED 1 -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v5 RESEND RFC 01/10] ephyr: allow passing explictly host X server display number and/or authorization file path
This patch introduces two command-line options for Xephyr: * -host-display: set Xephyr DISPLAY environment variable to host X server display number * -host-auth:set Xephyr XAUTHORITY environment variable to host X server authorization file path These options are particularly useful when Xephyr is launched directly from display manager, because DISPLAY and/or XAUTHORITY environment variables may not be set when it's launched. Signed-off-by: Laércio de Sousa laercioso...@sme-mogidascruzes.sp.gov.br --- hw/kdrive/ephyr/ephyrinit.c | 20 1 file changed, 20 insertions(+) diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 8fbaf1d..0a42c96 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -141,6 +141,8 @@ ddxUseMsg(void) KdUseMsg(); ErrorF(\nXephyr Option Usage:\n); +ErrorF(-host-displayhost X server display number\n); +ErrorF(-host-auth host X server authorization file path\n); ErrorF(-parent XIDUse existing window as Xephyr root win\n); ErrorF(-sw-cursor Render cursors in software in Xephyr\n); ErrorF(-fullscreen Attempt to run Xephyr fullscreen\n); @@ -369,6 +371,24 @@ ddxProcessArgument(int argc, char **argv, int i) EphyrWantNoHostGrab = 1; return 2; } +else if (!strcmp(argv[i], -host-display)) { +if (i + 1 argc) { +setenv(DISPLAY, argv[i + 1], 1); +return 2; +} + +UseMsg(); +exit(1); +} +else if (!strcmp(argv[i], -host-auth)) { +if (i + 1 argc) { +setenv(XAUTHORITY, argv[i + 1], 1); +return 2; +} + +UseMsg(); +exit(1); +} return KdProcessArgument(argc, argv, i); } -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH v5 RESEND RFC 02/10] kdrive: fix up NewInputDeviceRequest() implementation
This patch simplifies NewInputDeviceRequest() implementation in kinput.c, making use of improved KdParseKbdOptions()/KdParsePointerOptions() and merging several if (ki)/if (pi) clauses. Signed-off-by: Laércio de Sousa laercioso...@sme-mogidascruzes.sp.gov.br --- hw/kdrive/src/kinput.c | 76 -- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 057f53b..12e9128 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -1080,6 +1080,8 @@ KdParseKbdOptions(KdKeyboardInfo * ki) ki-xkbOptions = strdup(value); else if (!strcasecmp(key, device)) ki-path = strdup(value); +else if (!strcasecmp(key, driver)) +ki-driver = KdFindKeyboardDriver(value); else ErrorF(Kbd option key (%s) of value (%s) not assigned!\n, key, value); @@ -1160,18 +1162,20 @@ KdParsePointerOptions(KdPointerInfo * pi) const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); -if (!strcmp(key, emulatemiddle)) +if (!strcasecmp(key, emulatemiddle)) pi-emulateMiddleButton = TRUE; -else if (!strcmp(key, noemulatemiddle)) +else if (!strcasecmp(key, noemulatemiddle)) pi-emulateMiddleButton = FALSE; -else if (!strcmp(key, transformcoord)) +else if (!strcasecmp(key, transformcoord)) pi-transformCoordinates = TRUE; -else if (!strcmp(key, rawcoord)) +else if (!strcasecmp(key, rawcoord)) pi-transformCoordinates = FALSE; else if (!strcasecmp(key, device)) pi-path = strdup(value); else if (!strcasecmp(key, protocol)) pi-protocol = strdup(value); +else if (!strcasecmp(key, driver)) +pi-driver = KdFindPointerDriver(value); else ErrorF(Pointer option key (%s) of value (%s) not assigned!\n, key, value); @@ -2187,68 +2191,48 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, #endif } -if (!ki !pi) { -ErrorF(unrecognised device identifier!\n); -return BadValue; -} - -/* FIXME: change this code below to use KdParseKbdOptions and - * KdParsePointerOptions */ -nt_list_for_each_entry(option, options, list.next) { -const char *key = input_option_get_key(option); -const char *value = input_option_get_value(option); +if (pi) { +pi-options = options; +KdParsePointerOptions(pi); -if (strcmp(key, device) == 0) { -if (pi value) -pi-path = strdup(value); -else if (ki value) -ki-path = strdup(value); -} -else if (strcmp(key, driver) == 0) { -if (pi) { -pi-driver = KdFindPointerDriver(value); -if (!pi-driver) { -ErrorF(couldn't find driver!\n); -KdFreePointer(pi); -return BadValue; -} -pi-options = options; -} -else if (ki) { -ki-driver = KdFindKeyboardDriver(value); -if (!ki-driver) { -ErrorF(couldn't find driver!\n); -KdFreeKeyboard(ki); -return BadValue; -} -ki-options = options; -} +if (!pi-driver) { +ErrorF(couldn't find driver!\n); +KdFreePointer(pi); +return BadValue; } -} -if (pi) { if (KdAddPointer(pi) != Success || ActivateDevice(pi-dixdev, TRUE) != Success || EnableDevice(pi-dixdev, TRUE) != TRUE) { ErrorF(couldn't add or enable pointer\n); return BadImplementation; } + +*pdev = pi-dixdev; } else if (ki) { +ki-options = options; +KdParseKbdOptions(ki); + +if (!ki-driver) { +ErrorF(couldn't find driver!\n); +KdFreeKeyboard(ki); +return BadValue; +} + if (KdAddKeyboard(ki) != Success || ActivateDevice(ki-dixdev, TRUE) != Success || EnableDevice(ki-dixdev, TRUE) != TRUE) { ErrorF(couldn't add or enable keyboard\n); return BadImplementation; } -} -if (pi) { -*pdev = pi-dixdev; -} -else if (ki) { *pdev = ki-dixdev; } +else { +ErrorF(unrecognised device identifier!\n); +return BadValue; +} return Success; } -- 2.5.0 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel