+ x_sync_with_move (f, f->left_pos, f->top_pos,
+ FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN
+ ? 1 : 0);
+
+ /* change_gravity is non-zero when this function is called from Lisp to
+ programmatically move a frame. In that case, we call
+ x_check_expected_move to discover if we have a "Type A" or "Type B"
+ window manager, and, for a "Type A" window manager, adjust the position
+ of the frame.
+
+ We call x_check_expected_move if a programmatic move occurred, and
+ either the window manager type (A/B) is unknown or it is Type A but we
+ need to compute the top/left offset adjustment for this frame. */
+
+ if (change_gravity != 0 &&
+ (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN
+ || (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_A
+ && (FRAME_X_OUTPUT (f)->move_offset_left == 0
+ && FRAME_X_OUTPUT (f)->move_offset_top == 0))))
+ x_check_expected_move (f, modified_left, modified_top);
+
+ UNBLOCK_INPUT;
+}
+
+/* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED
+ on the root window for frame F contains ATOMNAME.
+ This is how a WM check shall be done according to the Window Manager
+ Specification/Extended Window Manager Hints at
+ http://freedesktop.org/wiki/Standards_2fwm_2dspec. */
+
+static int
+wm_supports (f, atomname)
+ struct frame *f;
+ const char *atomname;
+{
+ Atom actual_type;
+ unsigned long actual_size, bytes_remaining;
+ int i, rc, actual_format;
+ Atom prop_atom;
+ Window wmcheck_window;
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+ Window target_window = dpyinfo->root_window;
+ long max_len = 65536;
+ Display *dpy = FRAME_X_DISPLAY (f);
+ unsigned char *tmp_data = NULL;
+ Atom target_type = XA_WINDOW;
+ Atom want_atom;
+
+ BLOCK_INPUT;
+
+ prop_atom = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", False);
+
+ x_catch_errors (dpy);
+ rc = XGetWindowProperty (dpy, target_window,
+ prop_atom, 0, max_len, False, target_type,
+ &actual_type, &actual_format, &actual_size,
+ &bytes_remaining, &tmp_data);
+
+ if (rc != Success || actual_type != XA_WINDOW || x_had_errors_p (dpy))
+ {
+ if (tmp_data) XFree (tmp_data);
+ x_uncatch_errors ();
+ UNBLOCK_INPUT;
+ return 0;
+ }
+
+ wmcheck_window = *(Window *) tmp_data;
+ XFree (tmp_data);
+
+ /* Check if window exists. */
+ XSelectInput (dpy, wmcheck_window, StructureNotifyMask);
+ x_sync (f);
+ if (x_had_errors_p (dpy))
+ {
+ x_uncatch_errors ();
+ UNBLOCK_INPUT;
+ return 0;
+ }
+
+ if (dpyinfo->net_supported_window != wmcheck_window)