Changeset 57357 in vbox for trunk/src/VBox/Additions/x11
- Timestamp:
- Aug 14, 2015 3:04:46 PM (9 years ago)
- Location:
- trunk/src/VBox/Additions/x11/VBoxClient
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h
r55401 r57357 51 51 /** Run the service main loop */ 52 52 int (*run)(struct VBCLSERVICE **ppInterface, bool fDaemonised); 53 /** Pause the service loop. This is used to allow the service to disable54 * itself when the X server is switched out. It must be safe to call on a55 * different thread if the VT monitoring thread is used. */56 int (*pause)(struct VBCLSERVICE **ppInterface);57 /** Resume after pausing. The same applies here as for @a pause. */58 int (*resume)(struct VBCLSERVICE **ppInterface);59 53 /** Clean up any global resources before we shut down hard. The last calls 60 54 * to @a pause and @a resume are guaranteed to finish before this is called. … … 77 71 } 78 72 79 union _XEvent; /* We do not want to pull in the X11 header files here. */80 extern void VBClCheckXOrgVT(union _XEvent *pEvent);81 extern int VBClStartVTMonitor();82 83 73 extern struct VBCLSERVICE **VBClGetClipboardService(); 84 74 extern struct VBCLSERVICE **VBClGetSeamlessService(); -
trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp
r54859 r57357 314 314 VBClServiceDefaultHandler, /* init */ 315 315 run, 316 VBClServiceDefaultHandler, /* pause */317 VBClServiceDefaultHandler, /* resume */318 316 cleanup 319 317 }; -
trunk/src/VBox/Additions/x11/VBoxClient/display.cpp
r57356 r57357 388 388 init, 389 389 run, 390 VBClServiceDefaultHandler, /* pause */391 VBClServiceDefaultHandler, /* resume */392 390 cleanup 393 391 }; -
trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
r57283 r57357 3341 3341 VBClServiceDefaultHandler, /* init */ 3342 3342 run, 3343 VBClServiceDefaultHandler, /* pause */3344 VBClServiceDefaultHandler, /* resume */3345 3343 cleanup 3346 3344 }; -
trunk/src/VBox/Additions/x11/VBoxClient/hostversion.cpp
r55600 r57357 208 208 VBClServiceDefaultHandler, /* init */ 209 209 run, 210 VBClServiceDefaultHandler, /* pause */211 VBClServiceDefaultHandler, /* resume */212 210 VBClServiceDefaultCleanup 213 211 }; -
trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
r56995 r57357 115 115 XGetErrorText(pDisplay, pError->error_code, errorText, sizeof(errorText)); 116 116 LogRelFlow(("VBoxClient: an X Window protocol error occurred: %s (error code %d). Request code: %d, minor code: %d, serial number: %d\n", errorText, pError->error_code, pError->request_code, pError->minor_code, pError->serial)); 117 return 0; /* We should never reach this. */117 return 0; 118 118 } 119 119 … … 152 152 } 153 153 154 /** Check whether X.Org has acquired or lost the current virtual terminal and155 * call the service @a pause() or @a resume() call-back if appropriate.156 * The functionality is provided by the vboxvideo driver for pre-1.16 X servers157 * and by 1.16 and later series servers.158 * This can either be called directly from a service's event loop or the service159 * can call VBClStartVTMonitor() to start an event loop in a separate thread.160 * Property notification for the root window should be selected first. Services161 * are not required to check VT changes if they do not need the information.162 * @param pEvent an event received on a display connection which will be163 * checked to see if it is change to the XFree86_has_VT property164 */165 void VBClCheckXOrgVT(union _XEvent *pEvent)166 {167 Atom actualType;168 int actualFormat;169 unsigned long cItems, cbLeft;170 bool fHasVT = false;171 unsigned long *pValue;172 int rc;173 Display *pDisplay = pEvent->xany.display;174 Atom hasVT = XInternAtom(pDisplay, "XFree86_has_VT", False);175 176 if ( pEvent->type != PropertyNotify177 || pEvent->xproperty.window != DefaultRootWindow(pDisplay)178 || pEvent->xproperty.atom != hasVT)179 return;180 XGetWindowProperty(pDisplay, DefaultRootWindow(pDisplay), hasVT, 0, 1,181 False, XA_INTEGER, &actualType, &actualFormat, &cItems,182 &cbLeft, (unsigned char **)&pValue);183 if (cItems && actualFormat == 32)184 {185 fHasVT = *pValue != 0;186 XFree(pValue);187 }188 else189 return;190 if (fHasVT)191 {192 rc = (*g_pService)->resume(g_pService);193 if (RT_FAILURE(rc))194 VBClFatalError(("Error resuming the service: %Rrc\n", rc));195 }196 if (!fHasVT)197 {198 rc = (*g_pService)->pause(g_pService);199 if (RT_FAILURE(rc))200 VBClFatalError(("Error pausing the service: %Rrc\n", rc));201 }202 }203 204 /**205 * Thread which notifies the service when we switch to a different VT or back206 * and cleans up when the X server exits.207 * @note runs until programme exit.208 */209 static int pfnMonitorThread(RTTHREAD self, void *pvUser)210 {211 Display *pDisplay;212 bool fHasVT = true;213 214 pDisplay = XOpenDisplay(NULL);215 if (!pDisplay)216 VBClFatalError(("Failed to open the X11 display\n"));217 XSelectInput(pDisplay, DefaultRootWindow(pDisplay), PropertyChangeMask);218 while (true)219 {220 XEvent event;221 222 XNextEvent(pDisplay, &event);223 VBClCheckXOrgVT(&event);224 }225 return VINF_SUCCESS; /* Should never be reached. */226 }227 228 /**229 * Start a thread which notifies the service when we switch to a different230 * VT or back, and terminates us when the X server exits. This should be called231 * by most services which do not regularly run an X11 event loop.232 */233 int VBClStartVTMonitor()234 {235 return RTThreadCreate(NULL, pfnMonitorThread, NULL, 0,236 RTTHREADTYPE_INFREQUENT_POLLER, 0, "MONITOR");237 }238 239 154 /** 240 155 * Print out a usage message and exit with success. -
trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp
r57344 r57357 355 355 init, 356 356 run, 357 VBClServiceDefaultHandler, /* pause */358 VBClServiceDefaultHandler, /* resume */359 357 cleanup 360 358 };
Note:
See TracChangeset
for help on using the changeset viewer.