Bug Summary

File:hw/xfree86/common/xf86Events.c
Location:line 683, column 21
Description:Access to field 'next' results in a dereference of a null pointer (loaded from variable 'p')

Annotated Source Code

1/*
2 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Thomas Roell not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Thomas Roell makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
13 *
14 * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 *
22 */
23/*
24 * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
25 *
26 * Permission is hereby granted, free of charge, to any person obtaining a
27 * copy of this software and associated documentation files (the "Software"),
28 * to deal in the Software without restriction, including without limitation
29 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
30 * and/or sell copies of the Software, and to permit persons to whom the
31 * Software is furnished to do so, subject to the following conditions:
32 *
33 * The above copyright notice and this permission notice shall be included in
34 * all copies or substantial portions of the Software.
35 *
36 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
39 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
40 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
41 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42 * OTHER DEALINGS IN THE SOFTWARE.
43 *
44 * Except as contained in this notice, the name of the copyright holder(s)
45 * and author(s) shall not be used in advertising or otherwise to promote
46 * the sale, use or other dealings in this Software without prior written
47 * authorization from the copyright holder(s) and author(s).
48 */
49
50/* [JCH-96/01/21] Extended std reverse map to four buttons. */
51
52#ifdef HAVE_XORG_CONFIG_H1
53#include <xorg-config.h>
54#endif
55
56#include <X11/X.h>
57#include <X11/Xpoll.h>
58#include <X11/Xproto.h>
59#include <X11/Xatom.h>
60#include "misc.h"
61#include "xf86.h"
62#include "xf86Priv.h"
63#define XF86_OS_PRIVS
64#include "xf86_OSlib.h"
65#include <X11/keysym.h>
66
67#ifdef XFreeXDGA1
68#include "dgaproc.h"
69#endif
70
71#include <X11/extensions/XI.h>
72#include <X11/extensions/XIproto.h>
73#include "inputstr.h"
74#include "xf86Xinput.h"
75
76#include "mi.h"
77#include "mipointer.h"
78
79#include "xkbsrv.h"
80#include "xkbstr.h"
81
82#ifdef DPMSExtension1
83#include <X11/extensions/dpmsconst.h>
84#include "dpmsproc.h"
85#endif
86
87#include "xf86platformBus.h"
88#include "systemd-logind.h"
89
90/*
91 * This is a toggling variable:
92 * FALSE = No VT switching keys have been pressed last time around
93 * TRUE = Possible VT switch Pending
94 * (DWH - 12/2/93)
95 *
96 * This has been generalised to work with Linux and *BSD+syscons (DHD)
97 */
98
99Bool VTSwitchEnabled = TRUE1; /* Allows run-time disabling for
100 *BSD and for avoiding VT
101 switches when using the DRI
102 automatic full screen mode.*/
103
104extern fd_set EnabledDevices;
105
106#ifdef XF86PM
107extern void (*xf86OSPMClose) (void);
108#endif
109
110static void xf86VTSwitch(void);
111
112/*
113 * Allow arbitrary drivers or other XFree86 code to register with our main
114 * Wakeup handler.
115 */
116typedef struct x_IHRec {
117 int fd;
118 InputHandlerProc ihproc;
119 void *data;
120 Bool enabled;
121 Bool is_input;
122 struct x_IHRec *next;
123} IHRec, *IHPtr;
124
125static IHPtr InputHandlers = NULL((void*)0);
126
127Bool
128LegalModifier(unsigned int key, DeviceIntPtr pDev)
129{
130 return TRUE1;
131}
132
133/*
134 * TimeSinceLastInputEvent --
135 * Function used for screensaver purposes by the os module. Returns the
136 * time in milliseconds since there last was any input.
137 */
138int
139TimeSinceLastInputEvent(void)
140{
141 if (xf86Info.lastEventTime == 0) {
142 xf86Info.lastEventTime = GetTimeInMillis();
143 }
144 return GetTimeInMillis() - xf86Info.lastEventTime;
145}
146
147/*
148 * SetTimeSinceLastInputEvent --
149 * Set the lastEventTime to now.
150 */
151void
152SetTimeSinceLastInputEvent(void)
153{
154 xf86Info.lastEventTime = GetTimeInMillis();
155}
156
157/*
158 * ProcessInputEvents --
159 * Retrieve all waiting input events and pass them to DIX in their
160 * correct chronological order. Only reads from the system pointer
161 * and keyboard.
162 */
163void
164ProcessInputEvents(void)
165{
166 int x, y;
167
168 mieqProcessInputEvents();
169
170 /* FIXME: This is a problem if we have multiple pointers */
171 miPointerGetPosition(inputInfo.pointer, &x, &y);
172
173 xf86SetViewport(xf86Info.currentScreen, x, y);
174}
175
176/*
177 * Handle keyboard events that cause some kind of "action"
178 * (i.e., server termination, video mode changes, VT switches, etc.)
179 */
180void
181xf86ProcessActionEvent(ActionEvent action, void *arg)
182{
183 DebugF("ProcessActionEvent(%d,%p)\n", (int) action, arg);
184 switch (action) {
185 case ACTION_TERMINATE:
186 if (!xf86Info.dontZap) {
187 xf86Msg(X_INFO, "Server zapped. Shutting down.\n");
188#ifdef XFreeXDGA1
189 DGAShutdown();
190#endif
191 GiveUp(0);
192 }
193 break;
194 case ACTION_NEXT_MODE:
195 if (!xf86Info.dontZoom)
196 xf86ZoomViewport(xf86Info.currentScreen, 1);
197 break;
198 case ACTION_PREV_MODE:
199 if (!xf86Info.dontZoom)
200 xf86ZoomViewport(xf86Info.currentScreen, -1);
201 break;
202 case ACTION_SWITCHSCREEN:
203 if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
204 int vtno = *((int *) arg);
205
206 if (vtno != xf86Info.vtno) {
207 if (!xf86VTActivate(vtno)) {
208 ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
209 xf86Info.vtno, vtno, strerror(errno(*__error())));
210 }
211 }
212 }
213 break;
214 case ACTION_SWITCHSCREEN_NEXT:
215 if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
216 if (!xf86VTActivate(xf86Info.vtno + 1)) {
217 /* If first try failed, assume this is the last VT and
218 * try wrapping around to the first vt.
219 */
220 if (!xf86VTActivate(1)) {
221 ErrorF("Failed to switch from vt%02d to next vt: %s\n",
222 xf86Info.vtno, strerror(errno(*__error())));
223 }
224 }
225 }
226 break;
227 case ACTION_SWITCHSCREEN_PREV:
228 if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
229 if (!xf86VTActivate(xf86Info.vtno - 1)) {
230 /* Don't know what the maximum VT is, so can't wrap around */
231 ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
232 xf86Info.vtno, strerror(errno(*__error())));
233 }
234 }
235 break;
236 default:
237 break;
238 }
239}
240
241/*
242 * xf86Wakeup --
243 * Os wakeup handler.
244 */
245
246/* ARGSUSED */
247void
248xf86Wakeup(void *blockData, int err, void *pReadmask)
249{
250 if (err >= 0) { /* we don't want the handlers called if select() */
251 IHPtr ih, ih_tmp; /* returned with an error condition, do we? */
252
253 nt_list_for_each_entry_safe(ih, ih_tmp, InputHandlers, next)for (ih = InputHandlers, ih_tmp = (ih) ? (ih)->next : ((void
*)0); ih; ih = ih_tmp, ih_tmp = (ih_tmp) ? (ih_tmp)->next:
((void*)0))
{
254 if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
255 (FD_ISSET(ih->fd, ((fd_set *) pReadmask))__darwin_fd_isset((ih->fd), (((fd_set *) pReadmask))) != 0)) {
256 ih->ihproc(ih->fd, ih->data);
257 }
258 }
259 }
260
261 if (xf86VTSwitchPending())
262 xf86VTSwitch();
263}
264
265/*
266 * xf86ReadInput --
267 * input thread handler
268 */
269
270static void
271xf86ReadInput(int fd, int ready, void *closure)
272{
273 InputInfoPtr pInfo = closure;
274
275 pInfo->read_input(pInfo);
276}
277
278/*
279 * xf86AddEnabledDevice --
280 *
281 */
282void
283xf86AddEnabledDevice(InputInfoPtr pInfo)
284{
285 InputThreadRegisterDev(pInfo->fd, xf86ReadInput, pInfo);
286}
287
288/*
289 * xf86RemoveEnabledDevice --
290 *
291 */
292void
293xf86RemoveEnabledDevice(InputInfoPtr pInfo)
294{
295 InputThreadUnregisterDev(pInfo->fd);
296}
297
298static int *xf86SignalIntercept = NULL((void*)0);
299
300void
301xf86InterceptSignals(int *signo)
302{
303 if ((xf86SignalIntercept = signo))
304 *signo = -1;
305}
306
307static void (*xf86SigIllHandler) (void) = NULL((void*)0);
308
309void
310xf86InterceptSigIll(void (*sigillhandler) (void))
311{
312 xf86SigIllHandler = sigillhandler;
313}
314
315/*
316 * xf86SigWrapper --
317 * Catch unexpected signals and exit or continue cleanly.
318 */
319int
320xf86SigWrapper(int signo)
321{
322 if ((signo == SIGILL4) && xf86SigIllHandler) {
323 (*xf86SigIllHandler) ();
324 return 0; /* continue */
325 }
326
327 if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
328 *xf86SignalIntercept = signo;
329 return 0; /* continue */
330 }
331
332 xf86Info.caughtSignal = TRUE1;
333 return 1; /* abort */
334}
335
336/*
337 * xf86PrintBacktrace --
338 * Print a stack backtrace for debugging purposes.
339 */
340void
341xf86PrintBacktrace(void)
342{
343 xorg_backtrace();
344}
345
346static void
347xf86ReleaseKeys(DeviceIntPtr pDev)
348{
349 KeyClassPtr keyc;
350 int i;
351
352 if (!pDev || !pDev->key)
353 return;
354
355 keyc = pDev->key;
356
357 /*
358 * Hmm... here is the biggest hack of every time !
359 * It may be possible that a switch-vt procedure has finished BEFORE
360 * you released all keys neccessary to do this. That peculiar behavior
361 * can fool the X-server pretty much, cause it assumes that some keys
362 * were not released. TWM may stuck alsmost completly....
363 * OK, what we are doing here is after returning from the vt-switch
364 * exeplicitely unrelease all keyboard keys before the input-devices
365 * are reenabled.
366 */
367
368 for (i = keyc->xkbInfo->desc->min_key_code;
369 i < keyc->xkbInfo->desc->max_key_code; i++) {
370 if (key_is_down(pDev, i, KEY_POSTED2)) {
371 input_lock();
372 QueueKeyboardEvents(pDev, KeyRelease3, i);
373 input_unlock();
374 }
375 }
376}
377
378void
379xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo)
380{
381 if (!pInfo->dev)
382 return;
383
384 if (!pInfo->dev->enabled)
385 pInfo->flags |= XI86_DEVICE_DISABLED0x10;
386
387 xf86ReleaseKeys(pInfo->dev);
388 ProcessInputEvents();
389 DisableDevice(pInfo->dev, TRUE1);
390}
391
392void
393xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo)
394{
395 if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED0x10) == 0)
396 EnableDevice(pInfo->dev, TRUE1);
397 pInfo->flags &= ~XI86_DEVICE_DISABLED0x10;
398}
399
400/*
401 * xf86UpdateHasVTProperty --
402 * Update a flag property on the root window to say whether the server VT
403 * is currently the active one as some clients need to know this.
404 */
405static void
406xf86UpdateHasVTProperty(Bool hasVT)
407{
408 Atom property_name;
409 int32_t value = hasVT ? 1 : 0;
410 int i;
411
412 property_name = MakeAtom(HAS_VT_ATOM_NAME"XFree86_has_VT", sizeof(HAS_VT_ATOM_NAME"XFree86_has_VT") - 1,
413 FALSE0);
414 if (property_name == BAD_RESOURCE0xe0000000)
415 FatalError("Failed to retrieve \"HAS_VT\" atom\n");
416 for (i = 0; i < xf86NumScreens; i++) {
417 dixChangeWindowProperty(serverClient,
418 xf86ScrnToScreen(xf86Screens[i])->root,
419 property_name, XA_INTEGER((Atom) 19), 32,
420 PropModeReplace0, 1, &value, TRUE1);
421 }
422}
423
424void
425xf86VTLeave(void)
426{
427 int i;
428 InputInfoPtr pInfo;
429 IHPtr ih;
430
431 DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
432 BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
433#ifdef DPMSExtension1
434 if (DPMSPowerLevel != DPMSModeOn0)
435 DPMSSet(serverClient, DPMSModeOn0);
436#endif
437 for (i = 0; i < xf86NumScreens; i++) {
438 if (!(dispatchException & DE_TERMINATE2))
439 if (xf86Screens[i]->EnableDisableFBAccess)
440 (*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], FALSE0);
441 }
442
443 /*
444 * Keep the order: Disable Device > LeaveVT
445 * EnterVT > EnableDevice
446 */
447 for (ih = InputHandlers; ih; ih = ih->next) {
448 if (ih->is_input)
449 xf86DisableInputHandler(ih);
450 else
451 xf86DisableGeneralHandler(ih);
452 }
453 for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
454 xf86DisableInputDeviceForVTSwitch(pInfo);
455
456 input_lock();
457 for (i = 0; i < xf86NumScreens; i++)
458 xf86Screens[i]->LeaveVT(xf86Screens[i]);
459 for (i = 0; i < xf86NumGPUScreens; i++)
460 xf86GPUScreens[i]->LeaveVT(xf86GPUScreens[i]);
461
462 xf86AccessLeave(); /* We need this here, otherwise */
463
464 if (!xf86VTSwitchAway())
465 goto switch_failed;
466
467#ifdef XF86PM
468 if (xf86OSPMClose)
469 xf86OSPMClose();
470 xf86OSPMClose = NULL((void*)0);
471#endif
472
473 for (i = 0; i < xf86NumScreens; i++) {
474 /*
475 * zero all access functions to
476 * trap calls when switched away.
477 */
478 xf86Screens[i]->vtSema = FALSE0;
479 }
480 if (xorgHWAccess)
481 xf86DisableIO();
482
483 xf86UpdateHasVTProperty(FALSE0);
484
485 return;
486
487switch_failed:
488 DebugF("xf86VTSwitch: Leave failed\n");
489 xf86AccessEnter();
490 for (i = 0; i < xf86NumScreens; i++) {
491 if (!xf86Screens[i]->EnterVT(xf86Screens[i]))
492 FatalError("EnterVT failed for screen %d\n", i);
493 }
494 for (i = 0; i < xf86NumGPUScreens; i++) {
495 if (!xf86GPUScreens[i]->EnterVT(xf86GPUScreens[i]))
496 FatalError("EnterVT failed for gpu screen %d\n", i);
497 }
498 if (!(dispatchException & DE_TERMINATE2)) {
499 for (i = 0; i < xf86NumScreens; i++) {
500 if (xf86Screens[i]->EnableDisableFBAccess)
501 (*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE1);
502 }
503 }
504 dixSaveScreens(serverClient, SCREEN_SAVER_FORCER2, ScreenSaverReset0);
505
506 for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
507 xf86EnableInputDeviceForVTSwitch(pInfo);
508 for (ih = InputHandlers; ih; ih = ih->next) {
509 if (ih->is_input)
510 xf86EnableInputHandler(ih);
511 else
512 xf86EnableGeneralHandler(ih);
513 }
514 input_unlock();
515}
516
517void
518xf86VTEnter(void)
519{
520 int i;
521 InputInfoPtr pInfo;
522 IHPtr ih;
523
524 DebugF("xf86VTSwitch: Entering\n");
525 if (!xf86VTSwitchTo())
526 return;
527
528#ifdef XF86PM
529 xf86OSPMClose = xf86OSPMOpen();
530#endif
531
532 if (xorgHWAccess)
533 xf86EnableIO();
534 xf86AccessEnter();
535 for (i = 0; i < xf86NumScreens; i++) {
536 xf86Screens[i]->vtSema = TRUE1;
537 if (!xf86Screens[i]->EnterVT(xf86Screens[i]))
538 FatalError("EnterVT failed for screen %d\n", i);
539 }
540 for (i = 0; i < xf86NumGPUScreens; i++) {
541 xf86GPUScreens[i]->vtSema = TRUE1;
542 if (!xf86GPUScreens[i]->EnterVT(xf86GPUScreens[i]))
543 FatalError("EnterVT failed for gpu screen %d\n", i);
544 }
545 for (i = 0; i < xf86NumScreens; i++) {
546 if (xf86Screens[i]->EnableDisableFBAccess)
547 (*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE1);
548 }
549
550 /* Turn screen saver off when switching back */
551 dixSaveScreens(serverClient, SCREEN_SAVER_FORCER2, ScreenSaverReset0);
552
553 for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
554 /* Devices with server managed fds get enabled on logind resume */
555 if (!(pInfo->flags & XI86_SERVER_FD0x20))
556 xf86EnableInputDeviceForVTSwitch(pInfo);
557 }
558
559 for (ih = InputHandlers; ih; ih = ih->next) {
560 if (ih->is_input)
561 xf86EnableInputHandler(ih);
562 else
563 xf86EnableGeneralHandler(ih);
564 }
565#ifdef XSERVER_PLATFORM_BUS
566 /* check for any new output devices */
567 xf86platformVTProbe();
568#endif
569
570 xf86UpdateHasVTProperty(TRUE1);
571
572 input_unlock();
573}
574
575/*
576 * xf86VTSwitch --
577 * Handle requests for switching the vt.
578 */
579static void
580xf86VTSwitch(void)
581{
582 DebugF("xf86VTSwitch()\n");
583
584#ifdef XFreeXDGA1
585 if (!DGAVTSwitch())
586 return;
587#endif
588
589 /*
590 * Since all screens are currently all in the same state it is sufficient
591 * check the first. This might change in future.
592 *
593 * VTLeave is always handled here (VT_PROCESS guarantees this is safe),
594 * if we use systemd_logind xf86VTEnter() gets called by systemd-logind.c
595 * once it has resumed all drm nodes.
596 */
597 if (xf86VTOwner())
598 xf86VTLeave();
599 else if (!systemd_logind_controls_session()0)
600 xf86VTEnter();
601}
602
603/* Input handler registration */
604
605static void *
606addInputHandler(int fd, InputHandlerProc proc, void *data)
607{
608 IHPtr ih;
609
610 if (fd < 0 || !proc)
611 return NULL((void*)0);
612
613 ih = calloc(sizeof(*ih), 1);
614 if (!ih)
615 return NULL((void*)0);
616
617 ih->fd = fd;
618 ih->ihproc = proc;
619 ih->data = data;
620 ih->enabled = TRUE1;
621
622 ih->next = InputHandlers;
623 InputHandlers = ih;
624
625 return ih;
626}
627
628void *
629xf86AddInputHandler(int fd, InputHandlerProc proc, void *data)
630{
631 IHPtr ih = addInputHandler(fd, proc, data);
632
633 if (ih) {
634 AddEnabledDevice(fd);
635 ih->is_input = TRUE1;
636 }
637 return ih;
638}
639
640void *
641xf86AddGeneralHandler(int fd, InputHandlerProc proc, void *data)
642{
643 IHPtr ih = addInputHandler(fd, proc, data);
644
645 if (ih)
646 AddGeneralSocket(fd);
647 return ih;
648}
649
650/**
651 * Set the handler for the console's fd. Replaces (and returns) the previous
652 * handler or NULL, whichever appropriate.
653 * proc may be NULL if the server should not handle events on the console.
654 */
655InputHandlerProc
656xf86SetConsoleHandler(InputHandlerProc proc, void *data)
657{
658 static IHPtr handler = NULL((void*)0);
659 InputHandlerProc old_proc = NULL((void*)0);
660
661 if (handler) {
662 old_proc = handler->ihproc;
663 xf86RemoveGeneralHandler(handler);
664 }
665
666 handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
667
668 return old_proc;
669}
670
671static void
672removeInputHandler(IHPtr ih)
673{
674 IHPtr p;
675
676 if (ih == InputHandlers)
5
Assuming 'ih' is not equal to 'InputHandlers'
6
Taking false branch
677 InputHandlers = ih->next;
678 else {
679 p = InputHandlers;
7
Value assigned to 'p'
680 while (p && p->next != ih)
8
Assuming pointer value is null
681 p = p->next;
682 if (ih)
9
Taking true branch
683 p->next = ih->next;
10
Access to field 'next' results in a dereference of a null pointer (loaded from variable 'p')
684 }
685 free(ih);
686}
687
688int
689xf86RemoveInputHandler(void *handler)
690{
691 IHPtr ih;
692 int fd;
693
694 if (!handler)
695 return -1;
696
697 ih = handler;
698 fd = ih->fd;
699
700 if (ih->fd >= 0)
701 RemoveEnabledDevice(ih->fd);
702 removeInputHandler(ih);
703
704 return fd;
705}
706
707int
708xf86RemoveGeneralHandler(void *handler)
709{
710 IHPtr ih;
711 int fd;
712
713 if (!handler)
1
Assuming 'handler' is non-null
2
Taking false branch
714 return -1;
715
716 ih = handler;
717 fd = ih->fd;
718
719 if (ih->fd >= 0)
3
Taking false branch
720 RemoveGeneralSocket(ih->fd);
721 removeInputHandler(ih);
4
Calling 'removeInputHandler'
722
723 return fd;
724}
725
726void
727xf86DisableInputHandler(void *handler)
728{
729 IHPtr ih;
730
731 if (!handler)
732 return;
733
734 ih = handler;
735 ih->enabled = FALSE0;
736 if (ih->fd >= 0)
737 RemoveEnabledDevice(ih->fd);
738}
739
740void
741xf86DisableGeneralHandler(void *handler)
742{
743 IHPtr ih;
744
745 if (!handler)
746 return;
747
748 ih = handler;
749 ih->enabled = FALSE0;
750 if (ih->fd >= 0)
751 RemoveGeneralSocket(ih->fd);
752}
753
754void
755xf86EnableInputHandler(void *handler)
756{
757 IHPtr ih;
758
759 if (!handler)
760 return;
761
762 ih = handler;
763 ih->enabled = TRUE1;
764 if (ih->fd >= 0)
765 AddEnabledDevice(ih->fd);
766}
767
768void
769xf86EnableGeneralHandler(void *handler)
770{
771 IHPtr ih;
772
773 if (!handler)
774 return;
775
776 ih = handler;
777 ih->enabled = TRUE1;
778 if (ih->fd >= 0)
779 AddGeneralSocket(ih->fd);
780}
781
782/*
783 * As used currently by the DRI, the return value is ignored.
784 */
785Bool
786xf86EnableVTSwitch(Bool new)
787{
788 static Bool def = TRUE1;
789 Bool old;
790
791 old = VTSwitchEnabled;
792 if (!new) {
793 /* Disable VT switching */
794 def = VTSwitchEnabled;
795 VTSwitchEnabled = FALSE0;
796 }
797 else {
798 /* Restore VT switching to default */
799 VTSwitchEnabled = def;
800 }
801 return old;
802}
803
804void
805DDXRingBell(int volume, int pitch, int duration)
806{
807 xf86OSRingBell(volume, pitch, duration);
808}
809
810Bool
811xf86VTOwner(void)
812{
813 /* at system startup xf86Screens[0] won't be set - but we will own the VT */
814 if (xf86NumScreens == 0)
815 return TRUE1;
816 return xf86Screens[0]->vtSema;
817}