aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-03-19 09:11:09 +0800
committerPo Lu2022-03-19 09:29:08 +0800
commit1467b04f5cf586c0f44b7df00591986fa8d40c66 (patch)
treeec88708c7d6413162416fbc0941e9f09f75fe380 /src
parentae9a0b78080d8c448e3949b257c55c5288d05529 (diff)
downloademacs-1467b04f5cf586c0f44b7df00591986fa8d40c66.tar.gz
emacs-1467b04f5cf586c0f44b7df00591986fa8d40c66.zip
Handle composite overlay window during drag and drop sessions
* configure.ac: Test for the composite extension and use it if available. * msdos/sed1v2.inp: Update. * src/Makefile.in (XCOMPOSITE_LIBS, XCOMPOSITE_CFLAGS): New variables. (EMACS_CFLAGS, LIBES): Add new libs and cflags. * src/xterm.c (x_dnd_get_target_window): Look for proxy on composite overlay window if mapped. (x_term_init): Test if the composite extension is available. * src/xterm.h (struct x_display_info): New fields for composite extension presence.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in7
-rw-r--r--src/xterm.c83
-rw-r--r--src/xterm.h9
3 files changed, 93 insertions, 6 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 2b7c4bb316c..0ec2d342646 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -271,6 +271,9 @@ XSYNC_CFLAGS = @XSYNC_CFLAGS@
271XDBE_LIBS = @XDBE_LIBS@ 271XDBE_LIBS = @XDBE_LIBS@
272XDBE_CFLAGS = @XDBE_CFLAGS@ 272XDBE_CFLAGS = @XDBE_CFLAGS@
273 273
274XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@
275XCOMPOSITE_CFLAGS = @XCOMPOSITE_CFLAGS@
276
274## widget.o if USE_X_TOOLKIT, otherwise empty. 277## widget.o if USE_X_TOOLKIT, otherwise empty.
275WIDGET_OBJ=@WIDGET_OBJ@ 278WIDGET_OBJ=@WIDGET_OBJ@
276 279
@@ -402,7 +405,7 @@ EMACS_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \
402 $(HARFBUZZ_CFLAGS) $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \ 405 $(HARFBUZZ_CFLAGS) $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \
403 $(LIBSYSTEMD_CFLAGS) $(JSON_CFLAGS) $(XSYNC_CFLAGS) \ 406 $(LIBSYSTEMD_CFLAGS) $(JSON_CFLAGS) $(XSYNC_CFLAGS) \
404 $(LIBGNUTLS_CFLAGS) $(NOTIFY_CFLAGS) $(CAIRO_CFLAGS) \ 407 $(LIBGNUTLS_CFLAGS) $(NOTIFY_CFLAGS) $(CAIRO_CFLAGS) \
405 $(WERROR_CFLAGS) $(HAIKU_CFLAGS) 408 $(WERROR_CFLAGS) $(HAIKU_CFLAGS) $(XCOMPOSITE_CFLAGS)
406ALL_CFLAGS = $(EMACS_CFLAGS) $(WARN_CFLAGS) $(CFLAGS) 409ALL_CFLAGS = $(EMACS_CFLAGS) $(WARN_CFLAGS) $(CFLAGS)
407ALL_OBJC_CFLAGS = $(EMACS_CFLAGS) \ 410ALL_OBJC_CFLAGS = $(EMACS_CFLAGS) \
408 $(filter-out $(NON_OBJC_CFLAGS),$(WARN_CFLAGS)) $(CFLAGS) \ 411 $(filter-out $(NON_OBJC_CFLAGS),$(WARN_CFLAGS)) $(CFLAGS) \
@@ -559,7 +562,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(PGTK_LIBS) $(LIBX_BASE) $(LIBIMAGE
559 $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(GETADDRINFO_A_LIBS) $(LCMS2_LIBS) \ 562 $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(GETADDRINFO_A_LIBS) $(LCMS2_LIBS) \
560 $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES) $(LIBSYSTEMD_LIBS) \ 563 $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES) $(LIBSYSTEMD_LIBS) \
561 $(JSON_LIBS) $(LIBGMP) $(LIBGCCJIT_LIBS) $(XINPUT_LIBS) $(HAIKU_LIBS) \ 564 $(JSON_LIBS) $(LIBGMP) $(LIBGCCJIT_LIBS) $(XINPUT_LIBS) $(HAIKU_LIBS) \
562 $(SQLITE3_LIBS) 565 $(SQLITE3_LIBS) $(XCOMPOSITE_LIBS)
563 566
564## FORCE it so that admin/unidata can decide whether this file is 567## FORCE it so that admin/unidata can decide whether this file is
565## up-to-date. Although since charprop depends on bootstrap-emacs, 568## up-to-date. Although since charprop depends on bootstrap-emacs,
diff --git a/src/xterm.c b/src/xterm.c
index f7047ff0e88..5c5f24e297d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -542,6 +542,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
542#include <X11/extensions/Xinerama.h> 542#include <X11/extensions/Xinerama.h>
543#endif 543#endif
544 544
545#ifdef HAVE_XCOMPOSITE
546#include <X11/extensions/Xcomposite.h>
547#endif
548
545/* Load sys/types.h if not already loaded. 549/* Load sys/types.h if not already loaded.
546 In some systems loading it twice is suicidal. */ 550 In some systems loading it twice is suicidal. */
547#ifndef makedev 551#ifndef makedev
@@ -817,6 +821,10 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
817{ 821{
818 Window child_return, child, dummy, proxy; 822 Window child_return, child, dummy, proxy;
819 int dest_x_return, dest_y_return, rc, proto; 823 int dest_x_return, dest_y_return, rc, proto;
824#if defined HAVE_XCOMPOSITE && (XCOMPOSITE_MAJOR > 0 || XCOMPOSITE_MINOR > 2)
825 Window overlay_window;
826 XWindowAttributes attrs;
827#endif
820 child_return = dpyinfo->root_window; 828 child_return = dpyinfo->root_window;
821 dest_x_return = root_x; 829 dest_x_return = root_x;
822 dest_y_return = root_y; 830 dest_y_return = root_y;
@@ -853,7 +861,7 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
853 { 861 {
854 *proto_out = proto; 862 *proto_out = proto;
855 863
856 x_uncatch_errors_after_check (); 864 x_uncatch_errors ();
857 return proxy; 865 return proxy;
858 } 866 }
859 } 867 }
@@ -865,7 +873,7 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
865 if (proto != -1) 873 if (proto != -1)
866 { 874 {
867 *proto_out = proto; 875 *proto_out = proto;
868 x_uncatch_errors_after_check (); 876 x_uncatch_errors ();
869 877
870 return child_return; 878 return child_return;
871 } 879 }
@@ -887,8 +895,49 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
887 x_uncatch_errors_after_check (); 895 x_uncatch_errors_after_check ();
888 } 896 }
889 897
898#if defined HAVE_XCOMPOSITE && (XCOMPOSITE_MAJOR > 0 || XCOMPOSITE_MINOR > 2)
899 if (child != dpyinfo->root_window)
900 {
901#endif
902 *proto_out = x_dnd_get_window_proto (dpyinfo, child);
903 return child;
904#if defined HAVE_XCOMPOSITE && (XCOMPOSITE_MAJOR > 0 || XCOMPOSITE_MINOR > 2)
905 }
906 else if (dpyinfo->composite_supported_p
907 && (dpyinfo->composite_major > 0
908 || dpyinfo->composite_minor > 2))
909 {
910 /* Only do this if a compositing manager is present. */
911 if (XGetSelectionOwner (dpyinfo->display,
912 dpyinfo->Xatom_NET_WM_CM_Sn) != None)
913 {
914 overlay_window = XCompositeGetOverlayWindow (dpyinfo->display,
915 dpyinfo->root_window);
916 XCompositeReleaseOverlayWindow (dpyinfo->display,
917 dpyinfo->root_window);
918 XGetWindowAttributes (dpyinfo->display, overlay_window, &attrs);
919
920 if (attrs.map_state == IsViewable)
921 {
922 proxy = x_dnd_get_window_proxy (dpyinfo, overlay_window);
923
924 if (proxy != None)
925 {
926 proto = x_dnd_get_window_proto (dpyinfo, proxy);
927
928 if (proto != -1)
929 {
930 *proto_out = proto;
931 return proxy;
932 }
933 }
934 }
935 }
936 }
937
890 *proto_out = x_dnd_get_window_proto (dpyinfo, child); 938 *proto_out = x_dnd_get_window_proto (dpyinfo, child);
891 return child; 939 return child;
940#endif
892} 941}
893 942
894static Window 943static Window
@@ -17936,6 +17985,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
17936#ifdef USE_XCB 17985#ifdef USE_XCB
17937 xcb_connection_t *xcb_conn; 17986 xcb_connection_t *xcb_conn;
17938#endif 17987#endif
17988 char *cm_atom_sprintf;
17939 17989
17940 block_input (); 17990 block_input ();
17941 17991
@@ -18217,6 +18267,20 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
18217 &dpyinfo->xrender_minor); 18267 &dpyinfo->xrender_minor);
18218#endif 18268#endif
18219 18269
18270 /* This must come after XRenderQueryVersion! */
18271#ifdef HAVE_XCOMPOSITE
18272 int composite_event_base, composite_error_base;
18273 dpyinfo->composite_supported_p = XCompositeQueryExtension (dpyinfo->display,
18274 &composite_event_base,
18275 &composite_error_base);
18276
18277 if (dpyinfo->composite_supported_p)
18278 dpyinfo->composite_supported_p
18279 = XCompositeQueryVersion (dpyinfo->display,
18280 &dpyinfo->composite_major,
18281 &dpyinfo->composite_minor);
18282#endif
18283
18220 /* Put the rdb where we can find it in a way that works on 18284 /* Put the rdb where we can find it in a way that works on
18221 all versions. */ 18285 all versions. */
18222 dpyinfo->rdb = xrdb; 18286 dpyinfo->rdb = xrdb;
@@ -18576,6 +18640,15 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
18576 } 18640 }
18577 18641
18578 { 18642 {
18643 int n = snprintf (NULL, 0, "_NET_WM_CM_S%d",
18644 XScreenNumberOfScreen (dpyinfo->screen));
18645 cm_atom_sprintf = alloca (n + 1);
18646
18647 snprintf (cm_atom_sprintf, n + 1, "_NET_WM_CM_S%d",
18648 XScreenNumberOfScreen (dpyinfo->screen));
18649 }
18650
18651 {
18579 static const struct 18652 static const struct
18580 { 18653 {
18581 const char *name; 18654 const char *name;
@@ -18688,7 +18761,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
18688 int i; 18761 int i;
18689 enum { atom_count = ARRAYELTS (atom_refs) }; 18762 enum { atom_count = ARRAYELTS (atom_refs) };
18690 /* 1 for _XSETTINGS_SN. */ 18763 /* 1 for _XSETTINGS_SN. */
18691 enum { total_atom_count = 1 + atom_count }; 18764 enum { total_atom_count = 2 + atom_count };
18692 Atom atoms_return[total_atom_count]; 18765 Atom atoms_return[total_atom_count];
18693 char *atom_names[total_atom_count]; 18766 char *atom_names[total_atom_count];
18694 static char const xsettings_fmt[] = "_XSETTINGS_S%d"; 18767 static char const xsettings_fmt[] = "_XSETTINGS_S%d";
@@ -18702,6 +18775,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
18702 sprintf (xsettings_atom_name, xsettings_fmt, 18775 sprintf (xsettings_atom_name, xsettings_fmt,
18703 XScreenNumberOfScreen (dpyinfo->screen)); 18776 XScreenNumberOfScreen (dpyinfo->screen));
18704 atom_names[i] = xsettings_atom_name; 18777 atom_names[i] = xsettings_atom_name;
18778 atom_names[i + 1] = cm_atom_sprintf;
18705 18779
18706 XInternAtoms (dpyinfo->display, atom_names, total_atom_count, 18780 XInternAtoms (dpyinfo->display, atom_names, total_atom_count,
18707 False, atoms_return); 18781 False, atoms_return);
@@ -18709,8 +18783,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
18709 for (i = 0; i < atom_count; i++) 18783 for (i = 0; i < atom_count; i++)
18710 *(Atom *) ((char *) dpyinfo + atom_refs[i].offset) = atoms_return[i]; 18784 *(Atom *) ((char *) dpyinfo + atom_refs[i].offset) = atoms_return[i];
18711 18785
18712 /* Manually copy last atom. */ 18786 /* Manually copy last two atoms. */
18713 dpyinfo->Xatom_xsettings_sel = atoms_return[i]; 18787 dpyinfo->Xatom_xsettings_sel = atoms_return[i];
18788 dpyinfo->Xatom_NET_WM_CM_Sn = atoms_return[i + 1];
18714 } 18789 }
18715 18790
18716#ifdef HAVE_XKB 18791#ifdef HAVE_XKB
diff --git a/src/xterm.h b/src/xterm.h
index 9665e92a9fb..05d5e08dc01 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -429,6 +429,9 @@ struct x_display_info
429 /* Atom used in XEmbed client messages. */ 429 /* Atom used in XEmbed client messages. */
430 Atom Xatom_XEMBED, Xatom_XEMBED_INFO; 430 Atom Xatom_XEMBED, Xatom_XEMBED_INFO;
431 431
432 /* Atom used to determine whether or not the screen is composited. */
433 Atom Xatom_NET_WM_CM_Sn;
434
432 /* The frame (if any) which has the X window that has keyboard focus. 435 /* The frame (if any) which has the X window that has keyboard focus.
433 Zero if none. This is examined by Ffocus_frame in xfns.c. Note 436 Zero if none. This is examined by Ffocus_frame in xfns.c. Note
434 that a mere EnterNotify event can set this; if you need to know the 437 that a mere EnterNotify event can set this; if you need to know the
@@ -635,6 +638,12 @@ struct x_display_info
635#ifdef HAVE_XINERAMA 638#ifdef HAVE_XINERAMA
636 bool xinerama_supported_p; 639 bool xinerama_supported_p;
637#endif 640#endif
641
642#ifdef HAVE_XCOMPOSITE
643 bool composite_supported_p;
644 int composite_major;
645 int composite_minor;
646#endif
638}; 647};
639 648
640#ifdef HAVE_X_I18N 649#ifdef HAVE_X_I18N