emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/src xterm.c


From: Jan Djärv
Subject: [Emacs-diffs] emacs/src xterm.c
Date: Fri, 27 Mar 2009 18:37:57 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Jan Djärv <jhd> 09/03/27 18:37:57

Modified files:
        src            : xterm.c 

Log message:
        (handle_one_xevent): Call x_handle_net_wm_state if
        the property _NET_WM_STATE has changed.
        updated.
        (x_handle_net_wm_state): New function to update frame parameter
        fullscreen.
        (x_term_init): Initialize atoms for _NET_WM_STATE.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/xterm.c?cvsroot=emacs&r1=1.1022&r2=1.1023

Patches:
Index: xterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.c,v
retrieving revision 1.1022
retrieving revision 1.1023
diff -u -b -r1.1022 -r1.1023
--- xterm.c     30 Jan 2009 13:06:10 -0000      1.1022
+++ xterm.c     27 Mar 2009 18:37:56 -0000      1.1023
@@ -363,6 +363,7 @@
                                            enum scroll_bar_part *,
                                            Lisp_Object *, Lisp_Object *,
                                            unsigned long *));
+static void x_handle_net_wm_state P_ ((struct frame *, XPropertyEvent *));
 static void x_check_fullscreen P_ ((struct frame *));
 static void x_check_expected_move P_ ((struct frame *, int, int));
 static void x_sync_with_move P_ ((struct frame *, int, int, int));
@@ -6096,6 +6097,10 @@
         goto OTHER;
 #endif
 #endif
+      f = x_top_window_to_frame (dpyinfo, event.xproperty.window);
+      if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state)
+        x_handle_net_wm_state (f, &event.xproperty);
+
       x_handle_property_notify (&event.xproperty);
       goto OTHER;
 
@@ -8656,6 +8661,69 @@
 }
 
 
+extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth;
+static void
+x_handle_net_wm_state (f, event)
+     struct frame *f;
+     XPropertyEvent *event;
+{
+  Atom actual_type;
+  unsigned long actual_size, bytes_remaining;
+  int i, rc, actual_format, value = 0;
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  long max_len = 65536;
+  Display *dpy = FRAME_X_DISPLAY (f);
+  unsigned char *tmp_data = NULL;
+  Atom target_type = XA_ATOM;
+
+  BLOCK_INPUT;
+  x_catch_errors (dpy);
+  rc = XGetWindowProperty (dpy, event->window,
+                           event->atom, 0, max_len, False, target_type,
+                           &actual_type, &actual_format, &actual_size,
+                           &bytes_remaining, &tmp_data);
+
+  if (rc != Success || actual_type != target_type || x_had_errors_p (dpy))
+    {
+      if (tmp_data) XFree (tmp_data);
+      x_uncatch_errors ();
+      UNBLOCK_INPUT;
+      return;
+    }
+
+  x_uncatch_errors ();
+
+  for (i = 0; i < actual_size; ++i)
+    {
+      Atom a = ((Atom*)tmp_data)[i];
+      if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
+        value |= FULLSCREEN_WIDTH;
+      else if (a == dpyinfo->Xatom_net_wm_state_maximized_vert)
+        value |= FULLSCREEN_HEIGHT;
+      else if (a == dpyinfo->Xatom_net_wm_state_fullscreen_atom)
+        value |= FULLSCREEN_BOTH;
+    }
+
+  Lisp_Object lval = Qnil;
+  switch (value) 
+    {
+    case FULLSCREEN_WIDTH:
+      lval = Qfullwidth;
+      break;
+    case FULLSCREEN_HEIGHT:
+      lval = Qfullheight;
+      break;
+    case FULLSCREEN_BOTH:
+      lval = Qfullboth;
+      break;
+    }
+      
+  store_frame_param (f, Qfullscreen, lval);
+  
+  if (tmp_data) XFree (tmp_data);
+  UNBLOCK_INPUT;
+}
+
 /* Check if we need to resize the frame due to a fullscreen request.
    If so needed, resize the frame. */
 static void
@@ -10350,6 +10418,15 @@
   dpyinfo->Xatom_XEMBED = XInternAtom (dpyinfo->display, "_XEMBED",
                                       False);
 
+  dpyinfo->Xatom_net_wm_state
+    = XInternAtom (dpyinfo->display, "_NET_WM_STATE", False);
+  dpyinfo->Xatom_net_wm_state_fullscreen_atom
+    = XInternAtom (dpyinfo->display, "_NET_WM_STATE_FULLSCREEN", False);
+  dpyinfo->Xatom_net_wm_state_maximized_horz
+    = XInternAtom (dpyinfo->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+  dpyinfo->Xatom_net_wm_state_maximized_vert
+    = XInternAtom (dpyinfo->display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
+
   dpyinfo->cut_buffers_initialized = 0;
 
   dpyinfo->x_dnd_atoms_size = 8;




reply via email to

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