From 5664998fcfe76f7de36dc770c74d9ab41bf03b1e Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Tue, 4 Sep 2007 09:15:35 +0000 Subject: [PATCH] Special handling for rectangular video area in x0vncserver. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2336 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/x0vncserver/PollingManager.cxx | 47 ++++++++++++++++++++++++++++- unix/x0vncserver/PollingManager.h | 2 ++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx index f2ea5871..74533511 100644 --- a/unix/x0vncserver/PollingManager.cxx +++ b/unix/x0vncserver/PollingManager.cxx @@ -296,13 +296,24 @@ bool PollingManager::poll_DetectVideo() if (grandStep) adjustVideoArea(); + bool videoDetected = false; + Rect r; + getVideoAreaRect(&r); + m_server->set_video_area(r); + videoDetected = !r.is_empty(); + if (videoDetected) { + m_image->get(DefaultRootWindow(m_dpy), + m_offsetLeft + r.tl.x, m_offsetTop + r.tl.y, + r.width(), r.height(), r.tl.x, r.tl.y); + } + #ifdef DEBUG if (nTilesChanged != 0) { fprintf(stderr, "#%d# ", nTilesChanged); } #endif - return (nTilesChanged != 0); + return (nTilesChanged != 0 || videoDetected); } bool PollingManager::poll_SkipCycles() @@ -604,3 +615,37 @@ void PollingManager::adjustVideoArea() memcpy(m_videoFlags, newFlags, m_widthTiles * m_heightTiles); } + +void +PollingManager::getVideoAreaRect(Rect *result) +{ + int y0 = m_heightTiles, y1 = 0; + int x0 = m_widthTiles, x1 = 0; + + for (int y = 0; y < m_heightTiles; y++) { + for (int x = 0; x < m_widthTiles; x++) { + if (!m_videoFlags[y * m_widthTiles + x]) + continue; + if (y < y0) y0 = y; + if (y > y1) y1 = y; + if (x < x0) x0 = x; + if (x > x1) x1 = x; + } + } + + // Limit width and height at 800 and 576 correspondingly. + if (x1 - x0 > 24) + x1 = x0 + 24; + if (y1 - y0 > 17) + y1 = y0 + 17; + + result->tl.x = x0 * 32; + result->tl.y = y0 * 32; + result->br.x = (x1 + 1) * 32; + result->br.y = (y1 + 1) * 32; + + if (x1 >= x0) { + fprintf(stderr, "Video rect %dx%d\tat(%d,%d)\n", + result->width(), result->height(), result->tl.x, result->tl.y); + } +} diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h index b8eef509..64a18ae6 100644 --- a/unix/x0vncserver/PollingManager.h +++ b/unix/x0vncserver/PollingManager.h @@ -120,6 +120,8 @@ private: void adjustVideoArea(); + void getVideoAreaRect(Rect *result); + // Additional images used in polling algorithms. Image *m_rowImage; // One row of the framebuffer Image *m_tileImage; // One tile (32x32 or less) -- 2.39.5