all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: emacs-devel@gnu.org
Subject: Proposal:  window-system-version function
Date: Mon, 21 May 2012 18:11:02 +0400	[thread overview]
Message-ID: <4FBA4CF6.1030007@yandex.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

This patch replaces global variable 'window-system-version' with the function
which returns the window system version for the specified frame. An obvious
reason for this is to have correct results when Emacs is running with both
TTY and X frames.

Dmitry

[-- Attachment #2: window_system_version.patch --]
[-- Type: text/plain, Size: 6068 bytes --]

=== modified file 'lisp/international/mule-diag.el'
--- lisp/international/mule-diag.el	2012-01-19 07:21:25 +0000
+++ lisp/international/mule-diag.el	2012-05-21 13:54:49 +0000
@@ -1105,7 +1105,7 @@
       (insert-section 2 "Display")
       (if window-system
 	  (insert (format "Window-system: %s, version %s"
-			  window-system window-system-version))
+			  window-system (window-system-version)))
 	(insert "Terminal: " (getenv "TERM")))
       (insert "\n\n")
 

=== modified file 'lisp/textmodes/artist.el'
--- lisp/textmodes/artist.el	2012-04-11 11:57:21 +0000
+++ lisp/textmodes/artist.el	2012-05-21 13:58:38 +0000
@@ -5371,20 +5371,21 @@
   (interactive)
   (require 'reporter)
   (if (y-or-n-p "Do you want to submit a bug report on Artist? ")
-      (let ((to   artist-maintainer-address)
-	    (vars '(window-system
-		    window-system-version
-		    ;;
-		    artist-rubber-banding
-		    artist-interface-with-rect
-		    artist-aspect-ratio
-		    ;; Now the internal ones
-		    artist-curr-go
-		    artist-key-poly-point-list
-		    artist-key-shape
-		    artist-key-draw-how
-		    artist-arrow-point-1
-		    artist-arrow-point-2)))
+      (let* ((to artist-maintainer-address)
+	     (window-system-version (window-system-version))
+	     (vars '(window-system
+		     window-system-version
+		     ;;
+		     artist-rubber-banding
+		     artist-interface-with-rect
+		     artist-aspect-ratio
+		     ;; Now the internal ones
+		     artist-curr-go
+		     artist-key-poly-point-list
+		     artist-key-shape
+		     artist-key-draw-how
+		     artist-arrow-point-1
+		     artist-arrow-point-2)))
 	;; Remove those variables from vars that are not bound
 	(mapc
 	 (function

=== modified file 'src/dispnew.c'
--- src/dispnew.c	2012-05-01 00:30:11 +0000
+++ src/dispnew.c	2012-05-21 13:55:48 +0000
@@ -6301,9 +6301,6 @@
   if (!inhibit_window_system && display_arg)
     {
       Vinitial_window_system = Qx;
-#ifdef HAVE_X11
-      Vwindow_system_version = make_number (11);
-#endif
 #ifdef GNU_LINUX
       /* In some versions of ncurses,
 	 tputs crashes if we have not called tgetent.
@@ -6319,7 +6316,6 @@
   if (!inhibit_window_system)
     {
       Vinitial_window_system = Qw32;
-      Vwindow_system_version = make_number (1);
       adjust_frame_glyphs_initially ();
       return;
     }
@@ -6333,7 +6329,6 @@
       )
     {
       Vinitial_window_system = Qns;
-      Vwindow_system_version = make_number (10);
       adjust_frame_glyphs_initially ();
       return;
     }
@@ -6575,10 +6570,6 @@
 use `display-graphic-p' or any of the other `display-*-p'
 predicates which report frame's specific UI-related capabilities.  */);
 
-  DEFVAR_LISP ("window-system-version", Vwindow_system_version,
-	       doc: /* The version number of the window system in use.
-For X windows, this is 11.  */);
-
   DEFVAR_BOOL ("cursor-in-echo-area", cursor_in_echo_area,
 	       doc: /* Non-nil means put cursor in minibuffer, at end of any message there.  */);
 
@@ -6614,8 +6605,5 @@
 #ifdef CANNOT_DUMP
   if (noninteractive)
 #endif
-    {
-      Vinitial_window_system = Qnil;
-      Vwindow_system_version = Qnil;
-    }
+    Vinitial_window_system = Qnil;
 }

=== modified file 'src/frame.c'
--- src/frame.c	2012-03-10 07:46:07 +0000
+++ src/frame.c	2012-05-21 13:54:49 +0000
@@ -256,6 +256,52 @@
     return type;
 }
 
+DEFUN ("window-system-version", Fwindow_system_version, Swindow_system_version, 0, 1, 0,
+       doc: /* The version of the window system that FRAME is displaying through.
+It's value is a number:
+ - 0 for a termcap frame,
+ - Major X protocol version for the frame on X display,
+ - Major OS version for the frame on MS-Windows display,
+ - 24 for the frame on direct-write MS-DOS display,
+ - 10 for the frame on a GNUstep or Macintosh Cocoa display.
+
+FRAME defaults to the currently selected frame.  */)
+     (Lisp_Object frame)
+{
+  struct frame *f;
+
+  if (NILP (frame))
+    frame = selected_frame;
+  CHECK_LIVE_FRAME (frame);
+  f = XFRAME (frame);
+
+  switch (f->output_method)
+    {
+    case output_initial:
+    case output_termcap:
+      return make_number (0);
+#ifdef HAVE_X_WINDOWS
+    case output_x_window:
+      return make_number (ProtocolVersion (FRAME_X_DISPLAY (f)));
+#endif
+#ifdef WINDOWSNT
+    case output_w32:
+      return make_number (w32_major_version);
+#endif
+#ifdef MSDOS
+    case output_msdos_raw:
+      return make_number (24);
+#endif
+#ifdef HAVE_NS
+    case output_mac:
+    case output_ns:
+      return make_number (10);
+#endif
+    default:
+      abort ();
+    }
+}
+
 struct frame *
 make_frame (int mini_p)
 {
@@ -4455,6 +4501,7 @@
   defsubr (&Sframep);
   defsubr (&Sframe_live_p);
   defsubr (&Swindow_system);
+  defsubr (&Swindow_system_version);
   defsubr (&Smake_terminal_frame);
   defsubr (&Shandle_switch_frame);
   defsubr (&Sselect_frame);

=== modified file 'src/msdos.c'
--- src/msdos.c	2012-04-09 13:05:48 +0000
+++ src/msdos.c	2012-05-21 13:54:49 +0000
@@ -1813,7 +1813,6 @@
 	}
 
       Vinitial_window_system = Qpc;
-      Vwindow_system_version = make_number (23); /* RE Emacs version */
       tty->terminal->type = output_msdos_raw;
 
       /* If Emacs was dumped on DOS/V machine, forget the stale VRAM

=== modified file 'src/w32fns.c'
--- src/w32fns.c	2012-05-18 08:36:50 +0000
+++ src/w32fns.c	2012-05-21 13:54:49 +0000
@@ -4729,7 +4729,6 @@
     error ("Cannot connect to server %s", SDATA (name));
 
   w32_in_use = 1;
-  XSETFASTINT (Vwindow_system_version, w32_major_version);
 
   return dpyinfo;
 }
@@ -4820,7 +4819,6 @@
 
   w32_in_use = 1;
 
-  XSETFASTINT (Vwindow_system_version, w32_major_version);
   return Qnil;
 }
 

=== modified file 'src/xfns.c'
--- src/xfns.c	2012-05-19 21:46:43 +0000
+++ src/xfns.c	2012-05-21 13:54:49 +0000
@@ -4063,7 +4063,6 @@
     error ("Cannot connect to X server %s", SDATA (name));
 
   x_in_use = 1;
-  XSETFASTINT (Vwindow_system_version, 11);
 
   return dpyinfo;
 }
@@ -4118,7 +4117,6 @@
 
   x_in_use = 1;
 
-  XSETFASTINT (Vwindow_system_version, 11);
   return Qnil;
 }
 


             reply	other threads:[~2012-05-21 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 14:11 Dmitry Antipov [this message]
2012-05-21 16:03 ` Proposal: window-system-version function Stefan Monnier
2012-05-21 16:20 ` Eli Zaretskii
2012-05-22  5:51   ` Dmitry Antipov
2012-05-22 12:41     ` Stefan Monnier
2012-05-22 16:13     ` Eli Zaretskii
2012-05-22  5:08 ` Ken Raeburn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FBA4CF6.1030007@yandex.ru \
    --to=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.