diff options
author | Pierre Ossman <ossman@cendio.se> | 2017-12-07 15:21:45 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2017-12-07 15:21:45 +0100 |
commit | 7b7b12016631c87fc864ae548d0d35d5493accb2 (patch) | |
tree | 78148648bf4e49404cacd18bc8bf2df27771ef8f | |
parent | 88a4541705c20c937db2d8a269c6a065070343ec (diff) | |
parent | dc27b95bd2a2a99049c4b0516e4a371106982287 (diff) | |
download | tigervnc-7b7b12016631c87fc864ae548d0d35d5493accb2.tar.gz tigervnc-7b7b12016631c87fc864ae548d0d35d5493accb2.zip |
Merge branch 'fatal' of https://github.com/CendioOssman/tigervnc
-rw-r--r-- | unix/xserver/hw/vnc/XorgGlue.c | 22 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XorgGlue.h | 10 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExt.c | 7 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.cc | 66 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.h | 3 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/xvnc.c | 8 |
6 files changed, 52 insertions, 64 deletions
diff --git a/unix/xserver/hw/vnc/XorgGlue.c b/unix/xserver/hw/vnc/XorgGlue.c index 712ed6af..141023a8 100644 --- a/unix/xserver/hw/vnc/XorgGlue.c +++ b/unix/xserver/hw/vnc/XorgGlue.c @@ -40,6 +40,18 @@ unsigned long vncGetServerGeneration(void) return serverGeneration; } +void vncFatalError(const char *format, ...) +{ + va_list args; + char buffer[4096]; + + va_start(args, format); + vsnprintf(buffer, sizeof(buffer), format, args); + va_end(args); + + FatalError("%s", buffer); +} + int vncGetScreenCount(void) { return screenInfo.numScreens; @@ -293,11 +305,21 @@ void vncRandRGetOutputDimensions(int scrIdx, int outputIdx, { #ifdef RANDR rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); + int swap; *x = rp->outputs[outputIdx]->crtc->x; *y = rp->outputs[outputIdx]->crtc->y; *width = rp->outputs[outputIdx]->crtc->mode->mode.width; *height = rp->outputs[outputIdx]->crtc->mode->mode.height; + + switch (rp->outputs[outputIdx]->crtc->rotation & 0xf) { + case RR_Rotate_90: + case RR_Rotate_270: + swap = *width; + *width = *height; + *height = swap; + break; + } #endif } diff --git a/unix/xserver/hw/vnc/XorgGlue.h b/unix/xserver/hw/vnc/XorgGlue.h index 5cae860a..63227ac3 100644 --- a/unix/xserver/hw/vnc/XorgGlue.h +++ b/unix/xserver/hw/vnc/XorgGlue.h @@ -24,9 +24,19 @@ extern "C" { #endif +#ifdef __GNUC__ +# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) +# define __noreturn_attr __attribute__((noreturn)) +#else +# define __printf_attr(a, b) +# define __noreturn_attr +#endif // __GNUC__ + const char *vncGetDisplay(void); unsigned long vncGetServerGeneration(void); +void vncFatalError(const char *format, ...) __printf_attr(1, 2) __noreturn_attr; + int vncGetScreenCount(void); void vncGetScreenFormat(int scrIdx, int *depth, int *bpp, diff --git a/unix/xserver/hw/vnc/vncExt.c b/unix/xserver/hw/vnc/vncExt.c index 0ee32101..f7ba9fa8 100644 --- a/unix/xserver/hw/vnc/vncExt.c +++ b/unix/xserver/hw/vnc/vncExt.c @@ -57,7 +57,7 @@ struct VncInputSelect { struct VncInputSelect* next; }; -int vncAddExtension(void) +void vncAddExtension(void) { ExtensionEntry* extEntry; @@ -65,8 +65,7 @@ int vncAddExtension(void) ProcVncExtDispatch, SProcVncExtDispatch, vncResetProc, StandardMinorOpcode); if (!extEntry) { - ErrorF("vncAddExtension: AddExtension failed\n"); - return -1; + FatalError("vncAddExtension: AddExtension failed\n"); } vncErrorBase = extEntry->errorBase; @@ -75,8 +74,6 @@ int vncAddExtension(void) if (!AddCallback(&ClientStateCallback, vncClientStateChange, 0)) { FatalError("Add ClientStateCallback failed\n"); } - - return 0; } int vncNotifyQueryConnect(void) diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index 13248f91..c47dfa72 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -137,27 +137,19 @@ static void parseOverrideList(const char *text, ParamSet &out) void vncExtensionInit(void) { - int ret; - if (vncExtGeneration == vncGetServerGeneration()) { vlog.error("vncExtensionInit: called twice in same generation?"); return; } vncExtGeneration = vncGetServerGeneration(); - if (vncGetScreenCount() > MAXSCREENS) { - vlog.error("vncExtensionInit: too many screens"); - return; - } + if (vncGetScreenCount() > MAXSCREENS) + vncFatalError("vncExtensionInit: too many screens"); - if (sizeof(ShortRect) != sizeof(struct UpdateRect)) { - vlog.error("vncExtensionInit: Incompatible ShortRect size"); - return; - } + if (sizeof(ShortRect) != sizeof(struct UpdateRect)) + vncFatalError("vncExtensionInit: Incompatible ShortRect size"); - ret = vncAddExtension(); - if (ret == -1) - return; + vncAddExtension(); vncSelectionInit(); @@ -240,17 +232,12 @@ void vncExtensionInit(void) vncHooksInit(scr); } } catch (rdr::Exception& e) { - vlog.error("vncExtInit: %s",e.str()); + vncFatalError("vncExtInit: %s",e.str()); } vncRegisterBlockHandlers(); } -int vncExtensionIsActive(int scrIdx) -{ - return (desktop[scrIdx] != NULL); -} - void vncHandleSocketEvent(int fd, int scrIdx, int read, int write) { desktop[scrIdx]->handleSocketEvent(fd, read, write); @@ -259,8 +246,7 @@ void vncHandleSocketEvent(int fd, int scrIdx, int read, int write) void vncCallBlockHandlers(int* timeout) { for (int scr = 0; scr < vncGetScreenCount(); scr++) - if (desktop[scr]) - desktop[scr]->blockHandler(timeout); + desktop[scr]->blockHandler(timeout); } int vncGetAvoidShiftNumLock(void) @@ -280,27 +266,18 @@ int vncGetSendPrimary(void) void vncUpdateDesktopName(void) { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->setDesktopName(desktopName); - } } void vncServerCutText(const char *text, size_t len) { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->serverCutText(text, len); - } } int vncConnectClient(const char *addr) { - if (desktop[0] == NULL) - return -1; - if (strlen(addr) == 0) { try { desktop[0]->disconnectClients(); @@ -332,8 +309,6 @@ void vncGetQueryConnect(uint32_t *opaqueId, const char**username, const char **address, int *timeout) { for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; desktop[scr]->getQueryConnect(opaqueId, username, address, timeout); if (opaqueId != 0) break; @@ -343,8 +318,6 @@ void vncGetQueryConnect(uint32_t *opaqueId, const char**username, void vncApproveConnection(uint32_t opaqueId, int approve) { for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; desktop[scr]->approveConnection(opaqueId, approve, "Connection rejected by local user"); } @@ -352,11 +325,8 @@ void vncApproveConnection(uint32_t opaqueId, int approve) void vncBell() { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->bell(); - } } void vncSetLEDState(unsigned long leds) @@ -371,11 +341,8 @@ void vncSetLEDState(unsigned long leds) if (leds & (1 << 2)) state |= ledScrollLock; - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->setLEDState(state); - } } void vncAddChanged(int scrIdx, const struct UpdateRect *extents, @@ -402,11 +369,8 @@ void vncAddCopied(int scrIdx, const struct UpdateRect *extents, void vncSetCursor(int width, int height, int hotX, int hotY, const unsigned char *rgbaData) { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->setCursor(width, height, hotX, hotY, rgbaData); - } } void vncPreScreenResize(int scrIdx) @@ -436,7 +400,11 @@ void vncPostScreenResize(int scrIdx, int success, int width, int height) void vncRefreshScreenLayout(int scrIdx) { - desktop[scrIdx]->refreshScreenLayout(); + try { + desktop[scrIdx]->refreshScreenLayout(); + } catch (rdr::Exception& e) { + vncFatalError("%s", e.str()); + } } int vncOverrideParam(const char *nameAndValue) diff --git a/unix/xserver/hw/vnc/vncExtInit.h b/unix/xserver/hw/vnc/vncExtInit.h index 99fee27e..e8294340 100644 --- a/unix/xserver/hw/vnc/vncExtInit.h +++ b/unix/xserver/hw/vnc/vncExtInit.h @@ -37,7 +37,7 @@ extern "C" { // vncExt.c extern int vncNoClipboard; -int vncAddExtension(void); +void vncAddExtension(void); int vncNotifyQueryConnect(void); @@ -48,7 +48,6 @@ extern int vncFbstride[]; extern int vncInetdSock; void vncExtensionInit(void); -int vncExtensionIsActive(int scrIdx); void vncHandleSocketEvent(int fd, int scrIdx, int read, int write); void vncCallBlockHandlers(int* timeout); diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 288ea5e6..b80863ab 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -1781,16 +1781,8 @@ void ProcessInputEvents(void) mieqProcessInputEvents(); } -// InitInput is called after InitExtensions, so we're guaranteed that -// vncExtensionInit() has already been called. - void InitInput(int argc, char *argv[]) { - int i; - for (i = 0;i < screenInfo.numScreens;i++) { - if (!vncExtensionIsActive(i)) - FatalError("failed to activate VNC extension for one or more screens"); - } mieqInit (); } |