unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* is there a hook run when display geometry changes?
@ 2011-08-12 17:51 Edward O'Connor
  2011-08-12 18:03 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Edward O'Connor @ 2011-08-12 17:51 UTC (permalink / raw)
  To: emacs-devel

Hi.

Depending on the geometry of the primary display, I like my Emacs to use
a different font size and a different window geometry. I have a function
in my .emacs which inspects (display-pixel-width) and
(display-pixel-height) and then does the right thing, and I run this
function from `emacs-startup-hook'.

This works well enough, but it'd be even awesomer if I could make Emacs
call this function automatically when I plug my laptop into an external
display. On GNUStep and Mac OS X, applications can listen for
NSApplicationDidChangeScreenParametersNotification for this sort of
thing. I assume there is similar functionality under X11 and on Windows.

Is there an existing hook for screen geometry changes that should be run
when Emacs gets an NSApplicationDidChangeScreenParametersNotification?
If not, is this a feature people would be interested in? What are other
people already doing for this?


Thanks,
Ted



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 17:51 is there a hook run when display geometry changes? Edward O'Connor
@ 2011-08-12 18:03 ` Eli Zaretskii
  2011-08-12 18:15   ` Edward O'Connor
  2011-08-12 19:01 ` David De La Harpe Golden
  2011-08-12 19:09 ` Antoine Levitt
  2 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2011-08-12 18:03 UTC (permalink / raw)
  To: Edward O'Connor; +Cc: emacs-devel

> From: "Edward O'Connor" <hober0@gmail.com>
> Date: Fri, 12 Aug 2011 10:51:25 -0700
> 
> Is there an existing hook for screen geometry changes that should be run
> when Emacs gets an NSApplicationDidChangeScreenParametersNotification?

Is window-configuration-change-hook what you want?



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 18:03 ` Eli Zaretskii
@ 2011-08-12 18:15   ` Edward O'Connor
  2011-08-12 18:28     ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Edward O'Connor @ 2011-08-12 18:15 UTC (permalink / raw)
  To: emacs-devel

Eli wrote:
> Is window-configuration-change-hook what you want?

No, I don't think so. `window-configuration-change-hook' is run when
there's a change to the windows being displayed in an Emacs frame. What
I'm asking for is something more like `display-configuration-change-hook',
which would get run whenever the number of displays available to Emacs
changes (adding or removing entries from x_display_list, or
geometry/resolution changes to any of its entries, assuming my read of
xterm.c is correct).

I don't think there's such a feature, but it would be really great if
there were such a thing. :)


Ted



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 18:15   ` Edward O'Connor
@ 2011-08-12 18:28     ` Eli Zaretskii
  2011-08-12 18:59       ` David De La Harpe Golden
  2011-08-12 19:37       ` Edward O'Connor
  0 siblings, 2 replies; 20+ messages in thread
From: Eli Zaretskii @ 2011-08-12 18:28 UTC (permalink / raw)
  To: Edward O'Connor; +Cc: emacs-devel

> From: "Edward O'Connor" <hober0@gmail.com>
> Date: Fri, 12 Aug 2011 11:15:55 -0700
> 
> Eli wrote:
> > Is window-configuration-change-hook what you want?
> 
> No, I don't think so. `window-configuration-change-hook' is run when
> there's a change to the windows being displayed in an Emacs frame.

It is also run when the frame geometry changes, if my reading of the
code is correct.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 18:28     ` Eli Zaretskii
@ 2011-08-12 18:59       ` David De La Harpe Golden
  2011-08-12 19:10         ` Thien-Thi Nguyen
  2011-08-12 19:37       ` Edward O'Connor
  1 sibling, 1 reply; 20+ messages in thread
From: David De La Harpe Golden @ 2011-08-12 18:59 UTC (permalink / raw)
  To: emacs-devel

On 12/08/11 19:28, Eli Zaretskii wrote:
>> No, I don't think so. `window-configuration-change-hook' is run when
>> there's a change to the windows being displayed in an Emacs frame.
>
> It is also run when the frame geometry changes, if my reading of the
> code is correct.
>

But the frame geometry mightn't always be said to change just because 
display geometry changes in current window systems, AFAIK  e.g. on X11, 
you'd want a hook run when emacs [selects for] and gets an xrandr 
XRRScreenChangeNotify event, I think.  Could be a separate 
display-configuration-change-hook or maybe another trigger of 
window-configuration-change hook.

I reckon it's a reasonable feature request, anyway (Edward, you could 
maybe file a wishlist item in the bug tracker?), though I confess I 
haven't checked the current code's behaviour on display hotplug changes.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 17:51 is there a hook run when display geometry changes? Edward O'Connor
  2011-08-12 18:03 ` Eli Zaretskii
@ 2011-08-12 19:01 ` David De La Harpe Golden
  2011-08-12 19:09 ` Antoine Levitt
  2 siblings, 0 replies; 20+ messages in thread
From: David De La Harpe Golden @ 2011-08-12 19:01 UTC (permalink / raw)
  To: emacs-devel

On 12/08/11 18:51, Edward O'Connor wrote:

> What are other
> people already doing for this?

[Well, I find the browser-like C-x C-+/C--/C-0 scaling feature covers 
temporary cases like plugging into a projector for a presentation]






^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 17:51 is there a hook run when display geometry changes? Edward O'Connor
  2011-08-12 18:03 ` Eli Zaretskii
  2011-08-12 19:01 ` David De La Harpe Golden
@ 2011-08-12 19:09 ` Antoine Levitt
  2 siblings, 0 replies; 20+ messages in thread
From: Antoine Levitt @ 2011-08-12 19:09 UTC (permalink / raw)
  To: emacs-devel

12/08/11 19:51, Edward O'Connor
> Hi.
>
> Depending on the geometry of the primary display, I like my Emacs to use
> a different font size and a different window geometry. I have a function
> in my .emacs which inspects (display-pixel-width) and
> (display-pixel-height) and then does the right thing, and I run this
> function from `emacs-startup-hook'.
>
> This works well enough, but it'd be even awesomer if I could make Emacs
> call this function automatically when I plug my laptop into an external
> display. On GNUStep and Mac OS X, applications can listen for
> NSApplicationDidChangeScreenParametersNotification for this sort of
> thing. I assume there is similar functionality under X11 and on Windows.
>
> Is there an existing hook for screen geometry changes that should be run
> when Emacs gets an NSApplicationDidChangeScreenParametersNotification?
> If not, is this a feature people would be interested in? What are other
> people already doing for this?
>
>
> Thanks,
> Ted

Not sure if that's what you want, but there's a bunch of stuff in
special-event-map. If all else fails, you can always run an external
script that listens for the notifications, then executes the function
via emacsclient.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 18:59       ` David De La Harpe Golden
@ 2011-08-12 19:10         ` Thien-Thi Nguyen
  2011-08-12 19:40           ` David De La Harpe Golden
  0 siblings, 1 reply; 20+ messages in thread
From: Thien-Thi Nguyen @ 2011-08-12 19:10 UTC (permalink / raw)
  To: David De La Harpe Golden; +Cc: emacs-devel

() David De La Harpe Golden <david@harpegolden.net>
() Fri, 12 Aug 2011 19:59:34 +0100

   e.g. on X11, you'd want a hook run when emacs [selects for]
   and gets an xrandr XRRScreenChangeNotify event, I think.
   Could be a separate display-configuration-change-hook or
   maybe another trigger of window-configuration-change hook.

Perhaps there's a way to request such notifications from dbus.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 18:28     ` Eli Zaretskii
  2011-08-12 18:59       ` David De La Harpe Golden
@ 2011-08-12 19:37       ` Edward O'Connor
  2011-08-12 20:20         ` Eli Zaretskii
  1 sibling, 1 reply; 20+ messages in thread
From: Edward O'Connor @ 2011-08-12 19:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> Eli wrote:
>> > Is window-configuration-change-hook what you want?
>>
>> No, I don't think so. `window-configuration-change-hook' is run when
>> there's a change to the windows being displayed in an Emacs frame.
>
> It is also run when the frame geometry changes, if my reading of the
> code is correct.

But the frame geometry hasn't changed either. Actually, the situation
is quite the opposite: I want to cause the frame geometry to change
when the display geometry changes.


Ted



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 19:10         ` Thien-Thi Nguyen
@ 2011-08-12 19:40           ` David De La Harpe Golden
  2011-08-12 20:04             ` Thien-Thi Nguyen
  0 siblings, 1 reply; 20+ messages in thread
From: David De La Harpe Golden @ 2011-08-12 19:40 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: emacs-devel

On 12/08/11 20:10, Thien-Thi Nguyen wrote:
> () David De La Harpe Golden<david@harpegolden.net>
> () Fri, 12 Aug 2011 19:59:34 +0100
>
>     e.g. on X11, you'd want a hook run when emacs [selects for]
>     and gets an xrandr XRRScreenChangeNotify event, I think.
>     Could be a separate display-configuration-change-hook or
>     maybe another trigger of window-configuration-change hook.
>
> Perhaps there's a way to request such notifications from dbus.

That would seem rather unnecessarily convoluted. libxrandr exists and 
has the function for it. man 3 xrandr

A XRRScreenChangeNotifyEvent is sent to a client that has requested 
notification whenever the screen configuration is changed. A client can 
perform this request by calling XRRSelectInput, passing the display, the 
root window, and the RRScreenChangeNotifyMask mask.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 19:40           ` David De La Harpe Golden
@ 2011-08-12 20:04             ` Thien-Thi Nguyen
  2011-08-12 21:18               ` David De La Harpe Golden
  0 siblings, 1 reply; 20+ messages in thread
From: Thien-Thi Nguyen @ 2011-08-12 20:04 UTC (permalink / raw)
  To: David De La Harpe Golden; +Cc: emacs-devel

() David De La Harpe Golden <david@harpegolden.net>
() Fri, 12 Aug 2011 20:40:41 +0100

   > Perhaps there's a way to request such notifications from dbus.

   That would seem rather unnecessarily convoluted.

Yes, but on the other hand...

   libxrandr exists and has the
   function for it. man 3 xrandr

   A XRRScreenChangeNotifyEvent is sent to a client that has requested
   notification whenever the screen configuration is changed. A client can
   perform this request by calling XRRSelectInput, passing the display, the root
   window, and the RRScreenChangeNotifyMask mask.

...keeping out of C has its charms, too.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 19:37       ` Edward O'Connor
@ 2011-08-12 20:20         ` Eli Zaretskii
  2011-08-15 21:48           ` Edward O'Connor
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2011-08-12 20:20 UTC (permalink / raw)
  To: Edward O'Connor; +Cc: emacs-devel

> From: "Edward O'Connor" <hober0@gmail.com>
> Date: Fri, 12 Aug 2011 12:37:03 -0700
> Cc: emacs-devel@gnu.org
> 
> >> Eli wrote:
> >> > Is window-configuration-change-hook what you want?
> >>
> >> No, I don't think so. `window-configuration-change-hook' is run when
> >> there's a change to the windows being displayed in an Emacs frame.
> >
> > It is also run when the frame geometry changes, if my reading of the
> > code is correct.
> 
> But the frame geometry hasn't changed either. Actually, the situation
> is quite the opposite: I want to cause the frame geometry to change
> when the display geometry changes.

Why don't you try it?  If it works (and I don't know if it does), you
will have your feature today rather than in a year (since Emacs 24 is
in feature freeze already).

It's true that this hook will be called in circumstances where you
don't need to do anything, but I'm assuming that you can detect
whether the display geometry changes and DTRT.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 20:04             ` Thien-Thi Nguyen
@ 2011-08-12 21:18               ` David De La Harpe Golden
  2011-08-12 21:47                 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 20+ messages in thread
From: David De La Harpe Golden @ 2011-08-12 21:18 UTC (permalink / raw)
  To: emacs-devel

On 12/08/11 21:04, Thien-Thi Nguyen wrote:
 >
> ...keeping out of C has its charms, too.

Shrug. Emacs already has x event processing implemented in C in xterm.c, 
though.




















^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 21:18               ` David De La Harpe Golden
@ 2011-08-12 21:47                 ` Thien-Thi Nguyen
  2011-08-13  5:47                   ` David De La Harpe Golden
  0 siblings, 1 reply; 20+ messages in thread
From: Thien-Thi Nguyen @ 2011-08-12 21:47 UTC (permalink / raw)
  To: David De La Harpe Golden; +Cc: emacs-devel

() David De La Harpe Golden <david@harpegolden.net>
() Fri, 12 Aug 2011 22:18:46 +0100

   Shrug. Emacs already has x event processing
   implemented in C in xterm.c, though.

I suggest writing the code and posting it.
First in C, if you prefer.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 21:47                 ` Thien-Thi Nguyen
@ 2011-08-13  5:47                   ` David De La Harpe Golden
  0 siblings, 0 replies; 20+ messages in thread
From: David De La Harpe Golden @ 2011-08-13  5:47 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: emacs-devel

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

On 12/08/11 22:47, Thien-Thi Nguyen wrote:
> () David De La Harpe Golden<david@harpegolden.net>
> () Fri, 12 Aug 2011 22:18:46 +0100
>
>     Shrug. Emacs already has x event processing
>     implemented in C in xterm.c, though.
>
> I suggest writing the code and posting it.

Yes, I was idly doing so. Attached is a first stab (x11 only).

















[-- Attachment #2: xrandr_monitoring_r1.diff --]
[-- Type: text/x-patch, Size: 9389 bytes --]

=== modified file 'configure.in'
--- configure.in	2011-08-04 17:04:39 +0000
+++ configure.in	2011-08-13 04:36:34 +0000
@@ -160,6 +160,8 @@
 OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
 OPTION_DEFAULT_ON([imagemagick],[don't compile with ImageMagick image support])
 
+OPTION_DEFAULT_ON([xrandr],[don't compile with XRandR support])
+
 OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
 OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
 OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
@@ -2590,6 +2592,21 @@
 fi
 AC_SUBST(LIBXSM)
 
+### Use xrandr (-lXrandr) if available
+HAVE_XRANDR=no
+XRANDR_LIBS=
+XRANDR_CFLAGS=
+if test "${HAVE_X11}" = "yes"; then
+  if test "${with_xrandr}" != "no"; then
+    PKG_CHECK_MODULES(XRANDR, xrandr > 1.0, HAVE_XRANDR=yes, HAVE_XRANDR=no)
+    if test "${HAVE_XRANDR}" = "yes"; then
+      AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the Xrandr library (-lXrandr).])
+    fi
+  fi
+fi
+AC_SUBST(XRANDR_LIBS)
+AC_SUBST(XRANDR_CFLAGS)
+
 ### Use libxml (-lxml2) if available
 if test "${with_xml2}" != "no"; then
   ### I'm not sure what the version number should be, so I just guessed.
@@ -3700,6 +3717,8 @@
 echo "  Does Emacs use -lotf?                                   ${HAVE_LIBOTF}"
 echo "  Does Emacs use -lxft?                                   ${HAVE_XFT}"
 
+echo "  Does Emacs use -lXrandr?                                ${HAVE_XRANDR}"
+
 echo "  Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}"
 echo
 

=== modified file 'lisp/frame.el'
--- lisp/frame.el	2011-07-16 13:02:51 +0000
+++ lisp/frame.el	2011-08-13 04:04:16 +0000
@@ -1585,6 +1585,18 @@
 (define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1")
 
 \f
+;; Display geometry changes
+
+(defun handle-screen-change-notify-event (event)
+  "Handle screen-change-notify-event on the display in EVENT.
+   At present, just runs any window-configuration-changed-hook
+   for all frames on the display."
+  ; FIXME: do we want a completely separate hook instead?
+  (interactive "e")
+  (let ((display-name (nth 1 event)))
+    (mapcar #'run-window-configuration-change-hook
+            (frames-on-display-list display-name))))
+
 ;;;; Key bindings
 
 (define-key ctl-x-5-map "2" 'make-frame-command)
@@ -1592,6 +1604,9 @@
 (define-key ctl-x-5-map "0" 'delete-frame)
 (define-key ctl-x-5-map "o" 'other-frame)
 
+(define-key special-event-map [screen-change-notify-event]
+  'handle-screen-change-notify-event)
+
 (provide 'frame)
 
 ;;; frame.el ends here

=== modified file 'src/Makefile.in'
--- src/Makefile.in	2011-08-04 17:04:39 +0000
+++ src/Makefile.in	2011-08-13 05:16:52 +0000
@@ -170,6 +170,9 @@
 
 LIBXSM=@LIBXSM@
 
+XRANDR_CFLAGS = @XRANDR_CFLAGS@
+XRANDR_LIBS = @XRANDR_LIBS@
+
 LIBXTR6=@LIBXTR6@
 
 ## $(LIBXMU) -lXt $(LIBXTR6) -lXext if USE_X_TOOLKIT, else $(LIBXSM).
@@ -313,6 +316,7 @@
   $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
   $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \
   $(LIBGNUTLS_CFLAGS) \
+  $(XRANDR_CFLAGS) \
   $(C_WARNINGS_SWITCH) $(CFLAGS)
 ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS)
 
@@ -388,7 +392,8 @@
    $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
    $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
    $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
-   $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \
+   $(LIBGNUTLS_LIBS) $(XRANDR_LIBS) \
+   $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \
    $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
 
 all: emacs$(EXEEXT) $(OTHER_FILES)

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2011-08-04 17:04:39 +0000
+++ src/keyboard.c	2011-08-13 03:41:32 +0000
@@ -331,6 +331,8 @@
 #endif
 static Lisp_Object Qconfig_changed_event;
 
+static Lisp_Object Qscreen_change_notify_event;
+
 /* Lisp_Object Qmouse_movement; - also an event header */
 
 /* Properties of event headers.  */
@@ -4033,6 +4035,11 @@
 	  obj = make_lispy_event (event);
 	  kbd_fetch_ptr = event + 1;
 	}
+      else if (event->kind == SCREEN_CHANGE_NOTIFY_EVENT)
+	{
+	  obj = make_lispy_event (event);
+	  kbd_fetch_ptr = event + 1;
+	}
       else
 	{
 	  /* If this event is on a different frame, return a switch-frame this
@@ -5987,6 +5994,9 @@
 			       Qnil));
        }
 #endif /* HAVE_GPM */
+    case SCREEN_CHANGE_NOTIFY_EVENT:
+	return Fcons (Qscreen_change_notify_event,
+                      Fcons (event->frame_or_window, Qnil));
 
       /* The 'kind' field of the event is something we don't recognize.  */
     default:
@@ -11527,6 +11537,7 @@
   DEFSYM (Qsave_session, "save-session");
   DEFSYM (Qconfig_changed_event, "config-changed-event");
   DEFSYM (Qmenu_enable, "menu-enable");
+  DEFSYM (Qscreen_change_notify_event, "screen-change-notify-event");
 
 #if defined (WINDOWSNT)
   DEFSYM (Qlanguage_change, "language-change");
@@ -12288,6 +12299,10 @@
 
   initial_define_lispy_key (Vspecial_event_map, "config-changed-event",
 			    "ignore");
+
+  initial_define_lispy_key (Vspecial_event_map, "screen-change-notify-event",
+			    "ignore");
+
 }
 
 /* Mark the pointers in the kboard objects.

=== modified file 'src/termhooks.h'
--- src/termhooks.h	2011-06-06 19:43:39 +0000
+++ src/termhooks.h	2011-08-13 03:18:24 +0000
@@ -206,6 +206,13 @@
   , NS_NONKEY_EVENT
 #endif
 
+  /* Generated when a bitmapped display's (upon which emacs has
+     frame(s) open) geometry changes dynamically e.g. by monitor
+     hotplugging or resolution change.
+     On X, that which is handled by the X Resize and Rotate
+     Extension.  */
+  , SCREEN_CHANGE_NOTIFY_EVENT
+
 };
 
 /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT

=== modified file 'src/window.c'
--- src/window.c	2011-08-05 11:04:44 +0000
+++ src/window.c	2011-08-13 04:04:18 +0000
@@ -6542,7 +6542,11 @@
 	       doc: /* Functions to call when window configuration changes.
 The buffer-local part is run once per window, with the relevant window
 selected; while the global part is run only once for the modified frame,
-with the relevant frame selected.  */);
+with the relevant frame selected.
+
+If emacs can detect them, changes to the overall geometry of a display
+upon which a frame is open will by default also run this hook via
+the function `handle-screen-change-notify-event`.  */);
   Vwindow_configuration_change_hook = Qnil;
 
   DEFVAR_LISP ("recenter-redisplay", Vrecenter_redisplay,

=== modified file 'src/xterm.c'
--- src/xterm.c	2011-08-04 11:06:22 +0000
+++ src/xterm.c	2011-08-13 05:00:47 +0000
@@ -85,6 +85,10 @@
 #include <X11/Shell.h>
 #endif
 
+#ifdef HAVE_XRANDR
+#include <X11/extensions/Xrandr.h>
+#endif
+
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
@@ -359,7 +363,6 @@
 static void x_wm_set_icon_pixmap (struct frame *, ptrdiff_t);
 static void x_initialize (void);
 
-
 /* Flush display of frame F, or of all frames if F is null.  */
 
 static void
@@ -6993,6 +6996,26 @@
       break;
 
     default:
+#ifdef HAVE_XRANDR
+    /* xrandr extension may or may not be present on a display =>
+       can't check for it as a constant C "case" arg, hence "if" here  */
+    if (dpyinfo->xrandr_present &&
+        (event.type == (dpyinfo->xrandr_event_base + RRScreenChangeNotify)))
+      {
+        /* FIXME: is XRRUpdateConfiguration actually called by the toolkit/gtk+?
+           Even if it is, can/should we call it ourselves here?  */
+#if !(defined USE_X_TOOLKIT || defined USE_GTK)
+        BLOCK_INPUT;
+        XRRUpdateConfiguration(&event);
+        UNBLOCK_INPUT;
+#endif
+        /* FIXME: do we really need a separate event kind? It seems
+           conceptually similar to a CONFIG_CHANGED_EVENT */
+        inev.ie.kind = SCREEN_CHANGE_NOTIFY_EVENT;
+        inev.ie.frame_or_window = XCAR(dpyinfo->name_list_element);
+      }
+    goto OTHER;
+#endif /* HAVE_XRANDR */
     OTHER:
 #ifdef USE_X_TOOLKIT
     BLOCK_INPUT;
@@ -8169,6 +8192,25 @@
 
 #endif /* not HAVE_X11R6_XIM */
 
+\f
+/***********************************************************************
+			   X Resize and Rotate
+ ***********************************************************************/
+
+#ifdef HAVE_XRANDR
+
+static void
+xrandr_initialize (struct x_display_info *dpyinfo)
+{
+  dpyinfo->xrandr_present = XRRQueryExtension (dpyinfo->display,
+                                               &(dpyinfo->xrandr_event_base),
+                                               &(dpyinfo->xrandr_error_base));
+  if (dpyinfo->xrandr_present)
+    XRRSelectInput (dpyinfo->display, dpyinfo->root_window,
+                    RRScreenChangeNotifyMask);
+}
+
+#endif /* HAVE_XRANDR */
 
 \f
 /* Calculate the absolute position in frame F
@@ -10315,6 +10357,10 @@
   xim_initialize (dpyinfo, resource_name);
 #endif
 
+#ifdef HAVE_XRANDR
+  xrandr_initialize (dpyinfo);
+#endif
+
   xsettings_initialize (dpyinfo);
 
   /* This is only needed for distinguishing keyboard and process input.  */

=== modified file 'src/xterm.h'
--- src/xterm.h	2011-07-07 02:24:56 +0000
+++ src/xterm.h	2011-08-13 02:41:25 +0000
@@ -354,6 +354,14 @@
 
   /* SM */
   Atom Xatom_SM_CLIENT_ID;
+
+#ifdef HAVE_XRANDR
+  /* X Resize and Rotate */
+  Bool xrandr_present;
+  int xrandr_event_base;
+  int xrandr_error_base;
+#endif
+
 };
 
 #ifdef HAVE_X_I18N


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-12 20:20         ` Eli Zaretskii
@ 2011-08-15 21:48           ` Edward O'Connor
  2011-08-16  6:48             ` Eli Zaretskii
  2011-08-16 18:54             ` martin rudalics
  0 siblings, 2 replies; 20+ messages in thread
From: Edward O'Connor @ 2011-08-15 21:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> Why don't you try it?

I tried it; it doesn't work. `window-configuration-change-hook'
doesn't get called in this case (though it does get called in many
other cases).


Ted



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-15 21:48           ` Edward O'Connor
@ 2011-08-16  6:48             ` Eli Zaretskii
  2011-08-25  5:21               ` David De La Harpe Golden
  2011-08-16 18:54             ` martin rudalics
  1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2011-08-16  6:48 UTC (permalink / raw)
  To: Edward O'Connor; +Cc: emacs-devel

> From: "Edward O'Connor" <hober0@gmail.com>
> Date: Mon, 15 Aug 2011 14:48:11 -0700
> Cc: emacs-devel@gnu.org
> 
> > Why don't you try it?
> 
> I tried it; it doesn't work. `window-configuration-change-hook'
> doesn't get called in this case (though it does get called in many
> other cases).

Thanks.  So I suggest to file a feature request with the Emacs bug
tracker (by using "M-x report-emacs-bug RET").



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-15 21:48           ` Edward O'Connor
  2011-08-16  6:48             ` Eli Zaretskii
@ 2011-08-16 18:54             ` martin rudalics
  2011-08-16 20:34               ` Stefan Monnier
  1 sibling, 1 reply; 20+ messages in thread
From: martin rudalics @ 2011-08-16 18:54 UTC (permalink / raw)
  To: Edward O'Connor; +Cc: Eli Zaretskii, emacs-devel

 > I tried it; it doesn't work. `window-configuration-change-hook'
 > doesn't get called in this case (though it does get called in many
 > other cases).

How about `window-size-change-functions'?

martin



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-16 18:54             ` martin rudalics
@ 2011-08-16 20:34               ` Stefan Monnier
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Monnier @ 2011-08-16 20:34 UTC (permalink / raw)
  To: martin rudalics; +Cc: Eli Zaretskii, Edward O'Connor, emacs-devel

>> I tried it; it doesn't work. `window-configuration-change-hook'
>> doesn't get called in this case (though it does get called in many
>> other cases).
> How about `window-size-change-functions'?

I don't think any hook gets run, currently, because as far as Emacs is
concerned, nothing has changed.  It just so happens that the display it
is using has changed size, but Emacs frames and windows aren't directly
linked to the display size: the display size is only queried in a few
relatively rare occasions.


        Stefan



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: is there a hook run when display geometry changes?
  2011-08-16  6:48             ` Eli Zaretskii
@ 2011-08-25  5:21               ` David De La Harpe Golden
  0 siblings, 0 replies; 20+ messages in thread
From: David De La Harpe Golden @ 2011-08-25  5:21 UTC (permalink / raw)
  To: emacs-devel; +Cc: Edward O'Connor

On 16/08/11 07:48, Eli Zaretskii wrote:
>> From: "Edward O'Connor"<hober0@gmail.com>
>> Date: Mon, 15 Aug 2011 14:48:11 -0700
>> Cc: emacs-devel@gnu.org
>>
>>> Why don't you try it?
>>
>> I tried it; it doesn't work. `window-configuration-change-hook'
>> doesn't get called in this case (though it does get called in many
>> other cases).
>
> Thanks.  So I suggest to file a feature request with the Emacs bug
> tracker (by using "M-x report-emacs-bug RET").
>

I went ahead and filed it in the bug tracker so the feature request 
doesn't get lost over the freeze period, see #9366

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9366




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2011-08-25  5:21 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-12 17:51 is there a hook run when display geometry changes? Edward O'Connor
2011-08-12 18:03 ` Eli Zaretskii
2011-08-12 18:15   ` Edward O'Connor
2011-08-12 18:28     ` Eli Zaretskii
2011-08-12 18:59       ` David De La Harpe Golden
2011-08-12 19:10         ` Thien-Thi Nguyen
2011-08-12 19:40           ` David De La Harpe Golden
2011-08-12 20:04             ` Thien-Thi Nguyen
2011-08-12 21:18               ` David De La Harpe Golden
2011-08-12 21:47                 ` Thien-Thi Nguyen
2011-08-13  5:47                   ` David De La Harpe Golden
2011-08-12 19:37       ` Edward O'Connor
2011-08-12 20:20         ` Eli Zaretskii
2011-08-15 21:48           ` Edward O'Connor
2011-08-16  6:48             ` Eli Zaretskii
2011-08-25  5:21               ` David De La Harpe Golden
2011-08-16 18:54             ` martin rudalics
2011-08-16 20:34               ` Stefan Monnier
2011-08-12 19:01 ` David De La Harpe Golden
2011-08-12 19:09 ` Antoine Levitt

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).