Replace DDXBEFORERESET, which was introduced for the sole benefit of XWin in commit 048045a9, with a slightly more general way of doing DDX-specific hooks, still for the sole benefit of XWin :-)
Use a structure of function pointers, which can be initialized as required by the specific DDX during main(), before dix_main() is called. Change main() in the XWin DDX to initializes the ddxBeforeReset hook. Signed-off-by: Jon TURNEY <[email protected]> --- configure.ac | 1 - dix/dispatch.c | 8 +++++--- dix/globals.c | 3 +++ hw/dmx/dmxinit.c | 6 ------ hw/vfb/InitOutput.c | 7 ------- hw/xnest/Init.c | 6 ------ hw/xwin/InitOutput.c | 7 ++++--- include/dix-config.h.in | 3 --- include/dixmain.h | 9 +++++++++ include/os.h | 4 ---- 10 files changed, 21 insertions(+), 33 deletions(-) diff --git a/configure.ac b/configure.ac index 1ceffe7..23d5217 100644 --- a/configure.ac +++ b/configure.ac @@ -1896,7 +1896,6 @@ if test "x$XWIN" = xyes; then fi AC_DEFINE(DDXOSVERRORF, 1, [Use OsVendorVErrorF]) - AC_DEFINE(DDXBEFORERESET, 1, [Use ddxBeforeReset ]) fi AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes]) AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes]) diff --git a/dix/dispatch.c b/dix/dispatch.c index 7b2132d..562ea44 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -130,6 +130,7 @@ int ProcInitialConnection(); #include "inputstr.h" #include "xkbsrv.h" #include "site.h" +#include "dixmain.h" #ifdef XSERVER_DTRACE #include "registry.h" @@ -456,9 +457,10 @@ Dispatch(void) } dispatchException &= ~DE_PRIORITYCHANGE; } -#if defined(DDXBEFORERESET) - ddxBeforeReset (); -#endif + + if (ddxHooks.ddxBeforeReset) + ddxHooks.ddxBeforeReset(); + KillAllClients(); free(clientReady); dispatchException &= ~DE_RESET; diff --git a/dix/globals.c b/dix/globals.c index 0a6b170..70b4b89 100644 --- a/dix/globals.c +++ b/dix/globals.c @@ -60,6 +60,7 @@ SOFTWARE. #include "site.h" #include "dixstruct.h" #include "os.h" +#include "dixmain.h" ScreenInfo screenInfo; KeybdCtrl defaultKeyboardControl = { @@ -129,3 +130,5 @@ char *display; char *ConnectionInfo; CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND; + +DdxHooks ddxHooks; diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c index 9012382..3115a97 100644 --- a/hw/dmx/dmxinit.c +++ b/hw/dmx/dmxinit.c @@ -839,12 +839,6 @@ void AbortDDX(void) } } -#ifdef DDXBEFORERESET -void ddxBeforeReset(void) -{ -} -#endif - /** This function is called in Xserver/dix/main.c from \a main() when * dispatchException & DE_TERMINATE (which is the only way to exit the * main loop without an interruption. */ diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index 14d0c03..2ca1e15 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -229,13 +229,6 @@ OsVendorFatalError(void) { } -#if defined(DDXBEFORERESET) -void ddxBeforeReset(void) -{ - return; -} -#endif - void ddxUseMsg(void) { diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c index f6b4a20..7205cd3 100644 --- a/hw/xnest/Init.c +++ b/hw/xnest/Init.c @@ -152,9 +152,3 @@ void OsVendorFatalError(void) return; } -#if defined(DDXBEFORERESET) -void ddxBeforeReset(void) -{ - return; -} -#endif diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 4e55a89..7c8a9e6 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -172,13 +172,12 @@ ddxPushProviders(void) #endif } -#if defined(DDXBEFORERESET) /* * Called right before KillAllClients when the server is going to reset, * allows us to shutdown our seperate threads cleanly. */ -void +static void ddxBeforeReset (void) { winDebug ("ddxBeforeReset - Hello\n"); @@ -187,10 +186,12 @@ ddxBeforeReset (void) winClipboardShutdown (); #endif } -#endif int main(int argc, char *argv[], char *envp[]) { + /* Initialize DDX-specific hooks */ + ddxHooks.ddxBeforeReset = ddxBeforeReset; + return dix_main(argc, argv, envp); } diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 5622766..58bc9c6 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -36,9 +36,6 @@ /* Use OsVendorVErrorF */ #undef DDXOSVERRORF -/* Use ddxBeforeReset */ -#undef DDXBEFORERESET - /* Build DPMS extension */ #undef DPMSExtension diff --git a/include/dixmain.h b/include/dixmain.h index 992823b..ab03756 100644 --- a/include/dixmain.h +++ b/include/dixmain.h @@ -26,4 +26,13 @@ int dix_main(int argc, char *argv[], char *envp[]); +struct _DdxHooks +{ + void (*ddxBeforeReset)(void); +}; + +typedef struct _DdxHooks DdxHooks; + +extern DdxHooks ddxHooks; + #endif /* DIXMAIN_H */ diff --git a/include/os.h b/include/os.h index d747040..30913d5 100644 --- a/include/os.h +++ b/include/os.h @@ -84,10 +84,6 @@ typedef struct _NewClientRec *NewClientPtr; #include <stdio.h> #include <stdarg.h> -#ifdef DDXBEFORERESET -extern void ddxBeforeReset (void); -#endif - #ifdef DDXOSVERRORF extern _X_EXPORT void (*OsVendorVErrorFProc)(const char *, va_list args); #endif -- 1.7.3.3 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
