# Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
--- a/src/mouse.c Thu Mar 5 11:52:36 2015
+++ b/src/mouse.c Thu Mar 5 11:56:15 2015
@@ -1753,18 +1753,19 @@
ErrorF("assigning %p name=%s\n", device, pInfo->name);
#endif
MouseInitProperties(device);
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1)
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+
break;
case DEVICE_ON:
- pInfo->fd = xf86OpenSerial(pInfo->options);
- if (pInfo->fd == -1)
- xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
- else {
#if defined(__NetBSD__) && defined(WSCONS_SUPPORT) && defined(WSMOUSEIO_SETVERSION)
int version = WSMOUSE_EVENT_VERSION;
if (ioctl(pInfo->fd, WSMOUSEIO_SETVERSION, &version) == -1)
xf86Msg(X_WARNING, "%s: cannot set version\n", pInfo->name);
#endif
+ if (pInfo->fd != -1) {
if (pMse->xisbscale)
pMse->buffer = XisbNew(pInfo->fd, pMse->xisbscale * 4);
else
@@ -1820,8 +1821,6 @@
XisbFree(pMse->buffer);
pMse->buffer = NULL;
}
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft)
{
RemoveBlockAndWakeupHandlers (MouseBlockHandler,
@@ -1832,6 +1831,10 @@
device->public.on = FALSE;
break;
case DEVICE_CLOSE:
+ if (pInfo->fd != -1) {
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ }
free(pMse->mousePriv);
pMse->mousePriv = NULL;
break;