emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100155: Get window position by re


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-23 r100155: Get window position by reading _NET_FRAME_EXTENTS (Bug#5721).
Date: Thu, 04 Nov 2010 09:41:25 +0100
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100155
committer: Jan D. <address@hidden>
branch nick: emacs-23
timestamp: Thu 2010-11-04 09:41:25 +0100
message:
  Get window position by reading _NET_FRAME_EXTENTS (Bug#5721).
  
  * src/xfns.c (x_real_positions): Try to get _NET_FRAME_EXTENTS first
  before traversing window tree (Bug#5721).
  
  * src/xterm.c (x_term_init): Initialize Xatom_net_frame_extents.
  
  * src/xterm.h (struct x_display_info): Xatom_net_frame_extents is new.
modified:
  src/ChangeLog
  src/xfns.c
  src/xterm.c
  src/xterm.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-11-03 18:55:19 +0000
+++ b/src/ChangeLog     2010-11-04 08:41:25 +0000
@@ -1,3 +1,12 @@
+2010-11-04  Jan Djärv  <address@hidden>
+
+       * xterm.c (x_term_init): Initialize Xatom_net_frame_extents.
+
+       * xterm.h (struct x_display_info): Xatom_net_frame_extents is new.
+
+       * xfns.c (x_real_positions): Try to get _NET_FRAME_EXTENTS first
+       before traversing window tree (Bug#5721).
+
 2010-11-03  Glenn Morris  <address@hidden>
 
        * Makefile.in (CRT_DIR): New variable, set by configure.

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2010-08-01 04:28:09 +0000
+++ b/src/xfns.c        2010-11-04 08:41:25 +0000
@@ -532,12 +532,60 @@
   int win_x, win_y, outer_x, outer_y;
   int real_x = 0, real_y = 0;
   int had_errors = 0;
-  Window win = f->output_data.x->parent_desc;
+  Window win;
+  Atom actual_type;
+  unsigned long actual_size, bytes_remaining;
+  int i, rc, actual_format;
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  long max_len = 400;
+  Display *dpy = FRAME_X_DISPLAY (f);
+  unsigned char *tmp_data = NULL;
+  Atom target_type = XA_CARDINAL;
 
   BLOCK_INPUT;
 
-  x_catch_errors (FRAME_X_DISPLAY (f));
-
+  x_catch_errors (dpy);
+
+  win = FRAME_OUTER_WINDOW (f);
+  /* Try _NET_FRAME_EXTENTS first.  */
+  rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_frame_extents,
+                           0, max_len, False, target_type,
+                           &actual_type, &actual_format, &actual_size,
+                           &bytes_remaining, &tmp_data);
+
+  if (0 && rc == Success && actual_type == target_type && !x_had_errors_p (dpy)
+      && actual_size == 4 && actual_format == 32)
+    {
+      int ign;
+      Window rootw;
+
+      XGetGeometry (FRAME_X_DISPLAY (f), win,
+                    &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);
+      long *fe = (long *)tmp_data;
+      
+      FRAME_X_OUTPUT (f)->x_pixels_outer_diff = fe[0];
+      FRAME_X_OUTPUT (f)->y_pixels_outer_diff = fe[2];
+      *xptr = real_x - fe[0];
+      *yptr = real_y - fe[2];
+
+      if (FRAME_X_WINDOW (f) != win) 
+        {
+          XGetGeometry (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                        &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);
+
+          f->x_pixels_diff = real_x;
+          f->y_pixels_diff = real_y;
+        }
+
+      if (tmp_data) XFree (tmp_data);
+      x_uncatch_errors ();
+      UNBLOCK_INPUT;
+      return;
+    }
+
+  if (tmp_data) XFree (tmp_data);
+
+  win = f->output_data.x->parent_desc;
   if (win == FRAME_X_DISPLAY_INFO (f)->root_window)
     win = FRAME_OUTER_WINDOW (f);
 

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2010-10-31 03:33:56 +0000
+++ b/src/xterm.c       2010-11-04 08:41:25 +0000
@@ -10522,7 +10522,8 @@
     = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False);
   dpyinfo->Xatom_net_window_type_tooltip
     = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE_TOOLTIP", False);
-  
+  dpyinfo->Xatom_net_frame_extents  
+    = XInternAtom (dpyinfo->display, "_NET_FRAME_EXTENTS", False);
   dpyinfo->cut_buffers_initialized = 0;
 
   dpyinfo->x_dnd_atoms_size = 8;

=== modified file 'src/xterm.h'
--- a/src/xterm.h       2010-07-14 10:05:53 +0000
+++ b/src/xterm.h       2010-11-04 08:41:25 +0000
@@ -362,10 +362,10 @@
   Window net_supported_window;
   Atom Xatom_net_window_type, Xatom_net_window_type_tooltip;
 
-  /* Atoms dealing with maximization and fullscreen */
+  /* Atoms dealing with EWMH (i.e. _NET_...) */
   Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen_atom,
     Xatom_net_wm_state_maximized_horz, Xatom_net_wm_state_maximized_vert,
-    Xatom_net_wm_state_sticky;
+    Xatom_net_wm_state_sticky, Xatom_net_frame_extents;
 
   /* XSettings atoms and windows.  */
   Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]