X2Go Bug report logs - #330
Incorrect detection of color depth on Windows

version graph

Package: python-x2go; Maintainer for python-x2go is X2Go Developers <x2go-dev@lists.x2go.org>; Source for python-x2go is src:python-x2go.

Reported by: kenneth <kenneth@wangpedersen.com>

Date: Tue, 22 Oct 2013 05:33:01 UTC

Severity: normal

Tags: patch, pending

Found in version

Fixed in version

Done: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>

Bug is archived. No further changes may be made.

Full log

🔗 View this message in rfc822 format

X-Loop: owner@bugs.x2go.org
Subject: Bug#330: Incorrect detection of color depth on Windows
Reply-To: kenneth <kenneth@wangpedersen.com>, 330@bugs.x2go.org
Resent-From: kenneth <kenneth@wangpedersen.com>
Resent-To: x2go-dev@lists.berlios.de
Resent-CC: X2Go Developers <x2go-dev@lists.berlios.de>
X-Loop: owner@bugs.x2go.org
Resent-Date: Tue, 22 Oct 2013 05:33:01 +0000
Resent-Message-ID: <handler.330.B.138241976221164@bugs.x2go.org>
Resent-Sender: owner@bugs.x2go.org
X-X2Go-PR-Message: report 330
X-X2Go-PR-Package: python-x2go
X-X2Go-PR-Keywords: patch
Received: via spool by submit@bugs.x2go.org id=B.138241976221164
          (code B); Tue, 22 Oct 2013 05:33:01 +0000
Received: (at submit) by bugs.x2go.org; 22 Oct 2013 05:29:22 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED
	autolearn=ham version=3.3.2
X-Greylist: delayed 935 seconds by postgrey-1.34 at ymir; Tue, 22 Oct 2013 07:29:21 CEST
Received: from sender1.zohomail.com (sender1.zohomail.com [])
	by ymir (Postfix) with ESMTP id 3974F5DB16
	for <submit@bugs.x2go.org>; Tue, 22 Oct 2013 07:29:21 +0200 (CEST)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; 
  s=zoho; d=wangpedersen.com; 
Received: from mail.zoho.com by mx.zohomail.com
	with SMTP id 13824188241111001.6217835969067; Mon, 21 Oct 2013 22:13:44 -0700 (PDT)
Date: Mon, 21 Oct 2013 22:13:44 -0700
From: kenneth <kenneth@wangpedersen.com>
To:  <submit@bugs.x2go.org>
Message-ID: <1878608620.350326.1382418824063.JavaMail.sas1@[]>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Priority: Medium
User-Agent: Zoho Mail
X-Mailer: Zoho Mail
Package: python-x2go
Tags: patch

The following code is used when detecting color depth on Windows (in x2go/utils.py):

  return win32api.GetSystemMetrics(2)

The following constant actually has the numeric value 2: 
SM_CXVSCROLL - The width of a vertical scroll bar, in pixels. 
See e.g. http://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx

At least on my system (Windows 7), this value is 17, causing python-x2go to incorrectly identify the display
as having 17 bits-per-pixel.

The attached patch fixes this issue by creating a screen display context and querying it for the color depth.

Kenneth Pedersen

From aba9e380f1a26299042a7f075217c9ad99505f73 Mon Sep 17 00:00:00 2001
From: Kenneth Pedersen <kenneth@wangpedersen.com>
Date: Mon, 21 Oct 2013 22:07:53 +0200
Subject: [PATCH] Detect color depth correctly on Windows

 x2go/utils.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/x2go/utils.py b/x2go/utils.py
index e8d80bc..8ecbf2c 100644
--- a/x2go/utils.py
+++ b/x2go/utils.py
@@ -48,6 +48,8 @@ if _X2GOCLIENT_OS != 'Windows':
 if _X2GOCLIENT_OS == 'Windows':
     import win32api
     import win32gui
+    import win32print
+    import win32con
 def is_in_nx3packmethods(method):
@@ -555,8 +557,10 @@ def local_color_depth():
             return 24
-        return win32api.GetSystemMetrics(2)
+        # This gets the color depth of the primary monitor. All monitors need not have the same color depth.
+        dc = win32gui.GetDC(None)
+        _depth = win32print.GetDeviceCaps(dc, win32con.BITSPIXEL) * win32print.GetDeviceCaps(dc, win32con.PLANES)
+        win32gui.ReleaseDC(None, dc)
 def is_color_depth_ok(depth_session, depth_local):

Send a report that this bug log contains spam.

X2Go Developers <owner@bugs.x2go.org>. Last modified: Sun Sep 20 08:36:19 2020; Machine Name: ymir.das-netzwerkteam.de

X2Go Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.