aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog80
-rw-r--r--src/callproc.c6
-rw-r--r--src/dired.c12
-rw-r--r--src/editfns.c18
-rw-r--r--src/emacs.c3
-rw-r--r--src/image.c8
-rw-r--r--src/keyboard.c2
-rw-r--r--src/macgui.h2
-rw-r--r--src/macmenu.c121
-rw-r--r--src/macterm.c117
-rw-r--r--src/macterm.h10
-rw-r--r--src/xterm.c173
-rw-r--r--src/xterm.h5
13 files changed, 430 insertions, 127 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 97c9d4cbeb9..1974d45dd2c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,71 @@
12007-01-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * editfns.c (Fformat): Allow integer-format to work with floats of size
4 larger than most-positive-fixnum (but still smaller than MAXINT).
5
6 * dired.c (Ffile_attributes): Use floats for large uids/gids.
7
82007-01-09 Eli Zaretskii <eliz@gnu.org>
9
10 * emacs.c (syms_of_emacs) <path-separator>: Doc fix.
11
122007-01-09 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
13
14 * callproc.c (Fcall_process_region) [HAVE_MKSTEMP]: Add BLOCK_INPUT
15 around mkstemp.
16
17 * image.c (XDrawLine) [MAC_OS]: Remove macro.
18 (XCreateGC_pixmap) [!HAVE_NTGUI]: Likewise.
19 (x_disable_image) [!HAVE_NTGUI]: Use XCreateGC instead of
20 XCreateGC_pixmap.
21
22 * macgui.h (Display): Typedef to opaque type.
23
24 * macmenu.c (mac_dialog_modal_filter) [MAC_OSX]: New function.
25 (Fx_popup_dialog) [MAC_OSX]: Use standard alert if called from
26 Fmessage_box, Fyes_or_no_p, or Fy_or_n_p.
27 [MAC_OS_X_VERSION_MAX_ALLOWED >= 1030] (menu_quit_handler):
28 Use mac_quit_char_key_p.
29
30 * macterm.c (XDrawLine): Rename from mac_draw_line_to_pixmap.
31 (XCreateGC): Change type of 2nd argument to void *.
32 (XFreeGC) [USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]:
33 Fix last change.
34 (mac_to_emacs_modifiers): Change return type to int.
35 [USE_CARBON_EVENTS] (mac_event_to_emacs_modifiers): Likewise.
36 (mac_mapped_modifiers): New function.
37 (XTread_socket): Use it.
38 [USE_TSM] (mac_handle_text_input_event): Likewise.
39 (do_window_update) [USE_CG_DRAWING]: Call mac_prepare_for_quickdraw.
40 (mac_quit_char_modifiers, mac_quit_char_keycode) [MAC_OSX]:
41 Remove variables.
42 (mac_determine_quit_char_modifiers, init_quit_char_handler)
43 [MAC_OSX]: Remove functions.
44 (make_ctrl_char) [MAC_OSX]: Add extern.
45 (mac_quit_char_key_p) [MAC_OSX]: New function.
46 (mac_initialize) [MAC_OSX]: Don't call init_quit_char_handler.
47
48 * macterm.h (FONT_MAX_WIDTH): Remove unused macro.
49 (XCreateGC): Change type in extern.
50 (XDrawLine): Rename from mac_draw_line_to_pixmap.
51 (mac_quit_char_key_p) [MAC_OSX]: Add extern.
52
532007-01-08 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
54
55 * keyboard.c (init_keyboard): Initialize interrupt_input_blocked and
56 interrupt_input_pending.
57
58 * xterm.h (x_display_info): New: net_supported_atoms,
59 nr_net_supported_atoms and net_supported_window.
60
61 * xterm.c: New variable last_user_time.
62 (handle_one_xevent): Set last_user_time from events that have Time.
63 Set net_supported_window to 0 when reparented.
64 (wm_supports): New function.
65 (do_ewmh_fullscreen): Use wm_supports to check for _NET_WM_STATE.
66 (x_term_init): Initialize net_supported_atoms, nr_net_supported_atoms
67 and net_supported_window.
68
12007-01-05 Kim F. Storm <storm@cua.dk> 692007-01-05 Kim F. Storm <storm@cua.dk>
2 70
3 * indent.c (Fvertical_motion): Fix it overshoot check for overlay 71 * indent.c (Fvertical_motion): Fix it overshoot check for overlay
@@ -148,8 +216,8 @@
148 216
1492006-12-22 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 2172006-12-22 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
150 218
151 * macfns.c (mac_update_title_bar) [TARGET_API_MAC_CARBON]: Call 219 * macfns.c (mac_update_title_bar) [TARGET_API_MAC_CARBON]:
152 mac_update_proxy_icon also when buffer modification flag changed. 220 Call mac_update_proxy_icon also when buffer modification flag changed.
153 [TARGET_API_MAC_CARBON] (mac_update_proxy_icon): Don't update alias, 221 [TARGET_API_MAC_CARBON] (mac_update_proxy_icon): Don't update alias,
154 but compare FSRef/FSSpec of resolved alias. 222 but compare FSRef/FSSpec of resolved alias.
155 223
@@ -242,8 +310,8 @@
242 (Fmac_atsu_font_face_attributes) [USE_ATSUI]: New function. 310 (Fmac_atsu_font_face_attributes) [USE_ATSUI]: New function.
243 (syms_of_macfns) [USE_ATSUI]: Defsubr it. 311 (syms_of_macfns) [USE_ATSUI]: Defsubr it.
244 312
245 * macselect.c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Use 313 * macselect.c [TARGET_API_MAC_CARBON] (mac_do_receive_drag):
246 mac_wakeup_from_rne instead of mac_post_mouse_moved_event. 314 Use mac_wakeup_from_rne instead of mac_post_mouse_moved_event.
247 315
248 * macterm.c (mac_query_char_extents) [USE_ATSUI]: Don't call 316 * macterm.c (mac_query_char_extents) [USE_ATSUI]: Don't call
249 ATSUGetGlyphBounds if not necessary. 317 ATSUGetGlyphBounds if not necessary.
@@ -256,8 +324,8 @@
256 (mac_load_query_font) [USE_ATSUI]: Use atsu_find_font_from_family_name. 324 (mac_load_query_font) [USE_ATSUI]: Use atsu_find_font_from_family_name.
257 Don't get metrics for Latin-1 right half characters. 325 Don't get metrics for Latin-1 right half characters.
258 (mac_load_query_font): Don't load font if space width is not positive. 326 (mac_load_query_font): Don't load font if space width is not positive.
259 [TARGET_API_MAC_CARBON] (mac_store_event_ref_as_apple_event): Use 327 [TARGET_API_MAC_CARBON] (mac_store_event_ref_as_apple_event):
260 mac_wakeup_from_rne instead of mac_post_mouse_moved_event. 328 Use mac_wakeup_from_rne instead of mac_post_mouse_moved_event.
261 (XTread_socket): Call SelectWindow when unfocused frame is clicked. 329 (XTread_socket): Call SelectWindow when unfocused frame is clicked.
262 330
263 * macterm.h (mac_wakeup_from_rne) [TARGET_API_MAC_CARBON]: Add extern. 331 * macterm.h (mac_wakeup_from_rne) [TARGET_API_MAC_CARBON]: Add extern.
diff --git a/src/callproc.c b/src/callproc.c
index bc9c8d67d11..eb7f8ff6252 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1107,7 +1107,11 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
1107 1107
1108#ifdef HAVE_MKSTEMP 1108#ifdef HAVE_MKSTEMP
1109 { 1109 {
1110 int fd = mkstemp (tempfile); 1110 int fd;
1111
1112 BLOCK_INPUT;
1113 fd = mkstemp (tempfile);
1114 UNBLOCK_INPUT;
1111 if (fd == -1) 1115 if (fd == -1)
1112 report_file_error ("Failed to open temporary file", 1116 report_file_error ("Failed to open temporary file",
1113 Fcons (Vtemp_file_name_pattern, Qnil)); 1117 Fcons (Vtemp_file_name_pattern, Qnil));
diff --git a/src/dired.c b/src/dired.c
index ffaeb5adee4..7b8f978b20c 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -1,6 +1,6 @@
1/* Lisp functions for making directory listings. 1/* Lisp functions for making directory listings.
2 Copyright (C) 1985, 1986, 1993, 1994, 1999, 2000, 2001, 2002, 2003, 2 Copyright (C) 1985, 1986, 1993, 1994, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006 Free Software Foundation, Inc. 3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -966,16 +966,18 @@ Elements of the attribute list are:
966 values[1] = make_number (s.st_nlink); 966 values[1] = make_number (s.st_nlink);
967 if (NILP (id_format) || EQ (id_format, Qinteger)) 967 if (NILP (id_format) || EQ (id_format, Qinteger))
968 { 968 {
969 values[2] = make_number (s.st_uid); 969 values[2] = make_fixnum_or_float (s.st_uid);
970 values[3] = make_number (s.st_gid); 970 values[3] = make_fixnum_or_float (s.st_gid);
971 } 971 }
972 else 972 else
973 { 973 {
974 BLOCK_INPUT; 974 BLOCK_INPUT;
975 pw = (struct passwd *) getpwuid (s.st_uid); 975 pw = (struct passwd *) getpwuid (s.st_uid);
976 values[2] = (pw ? build_string (pw->pw_name) : make_number (s.st_uid)); 976 values[2] = (pw ? build_string (pw->pw_name)
977 : make_fixnum_or_float (s.st_uid));
977 gr = (struct group *) getgrgid (s.st_gid); 978 gr = (struct group *) getgrgid (s.st_gid);
978 values[3] = (gr ? build_string (gr->gr_name) : make_number (s.st_gid)); 979 values[3] = (gr ? build_string (gr->gr_name)
980 : make_fixnum_or_float (s.st_gid));
979 UNBLOCK_INPUT; 981 UNBLOCK_INPUT;
980 } 982 }
981 values[4] = make_time (s.st_atime); 983 values[4] = make_time (s.st_atime);
diff --git a/src/editfns.c b/src/editfns.c
index 6089ee9a2e2..ab29a07b693 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1,7 +1,7 @@
1/* Lisp functions pertaining to editing. 1/* Lisp functions pertaining to editing.
2 Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996, 2 Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996,
3 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006 Free Software Foundation, Inc. 4 2005, 2006, 2007 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -3631,7 +3631,12 @@ usage: (format STRING &rest OBJECTS) */)
3631 if (*format != 'd' && *format != 'o' && *format != 'x' 3631 if (*format != 'd' && *format != 'o' && *format != 'x'
3632 && *format != 'i' && *format != 'X' && *format != 'c') 3632 && *format != 'i' && *format != 'X' && *format != 'c')
3633 error ("Invalid format operation %%%c", *format); 3633 error ("Invalid format operation %%%c", *format);
3634 args[n] = Ftruncate (args[n], Qnil); 3634 /* This fails unnecessarily if args[n] is bigger than
3635 most-positive-fixnum but smaller than MAXINT.
3636 These cases are important because we sometimes use floats
3637 to represent such integer values (typically such values
3638 come from UIDs or PIDs). */
3639 /* args[n] = Ftruncate (args[n], Qnil); */
3635 } 3640 }
3636 3641
3637 /* Note that we're using sprintf to print floats, 3642 /* Note that we're using sprintf to print floats,
@@ -3799,8 +3804,15 @@ usage: (format STRING &rest OBJECTS) */)
3799 else 3804 else
3800 sprintf (p, this_format, XUINT (args[n])); 3805 sprintf (p, this_format, XUINT (args[n]));
3801 } 3806 }
3802 else 3807 else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
3803 sprintf (p, this_format, XFLOAT_DATA (args[n])); 3808 sprintf (p, this_format, XFLOAT_DATA (args[n]));
3809 else if (format[-1] == 'd')
3810 /* Maybe we should use "%1.0f" instead so it also works
3811 for values larger than MAXINT. */
3812 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
3813 else
3814 /* Don't sign-extend for octal or hex printing. */
3815 sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n]));
3804 3816
3805 if (p > buf 3817 if (p > buf
3806 && multibyte 3818 && multibyte
diff --git a/src/emacs.c b/src/emacs.c
index 8ffab8f0d3d..d068ee767bf 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2483,7 +2483,8 @@ before you compile Emacs, to enable the code for this feature. */);
2483 emacs_priority = 0; 2483 emacs_priority = 0;
2484 2484
2485 DEFVAR_LISP ("path-separator", &Vpath_separator, 2485 DEFVAR_LISP ("path-separator", &Vpath_separator,
2486 doc: /* The directory separator in search paths, as a string. */); 2486 doc: /* String containing the character that separates directories in
2487search paths, such as PATH and other similar environment variables. */);
2487 { 2488 {
2488 char c = SEPCHAR; 2489 char c = SEPCHAR;
2489 Vpath_separator = make_string (&c, 1); 2490 Vpath_separator = make_string (&c, 1);
diff --git a/src/image.c b/src/image.c
index 8f13da337ff..b4ee3104543 100644
--- a/src/image.c
+++ b/src/image.c
@@ -122,8 +122,6 @@ typedef struct mac_bitmap_record Bitmap_Record;
122#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual 122#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
123#define x_defined_color mac_defined_color 123#define x_defined_color mac_defined_color
124#define DefaultDepthOfScreen(screen) (one_mac_display_info.n_planes) 124#define DefaultDepthOfScreen(screen) (one_mac_display_info.n_planes)
125#define XDrawLine(display, w, gc, x1, y1, x2, y2) \
126 mac_draw_line_to_pixmap(display, w, gc, x1, y1, x2, y2)
127 125
128#endif /* MAC_OS */ 126#endif /* MAC_OS */
129 127
@@ -5253,14 +5251,12 @@ x_disable_image (f, img)
5253 GC gc; 5251 GC gc;
5254 5252
5255#ifdef MAC_OS 5253#ifdef MAC_OS
5256#define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, NULL, 0, NULL)
5257#define MaskForeground(f) PIX_MASK_DRAW 5254#define MaskForeground(f) PIX_MASK_DRAW
5258#else 5255#else
5259#define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, pixmap, 0, NULL)
5260#define MaskForeground(f) WHITE_PIX_DEFAULT (f) 5256#define MaskForeground(f) WHITE_PIX_DEFAULT (f)
5261#endif 5257#endif
5262 5258
5263 gc = XCreateGC_pixmap (dpy, img->pixmap); 5259 gc = XCreateGC (dpy, img->pixmap, 0, NULL);
5264 XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f)); 5260 XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f));
5265 XDrawLine (dpy, img->pixmap, gc, 0, 0, 5261 XDrawLine (dpy, img->pixmap, gc, 0, 0,
5266 img->width - 1, img->height - 1); 5262 img->width - 1, img->height - 1);
@@ -5270,7 +5266,7 @@ x_disable_image (f, img)
5270 5266
5271 if (img->mask) 5267 if (img->mask)
5272 { 5268 {
5273 gc = XCreateGC_pixmap (dpy, img->mask); 5269 gc = XCreateGC (dpy, img->mask, 0, NULL);
5274 XSetForeground (dpy, gc, MaskForeground (f)); 5270 XSetForeground (dpy, gc, MaskForeground (f));
5275 XDrawLine (dpy, img->mask, gc, 0, 0, 5271 XDrawLine (dpy, img->mask, gc, 0, 0,
5276 img->width - 1, img->height - 1); 5272 img->width - 1, img->height - 1);
diff --git a/src/keyboard.c b/src/keyboard.c
index 656a642c666..c2603427004 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11410,6 +11410,8 @@ init_keyboard ()
11410 do_mouse_tracking = Qnil; 11410 do_mouse_tracking = Qnil;
11411#endif 11411#endif
11412 input_pending = 0; 11412 input_pending = 0;
11413 interrupt_input_blocked = 0;
11414 interrupt_input_pending = 0;
11413 11415
11414 /* This means that command_loop_1 won't try to select anything the first 11416 /* This means that command_loop_1 won't try to select anything the first
11415 time through. */ 11417 time through. */
diff --git a/src/macgui.h b/src/macgui.h
index 3a9913181de..7eed001a4db 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -24,7 +24,7 @@ Boston, MA 02110-1301, USA. */
24#ifndef EMACS_MACGUI_H 24#ifndef EMACS_MACGUI_H
25#define EMACS_MACGUI_H 25#define EMACS_MACGUI_H
26 26
27typedef int Display; /* fix later */ 27typedef struct _XDisplay Display; /* opaque */
28 28
29typedef Lisp_Object XrmDatabase; 29typedef Lisp_Object XrmDatabase;
30 30
diff --git a/src/macmenu.c b/src/macmenu.c
index 9981250979a..a70a80d32ed 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -876,6 +876,32 @@ no quit occurs and `x-popup-menu' returns nil. */)
876 876
877#ifdef HAVE_MENUS 877#ifdef HAVE_MENUS
878 878
879/* Regard ESC and C-g as Cancel even without the Cancel button. */
880
881#ifdef MAC_OSX
882static Boolean
883mac_dialog_modal_filter (dialog, event, item_hit)
884 DialogRef dialog;
885 EventRecord *event;
886 DialogItemIndex *item_hit;
887{
888 Boolean result;
889
890 result = StdFilterProc (dialog, event, item_hit);
891 if (result == false
892 && (event->what == keyDown || event->what == autoKey)
893 && ((event->message & charCodeMask) == kEscapeCharCode
894 || mac_quit_char_key_p (event->modifiers,
895 (event->message & keyCodeMask) >> 8)))
896 {
897 *item_hit = kStdCancelItemIndex;
898 return true;
899 }
900
901 return result;
902}
903#endif
904
879DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0, 905DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0,
880 doc: /* Pop up a dialog box and return user's selection. 906 doc: /* Pop up a dialog box and return user's selection.
881POSITION specifies which frame to use. 907POSITION specifies which frame to use.
@@ -961,6 +987,96 @@ for instance using the window manager, then this produces a quit and
961 but I don't want to make one now. */ 987 but I don't want to make one now. */
962 CHECK_WINDOW (window); 988 CHECK_WINDOW (window);
963 989
990#ifdef MAC_OSX
991 /* Special treatment for Fmessage_box, Fyes_or_no_p, and Fy_or_n_p. */
992 if (EQ (position, Qt)
993 && STRINGP (Fcar (contents))
994 && ((!NILP (Fequal (XCDR (contents),
995 Fcons (Fcons (build_string ("OK"), Qt), Qnil)))
996 && EQ (header, Qt))
997 || (!NILP (Fequal (XCDR (contents),
998 Fcons (Fcons (build_string ("Yes"), Qt),
999 Fcons (Fcons (build_string ("No"), Qnil),
1000 Qnil))))
1001 && NILP (header))))
1002 {
1003 OSStatus err = noErr;
1004 AlertStdCFStringAlertParamRec param;
1005 CFStringRef error_string, explanation_string;
1006 DialogRef alert;
1007 DialogItemIndex item_hit;
1008 Lisp_Object tem;
1009
1010 tem = Fstring_match (concat3 (build_string ("\\("),
1011 call0 (intern ("sentence-end")),
1012 build_string ("\\)\n")),
1013 XCAR (contents), Qnil);
1014 BLOCK_INPUT;
1015 if (NILP (tem))
1016 {
1017 error_string = cfstring_create_with_string (XCAR (contents));
1018 if (error_string == NULL)
1019 err = memFullErr;
1020 explanation_string = NULL;
1021 }
1022 else
1023 {
1024 tem = Fmatch_end (make_number (1));
1025 error_string =
1026 cfstring_create_with_string (Fsubstring (XCAR (contents),
1027 make_number (0), tem));
1028 if (error_string == NULL)
1029 err = memFullErr;
1030 else
1031 {
1032 XSETINT (tem, XINT (tem) + 1);
1033 explanation_string =
1034 cfstring_create_with_string (Fsubstring (XCAR (contents),
1035 tem, Qnil));
1036 if (explanation_string == NULL)
1037 {
1038 CFRelease (error_string);
1039 err = memFullErr;
1040 }
1041 }
1042 }
1043 if (err == noErr)
1044 err = GetStandardAlertDefaultParams (&param,
1045 kStdCFStringAlertVersionOne);
1046 if (err == noErr)
1047 {
1048 param.movable = true;
1049 param.position = kWindowAlertPositionParentWindow;
1050 if (NILP (header))
1051 {
1052 param.defaultText = CFSTR ("Yes");
1053 param.otherText = CFSTR ("No");
1054#if 0
1055 param.cancelText = CFSTR ("Cancel");
1056 param.cancelButton = kAlertStdAlertCancelButton;
1057#endif
1058 }
1059 err = CreateStandardAlert (kAlertNoteAlert, error_string,
1060 explanation_string, &param, &alert);
1061 CFRelease (error_string);
1062 if (explanation_string)
1063 CFRelease (explanation_string);
1064 }
1065 if (err == noErr)
1066 err = RunStandardAlert (alert, mac_dialog_modal_filter, &item_hit);
1067 UNBLOCK_INPUT;
1068
1069 if (err == noErr)
1070 {
1071 if (item_hit == kStdCancelItemIndex)
1072 Fsignal (Qquit, Qnil);
1073 else if (item_hit == kStdOkItemIndex)
1074 return Qt;
1075 else
1076 return Qnil;
1077 }
1078 }
1079#endif
964#ifndef HAVE_DIALOGS 1080#ifndef HAVE_DIALOGS
965 /* Display a menu with these alternatives 1081 /* Display a menu with these alternatives
966 in the middle of frame F. */ 1082 in the middle of frame F. */
@@ -1537,8 +1653,6 @@ menu_quit_handler (nextHandler, theEvent, userData)
1537 OSStatus err; 1653 OSStatus err;
1538 UInt32 keyCode; 1654 UInt32 keyCode;
1539 UInt32 keyModifiers; 1655 UInt32 keyModifiers;
1540 extern int mac_quit_char_modifiers;
1541 extern int mac_quit_char_keycode;
1542 1656
1543 err = GetEventParameter (theEvent, kEventParamKeyCode, 1657 err = GetEventParameter (theEvent, kEventParamKeyCode,
1544 typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode); 1658 typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
@@ -1548,8 +1662,7 @@ menu_quit_handler (nextHandler, theEvent, userData)
1548 typeUInt32, NULL, sizeof(UInt32), 1662 typeUInt32, NULL, sizeof(UInt32),
1549 NULL, &keyModifiers); 1663 NULL, &keyModifiers);
1550 1664
1551 if (err == noErr && keyCode == mac_quit_char_keycode 1665 if (err == noErr && mac_quit_char_key_p (keyModifiers, keyCode))
1552 && keyModifiers == mac_quit_char_modifiers)
1553 { 1666 {
1554 MenuRef menu = userData != 0 1667 MenuRef menu = userData != 0
1555 ? (MenuRef)userData : AcquireRootMenu (); 1668 ? (MenuRef)userData : AcquireRootMenu ();
diff --git a/src/macterm.c b/src/macterm.c
index 7c3f036f1ba..1706da48cc3 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -505,8 +505,10 @@ mac_draw_line (f, gc, x1, y1, x2, y2)
505#endif 505#endif
506} 506}
507 507
508/* Mac version of XDrawLine (to Pixmap). */
509
508void 510void
509mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) 511XDrawLine (display, p, gc, x1, y1, x2, y2)
510 Display *display; 512 Display *display;
511 Pixmap p; 513 Pixmap p;
512 GC gc; 514 GC gc;
@@ -1628,9 +1630,9 @@ XChangeGC (display, gc, mask, xgcv)
1628/* Mac replacement for XCreateGC. */ 1630/* Mac replacement for XCreateGC. */
1629 1631
1630GC 1632GC
1631XCreateGC (display, window, mask, xgcv) 1633XCreateGC (display, d, mask, xgcv)
1632 Display *display; 1634 Display *display;
1633 Window window; 1635 void *d;
1634 unsigned long mask; 1636 unsigned long mask;
1635 XGCValues *xgcv; 1637 XGCValues *xgcv;
1636{ 1638{
@@ -1663,8 +1665,13 @@ XFreeGC (display, gc)
1663 if (gc->clip_region) 1665 if (gc->clip_region)
1664 DisposeRgn (gc->clip_region); 1666 DisposeRgn (gc->clip_region);
1665#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 1667#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
1666 CGColorRelease (gc->cg_fore_color); 1668#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
1667 CGColorRelease (gc->cg_back_color); 1669 if (CGColorGetTypeID != NULL)
1670#endif
1671 {
1672 CGColorRelease (gc->cg_fore_color);
1673 CGColorRelease (gc->cg_back_color);
1674 }
1668#endif 1675#endif
1669 xfree (gc); 1676 xfree (gc);
1670} 1677}
@@ -8967,7 +8974,7 @@ static const unsigned char fn_keycode_to_keycode_table[] = {
8967}; 8974};
8968#endif /* MAC_OSX */ 8975#endif /* MAC_OSX */
8969 8976
8970static unsigned int 8977static int
8971#if USE_CARBON_EVENTS 8978#if USE_CARBON_EVENTS
8972mac_to_emacs_modifiers (UInt32 mods) 8979mac_to_emacs_modifiers (UInt32 mods)
8973#else 8980#else
@@ -9014,6 +9021,23 @@ mac_to_emacs_modifiers (EventModifiers mods)
9014 return result; 9021 return result;
9015} 9022}
9016 9023
9024static UInt32
9025mac_mapped_modifiers (modifiers)
9026 UInt32 modifiers;
9027{
9028 UInt32 mapped_modifiers_all =
9029 (NILP (Vmac_control_modifier) ? 0 : controlKey)
9030 | (NILP (Vmac_option_modifier) ? 0 : optionKey)
9031 | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
9032
9033#ifdef MAC_OSX
9034 mapped_modifiers_all |=
9035 (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask);
9036#endif
9037
9038 return mapped_modifiers_all & modifiers;
9039}
9040
9017static int 9041static int
9018mac_get_emulated_btn ( UInt32 modifiers ) 9042mac_get_emulated_btn ( UInt32 modifiers )
9019{ 9043{
@@ -9031,7 +9055,7 @@ mac_get_emulated_btn ( UInt32 modifiers )
9031#if USE_CARBON_EVENTS 9055#if USE_CARBON_EVENTS
9032/* Obtains the event modifiers from the event ref and then calls 9056/* Obtains the event modifiers from the event ref and then calls
9033 mac_to_emacs_modifiers. */ 9057 mac_to_emacs_modifiers. */
9034static UInt32 9058static int
9035mac_event_to_emacs_modifiers (EventRef eventRef) 9059mac_event_to_emacs_modifiers (EventRef eventRef)
9036{ 9060{
9037 UInt32 mods = 0; 9061 UInt32 mods = 0;
@@ -9256,6 +9280,9 @@ do_window_update (WindowPtr win)
9256 GetPortVisibleRegion (GetWindowPort (win), region); 9280 GetPortVisibleRegion (GetWindowPort (win), region);
9257 GetRegionBounds (region, &r); 9281 GetRegionBounds (region, &r);
9258 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); 9282 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
9283#if USE_CG_DRAWING
9284 mac_prepare_for_quickdraw (f);
9285#endif
9259 UpdateControls (win, region); 9286 UpdateControls (win, region);
9260 DisposeRgn (region); 9287 DisposeRgn (region);
9261#else 9288#else
@@ -10067,21 +10094,10 @@ mac_handle_text_input_event (next_handler, event, data)
10067 err = GetEventParameter (kbd_event, kEventParamKeyModifiers, 10094 err = GetEventParameter (kbd_event, kEventParamKeyModifiers,
10068 typeUInt32, NULL, 10095 typeUInt32, NULL,
10069 sizeof (UInt32), NULL, &modifiers); 10096 sizeof (UInt32), NULL, &modifiers);
10070 if (err == noErr) 10097 if (err == noErr && mac_mapped_modifiers (modifiers))
10071 { 10098 /* There're mapped modifier keys. Process it in
10072 mapped_modifiers = 10099 XTread_socket. */
10073 (NILP (Vmac_control_modifier) ? 0 : controlKey) 10100 return eventNotHandledErr;
10074 | (NILP (Vmac_option_modifier) ? 0 : optionKey)
10075 | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
10076#ifdef MAC_OSX
10077 mapped_modifiers |=
10078 (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask);
10079#endif
10080 if (modifiers & mapped_modifiers)
10081 /* There're mapped modifier keys. Process it in
10082 XTread_socket. */
10083 return eventNotHandledErr;
10084 }
10085 if (err == noErr) 10101 if (err == noErr)
10086 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes, 10102 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
10087 typeUnicodeText, NULL, 0, &actual_size, 10103 typeUnicodeText, NULL, 0, &actual_size,
@@ -11032,20 +11048,12 @@ XTread_socket (sd, expected, hold_quit)
11032 SInt16 current_key_script; 11048 SInt16 current_key_script;
11033 UInt32 modifiers = er.modifiers, mapped_modifiers; 11049 UInt32 modifiers = er.modifiers, mapped_modifiers;
11034 11050
11035 mapped_modifiers =
11036 (NILP (Vmac_control_modifier) ? 0 : controlKey)
11037 | (NILP (Vmac_option_modifier) ? 0 : optionKey)
11038 | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
11039
11040#if USE_CARBON_EVENTS && defined (MAC_OSX) 11051#if USE_CARBON_EVENTS && defined (MAC_OSX)
11041 mapped_modifiers |=
11042 (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask);
11043
11044 GetEventParameter (eventRef, kEventParamKeyModifiers, 11052 GetEventParameter (eventRef, kEventParamKeyModifiers,
11045 typeUInt32, NULL, 11053 typeUInt32, NULL,
11046 sizeof (UInt32), NULL, &modifiers); 11054 sizeof (UInt32), NULL, &modifiers);
11047#endif 11055#endif
11048 mapped_modifiers &= modifiers; 11056 mapped_modifiers = mac_mapped_modifiers (modifiers);
11049 11057
11050#if USE_CARBON_EVENTS && (defined (MAC_OSX) || USE_MAC_TSM) 11058#if USE_CARBON_EVENTS && (defined (MAC_OSX) || USE_MAC_TSM)
11051 /* When using Carbon Events, we need to pass raw keyboard 11059 /* When using Carbon Events, we need to pass raw keyboard
@@ -11639,34 +11647,33 @@ MakeMeTheFrontProcess ()
11639} 11647}
11640 11648
11641/***** Code to handle C-g testing *****/ 11649/***** Code to handle C-g testing *****/
11642
11643/* Contains the Mac modifier formed from quit_char */
11644int mac_quit_char_modifiers = 0;
11645int mac_quit_char_keycode;
11646extern int quit_char; 11650extern int quit_char;
11651extern int make_ctrl_char P_ ((int));
11647 11652
11648static void 11653int
11649mac_determine_quit_char_modifiers() 11654mac_quit_char_key_p (modifiers, key_code)
11650{ 11655 UInt32 modifiers, key_code;
11651 /* Todo: Determine modifiers from quit_char. */ 11656{
11652 UInt32 qc_modifiers = ctrl_modifier; 11657 UInt32 char_code;
11658 unsigned long some_state = 0;
11659 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
11660 int c, emacs_modifiers;
11661
11662 /* Mask off modifier keys that are mapped to some Emacs modifiers. */
11663 key_code |= (modifiers & ~(mac_mapped_modifiers (modifiers)));
11664 char_code = KeyTranslate (kchr_ptr, key_code, &some_state);
11665 if (char_code & ~0xff)
11666 return 0;
11653 11667
11654 /* Map modifiers */ 11668 emacs_modifiers = mac_to_emacs_modifiers (modifiers);
11655 mac_quit_char_modifiers = 0; 11669 if (emacs_modifiers & ctrl_modifier)
11656 if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= controlKey; 11670 c = make_ctrl_char (char_code);
11657 if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= shiftKey;
11658 if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= optionKey;
11659}
11660 11671
11661static void 11672 c |= (emacs_modifiers
11662init_quit_char_handler () 11673 & (meta_modifier | alt_modifier
11663{ 11674 | hyper_modifier | super_modifier));
11664 /* TODO: Let this support keys other the 'g' */
11665 mac_quit_char_keycode = 5;
11666 /* Look at <architecture/adb_kb_map.h> for details */
11667 /* http://gemma.apple.com/techpubs/mac/Toolbox/Toolbox-40.html#MARKER-9-184*/
11668 11675
11669 mac_determine_quit_char_modifiers(); 11676 return c == quit_char;
11670} 11677}
11671#endif /* MAC_OSX */ 11678#endif /* MAC_OSX */
11672 11679
@@ -11804,8 +11811,6 @@ mac_initialize ()
11804#if USE_CARBON_EVENTS 11811#if USE_CARBON_EVENTS
11805#ifdef MAC_OSX 11812#ifdef MAC_OSX
11806 init_service_handler (); 11813 init_service_handler ();
11807
11808 init_quit_char_handler ();
11809#endif /* MAC_OSX */ 11814#endif /* MAC_OSX */
11810 11815
11811 init_command_handler (); 11816 init_command_handler ();
diff --git a/src/macterm.h b/src/macterm.h
index c941fafb690..c7d86f157f1 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -44,8 +44,6 @@ Boston, MA 02110-1301, USA. */
44#define FONT_BASE(f) ((f)->ascent) 44#define FONT_BASE(f) ((f)->ascent)
45#define FONT_DESCENT(f) ((f)->descent) 45#define FONT_DESCENT(f) ((f)->descent)
46 46
47#define FONT_MAX_WIDTH(f) FONT_WIDTH(f) /* fix later */
48
49/* Structure recording bitmaps and reference count. 47/* Structure recording bitmaps and reference count.
50 If REFCOUNT is 0 then this record is free to be reused. */ 48 If REFCOUNT is 0 then this record is free to be reused. */
51 49
@@ -614,13 +612,12 @@ extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *,
614 unsigned long, unsigned long, 612 unsigned long, unsigned long,
615 unsigned int)); 613 unsigned int));
616extern void XFreePixmap P_ ((Display *, Pixmap)); 614extern void XFreePixmap P_ ((Display *, Pixmap));
617extern GC XCreateGC P_ ((Display *, Window, unsigned long, XGCValues *)); 615extern GC XCreateGC P_ ((Display *, void *, unsigned long, XGCValues *));
618extern void XFreeGC P_ ((Display *, GC)); 616extern void XFreeGC P_ ((Display *, GC));
619extern void XSetForeground P_ ((Display *, GC, unsigned long)); 617extern void XSetForeground P_ ((Display *, GC, unsigned long));
620extern void XSetBackground P_ ((Display *, GC, unsigned long)); 618extern void XSetBackground P_ ((Display *, GC, unsigned long));
621extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long)); 619extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long));
622extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int, 620extern void XDrawLine P_ ((Display *, Pixmap, GC, int, int, int, int));
623 int, int));
624extern void mac_clear_area P_ ((struct frame *, int, int, 621extern void mac_clear_area P_ ((struct frame *, int, int,
625 unsigned int, unsigned int)); 622 unsigned int, unsigned int));
626extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); 623extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
@@ -636,6 +633,9 @@ extern void do_apple_menu P_ ((SInt16));
636#if USE_CG_DRAWING 633#if USE_CG_DRAWING
637extern void mac_prepare_for_quickdraw P_ ((struct frame *)); 634extern void mac_prepare_for_quickdraw P_ ((struct frame *));
638#endif 635#endif
636#ifdef MAC_OSX
637extern int mac_quit_char_key_p P_ ((UInt32, UInt32));
638#endif
639 639
640#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 640#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
641#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 641#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
diff --git a/src/xterm.c b/src/xterm.c
index e16fb852873..122d9b7c3de 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -276,6 +276,10 @@ static Lisp_Object last_mouse_scroll_bar;
276 276
277static Time last_mouse_movement_time; 277static Time last_mouse_movement_time;
278 278
279/* Time for last user interaction as returned in X events. */
280
281static Time last_user_time;
282
279/* Incremented by XTread_socket whenever it really tries to read 283/* Incremented by XTread_socket whenever it really tries to read
280 events. */ 284 events. */
281 285
@@ -5882,6 +5886,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5882 break; 5886 break;
5883 5887
5884 case SelectionNotify: 5888 case SelectionNotify:
5889 last_user_time = event.xselection.time;
5885#ifdef USE_X_TOOLKIT 5890#ifdef USE_X_TOOLKIT
5886 if (! x_window_to_frame (dpyinfo, event.xselection.requestor)) 5891 if (! x_window_to_frame (dpyinfo, event.xselection.requestor))
5887 goto OTHER; 5892 goto OTHER;
@@ -5890,6 +5895,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5890 break; 5895 break;
5891 5896
5892 case SelectionClear: /* Someone has grabbed ownership. */ 5897 case SelectionClear: /* Someone has grabbed ownership. */
5898 last_user_time = event.xselectionclear.time;
5893#ifdef USE_X_TOOLKIT 5899#ifdef USE_X_TOOLKIT
5894 if (! x_window_to_frame (dpyinfo, event.xselectionclear.window)) 5900 if (! x_window_to_frame (dpyinfo, event.xselectionclear.window))
5895 goto OTHER; 5901 goto OTHER;
@@ -5906,6 +5912,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5906 break; 5912 break;
5907 5913
5908 case SelectionRequest: /* Someone wants our selection. */ 5914 case SelectionRequest: /* Someone wants our selection. */
5915 last_user_time = event.xselectionrequest.time;
5909#ifdef USE_X_TOOLKIT 5916#ifdef USE_X_TOOLKIT
5910 if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner)) 5917 if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner))
5911 goto OTHER; 5918 goto OTHER;
@@ -5926,6 +5933,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5926 break; 5933 break;
5927 5934
5928 case PropertyNotify: 5935 case PropertyNotify:
5936 last_user_time = event.xproperty.time;
5929#if 0 /* This is plain wrong. In the case that we are waiting for a 5937#if 0 /* This is plain wrong. In the case that we are waiting for a
5930 PropertyNotify used as an ACK in incremental selection 5938 PropertyNotify used as an ACK in incremental selection
5931 transfer, the property will be on the receiver's window. */ 5939 transfer, the property will be on the receiver's window. */
@@ -5949,6 +5957,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5949 5957
5950 /* Perhaps reparented due to a WM restart. Reset this. */ 5958 /* Perhaps reparented due to a WM restart. Reset this. */
5951 FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN; 5959 FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN;
5960 FRAME_X_DISPLAY_INFO (f)->net_supported_window = 0;
5952 } 5961 }
5953 goto OTHER; 5962 goto OTHER;
5954 5963
@@ -6107,6 +6116,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6107 6116
6108 case KeyPress: 6117 case KeyPress:
6109 6118
6119 last_user_time = event.xkey.time;
6110 ignore_next_mouse_click_timeout = 0; 6120 ignore_next_mouse_click_timeout = 0;
6111 6121
6112#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 6122#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
@@ -6497,6 +6507,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6497#endif 6507#endif
6498 6508
6499 case KeyRelease: 6509 case KeyRelease:
6510 last_user_time = event.xkey.time;
6500#ifdef HAVE_X_I18N 6511#ifdef HAVE_X_I18N
6501 /* Don't dispatch this event since XtDispatchEvent calls 6512 /* Don't dispatch this event since XtDispatchEvent calls
6502 XFilterEvent, and two calls in a row may freeze the 6513 XFilterEvent, and two calls in a row may freeze the
@@ -6507,6 +6518,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6507#endif 6518#endif
6508 6519
6509 case EnterNotify: 6520 case EnterNotify:
6521 last_user_time = event.xcrossing.time;
6510 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6522 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6511 6523
6512 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window); 6524 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
@@ -6547,6 +6559,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6547 goto OTHER; 6559 goto OTHER;
6548 6560
6549 case LeaveNotify: 6561 case LeaveNotify:
6562 last_user_time = event.xcrossing.time;
6550 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6563 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6551 6564
6552 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); 6565 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
@@ -6580,6 +6593,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6580 6593
6581 case MotionNotify: 6594 case MotionNotify:
6582 { 6595 {
6596 last_user_time = event.xmotion.time;
6583 previous_help_echo_string = help_echo_string; 6597 previous_help_echo_string = help_echo_string;
6584 help_echo_string = Qnil; 6598 help_echo_string = Qnil;
6585 6599
@@ -6728,6 +6742,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6728 6742
6729 bzero (&compose_status, sizeof (compose_status)); 6743 bzero (&compose_status, sizeof (compose_status));
6730 last_mouse_glyph_frame = 0; 6744 last_mouse_glyph_frame = 0;
6745 last_user_time = event.xbutton.time;
6731 6746
6732 if (dpyinfo->grabbed 6747 if (dpyinfo->grabbed
6733 && last_mouse_frame 6748 && last_mouse_frame
@@ -8336,40 +8351,111 @@ x_set_offset (f, xoff, yoff, change_gravity)
8336 UNBLOCK_INPUT; 8351 UNBLOCK_INPUT;
8337} 8352}
8338 8353
8339/* Do fullscreen as specified in extended window manager hints */ 8354/* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED
8355 on the root window for frame F contains ATOMNAME.
8356 This is how a WM check shall be done according to the Window Manager
8357 Specification/Extended Window Manager Hints at
8358 http://freedesktop.org/wiki/Standards_2fwm_2dspec. */
8359
8340static int 8360static int
8341do_ewmh_fullscreen (f) 8361wm_supports (f, atomname)
8342 struct frame *f; 8362 struct frame *f;
8363 const char *atomname;
8343{ 8364{
8344 int have_net_atom = FRAME_X_DISPLAY_INFO (f)->have_net_atoms; 8365 Atom actual_type;
8366 unsigned long actual_size, bytes_remaining;
8367 int i, rc, actual_format;
8368 Atom prop_atom;
8369 Window wmcheck_window;
8370 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
8371 Window target_window = dpyinfo->root_window;
8372 long max_len = 65536;
8373 Display *dpy = FRAME_X_DISPLAY (f);
8374 unsigned char *tmp_data = NULL;
8375 Atom target_type = XA_WINDOW;
8376 Atom want_atom;
8377
8378 BLOCK_INPUT;
8379
8380 prop_atom = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", False);
8381
8382 x_catch_errors (dpy);
8383 rc = XGetWindowProperty (dpy, target_window,
8384 prop_atom, 0, max_len, False, target_type,
8385 &actual_type, &actual_format, &actual_size,
8386 &bytes_remaining, &tmp_data);
8387
8388 if (rc != Success || actual_type != XA_WINDOW || x_had_errors_p (dpy))
8389 {
8390 if (tmp_data) XFree (tmp_data);
8391 x_uncatch_errors ();
8392 UNBLOCK_INPUT;
8393 return 0;
8394 }
8395
8396 wmcheck_window = *(Window *) tmp_data;
8397 XFree (tmp_data);
8345 8398
8346 if (!have_net_atom) 8399 /* Check if window exists. */
8400 XSelectInput (dpy, wmcheck_window, StructureNotifyMask);
8401 x_sync (f);
8402 if (x_had_errors_p (dpy))
8347 { 8403 {
8348 int num; 8404 x_uncatch_errors ();
8349 Atom *atoms = XListProperties (FRAME_X_DISPLAY (f), 8405 UNBLOCK_INPUT;
8350 FRAME_X_DISPLAY_INFO (f)->root_window, 8406 return 0;
8351 &num); 8407 }
8352 if (atoms && num > 0) 8408
8409 if (dpyinfo->net_supported_window != wmcheck_window)
8410 {
8411 /* Window changed, reload atoms */
8412 if (dpyinfo->net_supported_atoms != NULL)
8413 XFree (dpyinfo->net_supported_atoms);
8414 dpyinfo->net_supported_atoms = NULL;
8415 dpyinfo->nr_net_supported_atoms = 0;
8416 dpyinfo->net_supported_window = 0;
8417
8418 target_type = XA_ATOM;
8419 prop_atom = XInternAtom (dpy, "_NET_SUPPORTED", False);
8420 tmp_data = NULL;
8421 rc = XGetWindowProperty (dpy, target_window,
8422 prop_atom, 0, max_len, False, target_type,
8423 &actual_type, &actual_format, &actual_size,
8424 &bytes_remaining, &tmp_data);
8425
8426 if (rc != Success || actual_type != XA_ATOM || x_had_errors_p (dpy))
8353 { 8427 {
8354 char **names = (char **) xmalloc (num * sizeof(*names)); 8428 if (tmp_data) XFree (tmp_data);
8355 if (XGetAtomNames (FRAME_X_DISPLAY (f), atoms, num, names)) 8429 x_uncatch_errors ();
8356 { 8430 UNBLOCK_INPUT;
8357 int i; 8431 return 0;
8358 for (i = 0; i < num; ++i)
8359 {
8360 if (!have_net_atom)
8361 have_net_atom = strncmp (names[i], "_NET_", 5) == 0;
8362 XFree (names[i]);
8363 }
8364 }
8365 xfree (names);
8366 } 8432 }
8367 if (atoms)
8368 XFree (atoms);
8369 8433
8370 FRAME_X_DISPLAY_INFO (f)->have_net_atoms = have_net_atom; 8434 dpyinfo->net_supported_atoms = (Atom *)tmp_data;
8435 dpyinfo->nr_net_supported_atoms = actual_size;
8436 dpyinfo->net_supported_window = wmcheck_window;
8371 } 8437 }
8372 8438
8439 rc = 0;
8440 want_atom = XInternAtom (dpy, atomname, False);
8441
8442 for (i = 0; rc == 0 && i < dpyinfo->nr_net_supported_atoms; ++i)
8443 rc = dpyinfo->net_supported_atoms[i] == want_atom;
8444
8445 x_uncatch_errors ();
8446 UNBLOCK_INPUT;
8447
8448 return rc;
8449}
8450
8451/* Do fullscreen as specified in extended window manager hints */
8452
8453static int
8454do_ewmh_fullscreen (f)
8455 struct frame *f;
8456{
8457 int have_net_atom = wm_supports (f, "_NET_WM_STATE");
8458
8373 if (have_net_atom) 8459 if (have_net_atom)
8374 { 8460 {
8375 Lisp_Object frame; 8461 Lisp_Object frame;
@@ -8396,6 +8482,9 @@ do_ewmh_fullscreen (f)
8396 break; 8482 break;
8397 } 8483 }
8398 8484
8485 if (!wm_supports (f, what)) return 0;
8486
8487
8399 Fx_send_client_event (frame, make_number (0), frame, 8488 Fx_send_client_event (frame, make_number (0), frame,
8400 make_unibyte_string (atom, strlen (atom)), 8489 make_unibyte_string (atom, strlen (atom)),
8401 make_number (32), 8490 make_number (32),
@@ -8796,23 +8885,27 @@ XTframe_raise_lower (f, raise_flag)
8796 /* The following code is needed for `raise-frame' to work on 8885 /* The following code is needed for `raise-frame' to work on
8797 some versions of metacity; see Window Manager 8886 some versions of metacity; see Window Manager
8798 Specification/Extended Window Manager Hints at 8887 Specification/Extended Window Manager Hints at
8799 http://freedesktop.org/wiki/Standards_2fwm_2dspec 8888 http://freedesktop.org/wiki/Standards_2fwm_2dspec */
8800 8889
8801 However, on other versions (metacity 2.17.2-1.fc7), it 8890#if 0
8891 /* However, on other versions (metacity 2.17.2-1.fc7), it
8802 reportedly causes hangs when resizing frames. */ 8892 reportedly causes hangs when resizing frames. */
8803 8893
8804 /* Lisp_Object frame; 8894 const char *atom = "_NET_ACTIVE_WINDOW";
8805 const char *atom = "_NET_ACTIVE_WINDOW"; */ 8895 if (f->async_visible && wm_supports (f, atom))
8806 8896 {
8807 x_raise_frame (f); 8897 Lisp_Object frame;
8808 8898 XSETFRAME (frame, f);
8809 /* XSETFRAME (frame, f); 8899 Fx_send_client_event (frame, make_number (0), frame,
8810 Fx_send_client_event (frame, make_number (0), frame, 8900 make_unibyte_string (atom, strlen (atom)),
8811 make_unibyte_string (atom, strlen (atom)), 8901 make_number (32),
8812 make_number (32), 8902 Fcons (make_number (1),
8813 Fcons (make_number (1), 8903 Fcons (make_number (last_user_time),
8814 Fcons (make_number (time (NULL) * 1000), 8904 Qnil)));
8815 Qnil))); */ 8905 }
8906 else
8907#endif
8908 x_raise_frame (f);
8816 } 8909 }
8817 else 8910 else
8818 x_lower_frame (f); 8911 x_lower_frame (f);
@@ -10807,6 +10900,10 @@ x_term_init (display_name, xrm_option, resource_name)
10807 dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms) 10900 dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms)
10808 * dpyinfo->x_dnd_atoms_size); 10901 * dpyinfo->x_dnd_atoms_size);
10809 10902
10903 dpyinfo->net_supported_atoms = NULL;
10904 dpyinfo->nr_net_supported_atoms = 0;
10905 dpyinfo->net_supported_window = 0;
10906
10810 connection = ConnectionNumber (dpyinfo->display); 10907 connection = ConnectionNumber (dpyinfo->display);
10811 dpyinfo->connection = connection; 10908 dpyinfo->connection = connection;
10812 10909
diff --git a/src/xterm.h b/src/xterm.h
index 1ea50b8158f..b8e86d646ed 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -396,7 +396,10 @@ struct x_display_info
396 size_t x_dnd_atoms_size; 396 size_t x_dnd_atoms_size;
397 size_t x_dnd_atoms_length; 397 size_t x_dnd_atoms_length;
398 398
399 int have_net_atoms; 399 /* Extended window manager hints, Atoms supported by the window manager */
400 Atom *net_supported_atoms;
401 int nr_net_supported_atoms;
402 Window net_supported_window;
400}; 403};
401 404
402#ifdef HAVE_X_I18N 405#ifdef HAVE_X_I18N