[Spice-commits] 10 commits - autogen.sh common/vdcommon.h common/vdlog.cpp common/vdlog.h configure.ac .gitmodules Makefile.am spice-protocol vdagent/desktop_layout.cpp vdagent/vdagent.cpp vdservice/vdservice.cpp

Marc-André Lureau elmarco at kemper.freedesktop.org
Thu May 24 04:56:31 PDT 2012


 .gitmodules                |    3 ++
 Makefile.am                |   40 ++++++++++++++++++++++---------
 autogen.sh                 |   17 +++++++++++++
 common/vdcommon.h          |    4 +++
 common/vdlog.cpp           |    4 +++
 common/vdlog.h             |   57 ++++++++++++++++++++++++++-------------------
 configure.ac               |    4 +--
 spice-protocol             |    1 
 vdagent/desktop_layout.cpp |   31 ++++++++++++++++++++++++
 vdagent/vdagent.cpp        |    4 +++
 vdservice/vdservice.cpp    |   25 +++++++++++++++----
 11 files changed, 149 insertions(+), 41 deletions(-)

New commits:
commit b4e9afc721882ae14fe9e720a3cd113701cf9f8e
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri May 18 21:51:52 2012 +0200

    desktop_layout: fix incorrect total_width/height
    
    When resizing desktop to best match, the agent fails to update
    it's current mode width/height and then incorrectly report
    different total_width/total_height than real screen dimensions,
    then scaling input incorrectly results in mouse cursor offset.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=823019

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index 7564cf6..3b474d1 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -298,6 +298,11 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
         dev_mode->dmPosition.y = mode->_pos_y;
         dev_mode->dmFields |= DM_POSITION;
     }
+
+    // update current DisplayMode (so mouse scaling works properly)
+    mode->_width = dev_mode->dmPelsWidth;
+    mode->_height = dev_mode->dmPelsHeight;
+
     return true;
 }
 
commit 3d45018086688697bc5d3686b9fd47a079155094
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri May 11 17:27:54 2012 +0200

    Resize to arbitrary resolution
    
    Use QXL_ESCAPE_SET_CUSTOM_DISPLAY to update custom mode,
    and switch to it.

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index 6e255fc..7564cf6 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -15,6 +15,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include <spice/qxl_windows.h>
 #include "desktop_layout.h"
 #include "vdlog.h"
 
@@ -240,6 +241,8 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
 {
     DWORD closest_diff = -1;
     DWORD best = -1;
+    QXLEscapeSetCustomDisplay custom;
+    HDC hdc = NULL;
 
     ZeroMemory(dev_mode, sizeof(DEVMODE));
     dev_mode->dmSize = sizeof(DEVMODE);
@@ -248,6 +251,29 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
         dev_mode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION;
         return true;
     }
+
+    // Update custom resolution
+    custom.xres = mode->_width;
+    custom.yres = mode->_height;
+    custom.bpp = mode->_depth;
+    hdc = CreateDC(dev_name, NULL, NULL, NULL);
+    if (!hdc) {
+        vd_printf("failed to create DC: %s", dev_name);
+    } else {
+        int err = ExtEscape(hdc, QXL_ESCAPE_SET_CUSTOM_DISPLAY,
+                            sizeof(QXLEscapeSetCustomDisplay), (LPCSTR)&custom, 0, NULL);
+        if (err <= 0) {
+            vd_printf("can't set custom display, perhaps an old driver");
+        }
+        DeleteDC(hdc);
+    }
+
+    // force refresh mode table
+    DEVMODE tempDevMode;
+    ZeroMemory(&tempDevMode, sizeof (tempDevMode));
+    tempDevMode.dmSize = sizeof(DEVMODE);
+    EnumDisplaySettings(dev_name, 0xffffff, &tempDevMode);
+
     //Find the closest size which will fit within the monitor
     for (DWORD i = 0; EnumDisplaySettings(dev_name, i, dev_mode); i++) {
         if (dev_mode->dmPelsWidth > mode->_width ||
commit f2c2a136e2b4a0168c81045f7ef9613e96ded5cc
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri May 11 18:00:37 2012 +0200

    Use spice-protocol submodule

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..f946a4d
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "spice-protocol"]
+	path = spice-protocol
+	url = git://git.freedesktop.org/git/spice/spice-protocol.git
diff --git a/Makefile.am b/Makefile.am
index 05c4983..5afce17 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@ MAINTAINERCLEANFILES =
 
 INCLUDES =				\
 	-I$(top_srcdir)/common		\
-	$(SPICE_PROTOCOL_CFLAGS)	\
+	-I$(top_srcdir)/spice-protocol	\
 	$(NULL)
 
 AM_CPPFLAGS = -DUNICODE -D_UNICODE
diff --git a/autogen.sh b/autogen.sh
new file mode 100644
index 0000000..f84e1c1
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+pushd "$srcdir"
+git submodule update --init --recursive
+autoreconf -vfi
+popd
+
+if [ -z "$NOCONFIGURE" ]; then
+    "$srcdir"/configure --enable-maintainer-mode "$@"
+fi
+
+
diff --git a/configure.ac b/configure.ac
index 2888be3..597e724 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,7 +64,6 @@ dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
 
-PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol])
 PKG_CHECK_MODULES(CXIMAGE, [cximage])
 
 dnl ---------------------------------------------------------------------------
diff --git a/spice-protocol b/spice-protocol
new file mode 160000
index 0000000..d289047
--- /dev/null
+++ b/spice-protocol
@@ -0,0 +1 @@
+Subproject commit d28904731a06a25d3d148d895b0633520ead9aad
commit 2ab4fb7832d4630aced7e125a68af93f6f0079a9
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri May 11 16:24:24 2012 +0200

    Allow running as a normal process again
    
    The service code should be commented out if DEBUG_VDSERVICE.
    Otherwise it fails to run as a standalone process.

diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 9c5f569..3c35609 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -412,13 +412,12 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
     status->dwServiceSpecificExitCode = NO_ERROR;
     status->dwCheckPoint = 0;
     status->dwWaitHint = 0;
+#ifndef  DEBUG_VDSERVICE
     s->_status_handle = RegisterServiceCtrlHandlerEx(VD_SERVICE_NAME, &VDService::control_handler,
                                                      NULL);
     if (!s->_status_handle) {
-        printf("RegisterServiceCtrlHandler failed\n");
-#ifndef DEBUG_VDSERVICE
+        vd_printf("RegisterServiceCtrlHandler failed\n");
         return;
-#endif // DEBUG_VDSERVICE
     }
 
     // service is starting
@@ -429,10 +428,12 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
     status->dwControlsAccepted |= VDSERVICE_ACCEPTED_CONTROLS;
     status->dwCurrentState = SERVICE_RUNNING;
     SetServiceStatus(s->_status_handle, status);
+#endif //DEBUG_VDSERVICE
 
     s->_running = true;
     s->execute();
 
+#ifndef  DEBUG_VDSERVICE
     // service was stopped
     status->dwCurrentState = SERVICE_STOP_PENDING;
     SetServiceStatus(s->_status_handle, status);
@@ -440,7 +441,6 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
     // service is stopped
     status->dwControlsAccepted &= ~VDSERVICE_ACCEPTED_CONTROLS;
     status->dwCurrentState = SERVICE_STOPPED;
-#ifndef DEBUG_VDSERVICE
     SetServiceStatus(s->_status_handle, status);
 #endif //DEBUG_VDSERVICE
     vd_printf("***Service stopped***");
commit 1aa23d698ab8ca36ce67e14a4cd5d9cf8bfd8e96
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri May 11 16:23:47 2012 +0200

    mingw: compile a non-console binary
    
    Otherwise, a console dialog pops up

diff --git a/Makefile.am b/Makefile.am
index a2d2dae..05c4983 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,8 @@ INCLUDES =				\
 	$(SPICE_PROTOCOL_CFLAGS)	\
 	$(NULL)
 
-AM_CPPFLAGS=-DUNICODE -D_UNICODE
+AM_CPPFLAGS = -DUNICODE -D_UNICODE
+AM_LDFLAGS = -Wl,--subsystem,windows
 # -lversion is needed for the GetFileVersion* API which is used by vdlog.cpp
 LIBS = -lversion
 
commit 0c1658b1c2ed566cafe7fff7102850470c5d58a1
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri May 11 13:06:40 2012 +0200

    mingw: link with RC file to provide needed version information

diff --git a/Makefile.am b/Makefile.am
index 2e845ec..a2d2dae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,19 @@
+NULL =
+MAINTAINERCLEANFILES =
+
 INCLUDES =				\
 	-I$(top_srcdir)/common		\
-	$(SPICE_PROTOCOL_CFLAGS)
+	$(SPICE_PROTOCOL_CFLAGS)	\
+	$(NULL)
+
 AM_CPPFLAGS=-DUNICODE -D_UNICODE
+# -lversion is needed for the GetFileVersion* API which is used by vdlog.cpp
+LIBS = -lversion
 
 bin_PROGRAMS = vdagent vdservice
 
+vdagent_LDADD = $(CXIMAGE_LIBS) vdagent_rc.$(OBJEXT)
+vdagent_CXXFLAGS = $(CXIMAGE_CFLAGS)
 vdagent_SOURCES =			\
 	common/vdcommon.h		\
 	common/vdlog.cpp		\
@@ -13,27 +22,34 @@ vdagent_SOURCES =			\
 	vdagent/desktop_layout.h	\
 	vdagent/display_setting.cpp	\
 	vdagent/display_setting.h	\
-	vdagent/vdagent.cpp
+	vdagent/vdagent.cpp		\
+	$(NULL)
 
+vdagent_rc.$(OBJEXT): vdagent/vdagent.rc
+	$(AM_V_GEN)$(WINDRES) -i $< -o $@
+
+MAINTAINERCLEANFILES += vdagent_rc.$(OBJEXT)
+
+vdservice_LDADD = -lwtsapi32 vdservice_rc.$(OBJEXT)
 vdservice_SOURCES =			\
 	common/stdint.h			\
 	common/vdcommon.h		\
 	common/vdlog.cpp		\
 	common/vdlog.h			\
-	vdservice/vdservice.cpp		\
 	vdservice/pci_vdi_port.cpp	\
 	vdservice/pci_vdi_port.h	\
-	vdservice/vdi_port.h		\
 	vdservice/vdi_port.cpp		\
+	vdservice/vdi_port.h		\
+	vdservice/vdservice.cpp		\
+	vdservice/virtio_vdi_port.cpp	\
 	vdservice/virtio_vdi_port.h	\
-	vdservice/virtio_vdi_port.cpp
+	$(NULL)
+
+vdservice_rc.$(OBJEXT): vdservice/vdservice.rc
+	$(AM_V_GEN)$(WINDRES) -i $< -o $@
+
+MAINTAINERCLEANFILES += vdservice_rc.$(OBJEXT)
 
-# -lversion is needed for the GetFileVersion* API which is used by
-# vdlog.cpp
-LIBS = -lversion
-vdservice_LDADD = -lwtsapi32
-vdagent_LDADD = $(CXIMAGE_LIBS)
-vdagent_CXXFLAGS = $(CXIMAGE_CFLAGS)
 
 EXTRA_DIST =			\
 	tests/clipboard.py	\
diff --git a/configure.ac b/configure.ac
index 28c9d23..2888be3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ AC_PROG_CC
 AC_PROG_CXX
 AM_PROG_CC_C_O
 AC_PROG_INSTALL
+AC_CHECK_TOOL(WINDRES, [windres])
 
 dnl ---------------------------------------------------------------------------
 dnl - Extra verbose warning switches
commit 60e850c6e48c5223d00591e1d85ad1a31dcd44c5
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri May 11 02:08:26 2012 +0200

    mingw: don't use *_s msvcrt variants
    
    Apparently, it comes with a recent version of C library (msvcrt90?),
    but I don't know if we can/should ship also a MS dll. Probably it used
    to work with an inlined version with VS headers.
    
    The build can be tweaked to use the -non-_s variant with -DOLDMSVCRT
    CFLAGS.

diff --git a/common/vdcommon.h b/common/vdcommon.h
index c5268f4..394333b 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -53,6 +53,10 @@ enum {
 #define ALIGN_VC __declspec (align(1))
 #endif
 
+#ifdef OLDMSVCRT
+#define swprintf_s(buf, sz, format...) swprintf(buf, format)
+#endif
+
 typedef struct ALIGN_VC VDPipeMessage {
     uint32_t type;
     uint32_t opaque;
diff --git a/common/vdlog.cpp b/common/vdlog.cpp
index a0444d9..f84b5b3 100644
--- a/common/vdlog.cpp
+++ b/common/vdlog.cpp
@@ -52,7 +52,11 @@ VDLog* VDLog::get(TCHAR* path)
     }
     if (size != INVALID_FILE_SIZE && size > LOG_ROLL_SIZE) {
         TCHAR roll_path[MAX_PATH];
+#ifdef OLDMSVCRT
+        swprintf(roll_path, L"%s.1", path);
+#else
         swprintf_s(roll_path, MAX_PATH, L"%s.1", path);
+#endif
         if (!MoveFileEx(path, roll_path, MOVEFILE_REPLACE_EXISTING)) {
             return NULL;
         }
diff --git a/common/vdlog.h b/common/vdlog.h
index b2a7295..2ca03f3 100644
--- a/common/vdlog.h
+++ b/common/vdlog.h
@@ -53,32 +53,43 @@ static unsigned int log_level = LOG_DEBUG;
 static unsigned int log_level = LOG_INFO;
 #endif
 
-#define PRINT_LINE(type, format, datetime, ms, ...)                                             \
-    printf("%lu::%s::%s,%.3d::%s::" format "\n", GetCurrentThreadId(), type, datetime, ms,       \
+#define PRINT_LINE(type, format, datetime, ms, ...)                     \
+    printf("%lu::%s::%s,%.3d::%s::" format "\n", GetCurrentThreadId(), type, datetime, ms, \
            __FUNCTION__, ## __VA_ARGS__);
 
-#ifdef __MINGW32__
-#define vd_ftime_s _ftime
+#ifdef OLDMSVCRT
+#define LOG(type, format, ...) do {                                     \
+    if (type >= log_level && type <= LOG_FATAL) {                       \
+        VDLog* log = VDLog::get();                                      \
+        const char *type_as_char[] = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL" }; \
+        if (log) {                                                      \
+            log->PRINT_LINE(type_as_char[type], format, "", 0, ## __VA_ARGS__); \
+        } else {                                                        \
+            PRINT_LINE(type_as_char[type], format, "", 0, ## __VA_ARGS__); \
+        }                                                               \
+    }                                                                   \
+} while(0)
 #else
-#define vd_ftime_s _ftime_s
+#define LOG(type, format, ...) do {                                     \
+    if (type >= log_level && type <= LOG_FATAL) {                       \
+        VDLog* log = VDLog::get();                                      \
+        const char *type_as_char[] = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL" }; \
+        struct _timeb now;                                              \
+        struct tm today;                                                \
+        char datetime_str[20];                                          \
+        _ftime_s(&now);                                                 \
+        localtime_s(&today, &now.time);                                 \
+        strftime(datetime_str, 20, "%Y-%m-%d %H:%M:%S", &today);        \
+        if (log) {                                                      \
+            log->PRINT_LINE(type_as_char[type], format, datetime_str, now.millitm, ## __VA_ARGS__); \
+        } else {                                                        \
+            PRINT_LINE(type_as_char[type], format, datetime_str, now.millitm, ## __VA_ARGS__); \
+        }                                                               \
+    }                                                                   \
+} while(0)
 #endif
 
-#define LOG(type, format, ...) if (type >= log_level && type <= LOG_FATAL) {                    \
-    VDLog* log = VDLog::get();                                                                  \
-    const char *type_as_char[] = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL" };                 \
-    struct _timeb now;                                                                          \
-    struct tm today;                                                                            \
-    char datetime_str[20];                                                                      \
-    vd_ftime_s(&now);                                                                             \
-    localtime_s(&today, &now.time);                                                             \
-    strftime(datetime_str, 20, "%Y-%m-%d %H:%M:%S", &today);                                    \
-    if (log) {                                                                                  \
-        log->PRINT_LINE(type_as_char[type], format, datetime_str, now.millitm, ## __VA_ARGS__); \
-    } else {                                                                                    \
-        PRINT_LINE(type_as_char[type], format, datetime_str, now.millitm, ## __VA_ARGS__);      \
-    }                                                                                           \
-}
- 
+
 #define vd_printf(format, ...) LOG(LOG_INFO, format, ## __VA_ARGS__)
 #define LOG_INFO(format, ...) LOG(LOG_INFO, format, ## __VA_ARGS__)
 #define LOG_WARN(format, ...) LOG(LOG_WARN, format, ## __VA_ARGS__)
@@ -86,11 +97,11 @@ static unsigned int log_level = LOG_INFO;
 
 #define DBGLEVEL 1000
 
-#define DBG(level, format, ...) {               \
+#define DBG(level, format, ...) do {            \
     if (level <= DBGLEVEL) {                    \
         LOG(LOG_DEBUG, format, ## __VA_ARGS__); \
     }                                           \
-}
+} while(0)
 
 #define ASSERT(x) _ASSERTE(x)
 
commit 55cf72c2a81dd540db9c7626850f3f9ea26f91c6
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu May 10 23:44:10 2012 +0200

    Revert "Revert "mingw: make sure unicode support is enabled""
    
    This reverts commit dec8f9d049b884db2bf91c40478c832b4a4628fc.

diff --git a/Makefile.am b/Makefile.am
index cf514f1..2e845ec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 INCLUDES =				\
 	-I$(top_srcdir)/common		\
 	$(SPICE_PROTOCOL_CFLAGS)
+AM_CPPFLAGS=-DUNICODE -D_UNICODE
 
 bin_PROGRAMS = vdagent vdservice
 
commit b4b7105c572d50952ae132b722fb59ffce709bb2
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu May 10 23:43:59 2012 +0200

    mingw: add standard main() entry function
    
    Thanks Paolo for the suggestion:
    http://lists.freedesktop.org/archives/spice-devel/2012-May/009291.html

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 5cbe222..9046476 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -1355,7 +1355,11 @@ LRESULT CALLBACK VDAgent::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARA
     return 0;
 }
 
+#ifdef __GNUC__
+int main(int argc,char **argv)
+#else
 int APIENTRY _tWinMain(HINSTANCE instance, HINSTANCE prev_instance, LPTSTR cmd_line, int cmd_show)
+#endif
 {
     VDAgent* vdagent = VDAgent::get();
     vdagent->run();
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 4701f5a..9c5f569 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -1216,7 +1216,22 @@ void VDService::write_agent_control(uint32_t type, uint32_t opaque)
     }
 }
 
-int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
+#ifdef __GNUC__
+#undef _tmain
+#ifdef UNICODE
+int _tmain(int argc, TCHAR* argv[]);
+int main(void)
+{
+   int argc;
+   argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+   return _tmain(argc, argv);
+}
+#else
+#define _tmain main
+#endif
+#endif
+
+int _tmain(int argc, TCHAR* argv[])
 {
     bool success = false;
 
commit 1a7ad7ab1f8a0aedffb4060ff41ae98393584165
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu May 10 23:43:39 2012 +0200

    build-sys: fix autoreconf -vfi

diff --git a/configure.ac b/configure.ac
index 77d5c25..28c9d23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,7 +14,7 @@ AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])
 
-AM_INIT_AUTOMAKE([1.11 subdir-objects no-dist-gzip dist-xz tar-ustar])
+AM_INIT_AUTOMAKE([1.11 foreign subdir-objects no-dist-gzip dist-xz tar-ustar])
 
 AM_SILENT_RULES([yes])
 


More information about the Spice-commits mailing list