From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround Date: Fri, 30 Dec 2011 11:00:20 +0200 Message-ID: <8339c2v3h7.fsf@gnu.org> References: <69c9ec930ef1d48655624d437aa66d0fce275d3e.1325166766.git.dancol@dancol.org> <4EFC9416.6090005@dancol.org> <4EFC987D.2020901@dancol.org> <4EFCF0BF.1020907@dancol.org> <4EFD2D75.3030603@dancol.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1325235676 10783 80.91.229.12 (30 Dec 2011 09:01:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Dec 2011 09:01:16 +0000 (UTC) Cc: lekktu@gmail.com, 10397@debbugs.gnu.org To: Daniel Colascione Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 30 10:01:12 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RgYKt-00046s-Cp for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2011 10:01:11 +0100 Original-Received: from localhost ([::1]:46267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgYKs-0001mT-Rb for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2011 04:01:10 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:48389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgYKr-0001mG-1L for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 04:01:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgYKp-0001iO-V6 for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 04:01:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgYKp-0001iJ-QW for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 04:01:07 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RgYNe-0004fB-1V for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 04:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Dec 2011 09:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10397 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 10397-submit@debbugs.gnu.org id=B10397.132523580317871 (code B ref 10397); Fri, 30 Dec 2011 09:04:02 +0000 Original-Received: (at 10397) by debbugs.gnu.org; 30 Dec 2011 09:03:23 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgYMz-0004eB-FC for submit@debbugs.gnu.org; Fri, 30 Dec 2011 04:03:22 -0500 Original-Received: from mtaout23.012.net.il ([80.179.55.175]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgYMv-0004e0-RT for 10397@debbugs.gnu.org; Fri, 30 Dec 2011 04:03:19 -0500 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0LX000K00EATQL00@a-mtaout23.012.net.il> for 10397@debbugs.gnu.org; Fri, 30 Dec 2011 11:00:22 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([77.126.18.76]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LX000K9UECJG9D0@a-mtaout23.012.net.il>; Fri, 30 Dec 2011 11:00:22 +0200 (IST) In-reply-to: <4EFD2D75.3030603@dancol.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 30 Dec 2011 04:04:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55301 Archived-At: > Date: Thu, 29 Dec 2011 19:18:13 -0800 > From: Daniel Colascione > Cc: 10397@debbugs.gnu.org > > > NUMCOLORS > > Number of entries in the device's color table, if the device has a > > color depth of no more than 8 bits per pixel. For devices with greater > > color depths, 1 is returned. > > > > (It says "1", but it's a typo for "-1".) > > Good catch. What about this (untested) code? > > hdc = GetDC (dpyinfo->root_window); > if (dpyinfo->has_palette) > cap = GetDeviceCaps (hdc, SIZEPALETTE); > else if (dpyinfo->n_cbits <= 8) > /* According to the MSDN, GetDeviceCaps (NUMCOLORS) is valid only > for devices with at most eight bits per pixel. It's supposed > to return -1 for other displays, but because it actually > returns other, incorrect values under some conditions (e.g., > remote desktop), only use it when we know it's valid. */ > cap = GetDeviceCaps (hdc, NUMCOLORS); > else > cap = -1; Looks good to me. I think this could go into 24.1, unless Jason (or someone else) objects. As I wrote elsewhere, past 24.1, we could explore the possibility of not calling GetDeviceCaps here at all (assuming that using the number of planes and bits per plane does the job even when the latter is 8 or less).