diff options
author | Karoly Lorentey <lorentey@elte.hu> | 2007-01-13 22:59:28 +0000 |
---|---|---|
committer | Karoly Lorentey <lorentey@elte.hu> | 2007-01-13 22:59:28 +0000 |
commit | 38db5c8d522cc1faa8190e77dbc932a5560e6aad (patch) | |
tree | efe4c81d7210843bb208282461ebce12c5bd3daf /src | |
parent | 191ae1cf7cd2571277635b3b8e488e773ca5c9b9 (diff) | |
parent | b4ec8cb4e66f94547e8215a1c1eb6cda3b83ca63 (diff) | |
download | emacs-38db5c8d522cc1faa8190e77dbc932a5560e6aad.tar.gz emacs-38db5c8d522cc1faa8190e77dbc932a5560e6aad.tar.bz2 emacs-38db5c8d522cc1faa8190e77dbc932a5560e6aad.zip |
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-592
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-593
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-594
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-595
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-596
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-597
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-598
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-186
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-187
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-188
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-189
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-190
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-191
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-593
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 80 | ||||
-rw-r--r-- | src/callproc.c | 6 | ||||
-rw-r--r-- | src/dired.c | 12 | ||||
-rw-r--r-- | src/editfns.c | 18 | ||||
-rw-r--r-- | src/emacs.c | 3 | ||||
-rw-r--r-- | src/image.c | 8 | ||||
-rw-r--r-- | src/keyboard.c | 2 | ||||
-rw-r--r-- | src/macgui.h | 2 | ||||
-rw-r--r-- | src/macmenu.c | 121 | ||||
-rw-r--r-- | src/macterm.c | 117 | ||||
-rw-r--r-- | src/macterm.h | 10 | ||||
-rw-r--r-- | src/xterm.c | 173 | ||||
-rw-r--r-- | src/xterm.h | 5 |
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 @@ +2007-01-10 Stefan Monnier <monnier@iro.umontreal.ca> + + * editfns.c (Fformat): Allow integer-format to work with floats of size + larger than most-positive-fixnum (but still smaller than MAXINT). + + * dired.c (Ffile_attributes): Use floats for large uids/gids. + +2007-01-09 Eli Zaretskii <eliz@gnu.org> + + * emacs.c (syms_of_emacs) <path-separator>: Doc fix. + +2007-01-09 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * callproc.c (Fcall_process_region) [HAVE_MKSTEMP]: Add BLOCK_INPUT + around mkstemp. + + * image.c (XDrawLine) [MAC_OS]: Remove macro. + (XCreateGC_pixmap) [!HAVE_NTGUI]: Likewise. + (x_disable_image) [!HAVE_NTGUI]: Use XCreateGC instead of + XCreateGC_pixmap. + + * macgui.h (Display): Typedef to opaque type. + + * macmenu.c (mac_dialog_modal_filter) [MAC_OSX]: New function. + (Fx_popup_dialog) [MAC_OSX]: Use standard alert if called from + Fmessage_box, Fyes_or_no_p, or Fy_or_n_p. + [MAC_OS_X_VERSION_MAX_ALLOWED >= 1030] (menu_quit_handler): + Use mac_quit_char_key_p. + + * macterm.c (XDrawLine): Rename from mac_draw_line_to_pixmap. + (XCreateGC): Change type of 2nd argument to void *. + (XFreeGC) [USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]: + Fix last change. + (mac_to_emacs_modifiers): Change return type to int. + [USE_CARBON_EVENTS] (mac_event_to_emacs_modifiers): Likewise. + (mac_mapped_modifiers): New function. + (XTread_socket): Use it. + [USE_TSM] (mac_handle_text_input_event): Likewise. + (do_window_update) [USE_CG_DRAWING]: Call mac_prepare_for_quickdraw. + (mac_quit_char_modifiers, mac_quit_char_keycode) [MAC_OSX]: + Remove variables. + (mac_determine_quit_char_modifiers, init_quit_char_handler) + [MAC_OSX]: Remove functions. + (make_ctrl_char) [MAC_OSX]: Add extern. + (mac_quit_char_key_p) [MAC_OSX]: New function. + (mac_initialize) [MAC_OSX]: Don't call init_quit_char_handler. + + * macterm.h (FONT_MAX_WIDTH): Remove unused macro. + (XCreateGC): Change type in extern. + (XDrawLine): Rename from mac_draw_line_to_pixmap. + (mac_quit_char_key_p) [MAC_OSX]: Add extern. + +2007-01-08 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * keyboard.c (init_keyboard): Initialize interrupt_input_blocked and + interrupt_input_pending. + + * xterm.h (x_display_info): New: net_supported_atoms, + nr_net_supported_atoms and net_supported_window. + + * xterm.c: New variable last_user_time. + (handle_one_xevent): Set last_user_time from events that have Time. + Set net_supported_window to 0 when reparented. + (wm_supports): New function. + (do_ewmh_fullscreen): Use wm_supports to check for _NET_WM_STATE. + (x_term_init): Initialize net_supported_atoms, nr_net_supported_atoms + and net_supported_window. + 2007-01-05 Kim F. Storm <storm@cua.dk> * indent.c (Fvertical_motion): Fix it overshoot check for overlay @@ -148,8 +216,8 @@ 2006-12-22 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> - * macfns.c (mac_update_title_bar) [TARGET_API_MAC_CARBON]: Call - mac_update_proxy_icon also when buffer modification flag changed. + * macfns.c (mac_update_title_bar) [TARGET_API_MAC_CARBON]: + Call mac_update_proxy_icon also when buffer modification flag changed. [TARGET_API_MAC_CARBON] (mac_update_proxy_icon): Don't update alias, but compare FSRef/FSSpec of resolved alias. @@ -242,8 +310,8 @@ (Fmac_atsu_font_face_attributes) [USE_ATSUI]: New function. (syms_of_macfns) [USE_ATSUI]: Defsubr it. - * macselect.c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Use - mac_wakeup_from_rne instead of mac_post_mouse_moved_event. + * macselect.c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): + Use mac_wakeup_from_rne instead of mac_post_mouse_moved_event. * macterm.c (mac_query_char_extents) [USE_ATSUI]: Don't call ATSUGetGlyphBounds if not necessary. @@ -256,8 +324,8 @@ (mac_load_query_font) [USE_ATSUI]: Use atsu_find_font_from_family_name. Don't get metrics for Latin-1 right half characters. (mac_load_query_font): Don't load font if space width is not positive. - [TARGET_API_MAC_CARBON] (mac_store_event_ref_as_apple_event): Use - mac_wakeup_from_rne instead of mac_post_mouse_moved_event. + [TARGET_API_MAC_CARBON] (mac_store_event_ref_as_apple_event): + Use mac_wakeup_from_rne instead of mac_post_mouse_moved_event. (XTread_socket): Call SelectWindow when unfocused frame is clicked. * 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 #ifdef HAVE_MKSTEMP { - int fd = mkstemp (tempfile); + int fd; + + BLOCK_INPUT; + fd = mkstemp (tempfile); + UNBLOCK_INPUT; if (fd == -1) report_file_error ("Failed to open temporary file", 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 @@ /* Lisp functions for making directory listings. Copyright (C) 1985, 1986, 1993, 1994, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -966,16 +966,18 @@ Elements of the attribute list are: values[1] = make_number (s.st_nlink); if (NILP (id_format) || EQ (id_format, Qinteger)) { - values[2] = make_number (s.st_uid); - values[3] = make_number (s.st_gid); + values[2] = make_fixnum_or_float (s.st_uid); + values[3] = make_fixnum_or_float (s.st_gid); } else { BLOCK_INPUT; pw = (struct passwd *) getpwuid (s.st_uid); - values[2] = (pw ? build_string (pw->pw_name) : make_number (s.st_uid)); + values[2] = (pw ? build_string (pw->pw_name) + : make_fixnum_or_float (s.st_uid)); gr = (struct group *) getgrgid (s.st_gid); - values[3] = (gr ? build_string (gr->gr_name) : make_number (s.st_gid)); + values[3] = (gr ? build_string (gr->gr_name) + : make_fixnum_or_float (s.st_gid)); UNBLOCK_INPUT; } 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 @@ /* Lisp functions pertaining to editing. Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006 Free Software Foundation, Inc. + 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -3631,7 +3631,12 @@ usage: (format STRING &rest OBJECTS) */) if (*format != 'd' && *format != 'o' && *format != 'x' && *format != 'i' && *format != 'X' && *format != 'c') error ("Invalid format operation %%%c", *format); - args[n] = Ftruncate (args[n], Qnil); + /* This fails unnecessarily if args[n] is bigger than + most-positive-fixnum but smaller than MAXINT. + These cases are important because we sometimes use floats + to represent such integer values (typically such values + come from UIDs or PIDs). */ + /* args[n] = Ftruncate (args[n], Qnil); */ } /* Note that we're using sprintf to print floats, @@ -3799,8 +3804,15 @@ usage: (format STRING &rest OBJECTS) */) else sprintf (p, this_format, XUINT (args[n])); } - else + else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') sprintf (p, this_format, XFLOAT_DATA (args[n])); + else if (format[-1] == 'd') + /* Maybe we should use "%1.0f" instead so it also works + for values larger than MAXINT. */ + sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); + else + /* Don't sign-extend for octal or hex printing. */ + sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); if (p > buf && 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. */); emacs_priority = 0; DEFVAR_LISP ("path-separator", &Vpath_separator, - doc: /* The directory separator in search paths, as a string. */); + doc: /* String containing the character that separates directories in +search paths, such as PATH and other similar environment variables. */); { char c = SEPCHAR; 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; #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual #define x_defined_color mac_defined_color #define DefaultDepthOfScreen(screen) (one_mac_display_info.n_planes) -#define XDrawLine(display, w, gc, x1, y1, x2, y2) \ - mac_draw_line_to_pixmap(display, w, gc, x1, y1, x2, y2) #endif /* MAC_OS */ @@ -5253,14 +5251,12 @@ x_disable_image (f, img) GC gc; #ifdef MAC_OS -#define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, NULL, 0, NULL) #define MaskForeground(f) PIX_MASK_DRAW #else -#define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, pixmap, 0, NULL) #define MaskForeground(f) WHITE_PIX_DEFAULT (f) #endif - gc = XCreateGC_pixmap (dpy, img->pixmap); + gc = XCreateGC (dpy, img->pixmap, 0, NULL); XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f)); XDrawLine (dpy, img->pixmap, gc, 0, 0, img->width - 1, img->height - 1); @@ -5270,7 +5266,7 @@ x_disable_image (f, img) if (img->mask) { - gc = XCreateGC_pixmap (dpy, img->mask); + gc = XCreateGC (dpy, img->mask, 0, NULL); XSetForeground (dpy, gc, MaskForeground (f)); XDrawLine (dpy, img->mask, gc, 0, 0, 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 () do_mouse_tracking = Qnil; #endif input_pending = 0; + interrupt_input_blocked = 0; + interrupt_input_pending = 0; /* This means that command_loop_1 won't try to select anything the first 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. */ #ifndef EMACS_MACGUI_H #define EMACS_MACGUI_H -typedef int Display; /* fix later */ +typedef struct _XDisplay Display; /* opaque */ typedef Lisp_Object XrmDatabase; 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. */) #ifdef HAVE_MENUS +/* Regard ESC and C-g as Cancel even without the Cancel button. */ + +#ifdef MAC_OSX +static Boolean +mac_dialog_modal_filter (dialog, event, item_hit) + DialogRef dialog; + EventRecord *event; + DialogItemIndex *item_hit; +{ + Boolean result; + + result = StdFilterProc (dialog, event, item_hit); + if (result == false + && (event->what == keyDown || event->what == autoKey) + && ((event->message & charCodeMask) == kEscapeCharCode + || mac_quit_char_key_p (event->modifiers, + (event->message & keyCodeMask) >> 8))) + { + *item_hit = kStdCancelItemIndex; + return true; + } + + return result; +} +#endif + DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0, doc: /* Pop up a dialog box and return user's selection. POSITION specifies which frame to use. @@ -961,6 +987,96 @@ for instance using the window manager, then this produces a quit and but I don't want to make one now. */ CHECK_WINDOW (window); +#ifdef MAC_OSX + /* Special treatment for Fmessage_box, Fyes_or_no_p, and Fy_or_n_p. */ + if (EQ (position, Qt) + && STRINGP (Fcar (contents)) + && ((!NILP (Fequal (XCDR (contents), + Fcons (Fcons (build_string ("OK"), Qt), Qnil))) + && EQ (header, Qt)) + || (!NILP (Fequal (XCDR (contents), + Fcons (Fcons (build_string ("Yes"), Qt), + Fcons (Fcons (build_string ("No"), Qnil), + Qnil)))) + && NILP (header)))) + { + OSStatus err = noErr; + AlertStdCFStringAlertParamRec param; + CFStringRef error_string, explanation_string; + DialogRef alert; + DialogItemIndex item_hit; + Lisp_Object tem; + + tem = Fstring_match (concat3 (build_string ("\\("), + call0 (intern ("sentence-end")), + build_string ("\\)\n")), + XCAR (contents), Qnil); + BLOCK_INPUT; + if (NILP (tem)) + { + error_string = cfstring_create_with_string (XCAR (contents)); + if (error_string == NULL) + err = memFullErr; + explanation_string = NULL; + } + else + { + tem = Fmatch_end (make_number (1)); + error_string = + cfstring_create_with_string (Fsubstring (XCAR (contents), + make_number (0), tem)); + if (error_string == NULL) + err = memFullErr; + else + { + XSETINT (tem, XINT (tem) + 1); + explanation_string = + cfstring_create_with_string (Fsubstring (XCAR (contents), + tem, Qnil)); + if (explanation_string == NULL) + { + CFRelease (error_string); + err = memFullErr; + } + } + } + if (err == noErr) + err = GetStandardAlertDefaultParams (¶m, + kStdCFStringAlertVersionOne); + if (err == noErr) + { + param.movable = true; + param.position = kWindowAlertPositionParentWindow; + if (NILP (header)) + { + param.defaultText = CFSTR ("Yes"); + param.otherText = CFSTR ("No"); +#if 0 + param.cancelText = CFSTR ("Cancel"); + param.cancelButton = kAlertStdAlertCancelButton; +#endif + } + err = CreateStandardAlert (kAlertNoteAlert, error_string, + explanation_string, ¶m, &alert); + CFRelease (error_string); + if (explanation_string) + CFRelease (explanation_string); + } + if (err == noErr) + err = RunStandardAlert (alert, mac_dialog_modal_filter, &item_hit); + UNBLOCK_INPUT; + + if (err == noErr) + { + if (item_hit == kStdCancelItemIndex) + Fsignal (Qquit, Qnil); + else if (item_hit == kStdOkItemIndex) + return Qt; + else + return Qnil; + } + } +#endif #ifndef HAVE_DIALOGS /* Display a menu with these alternatives in the middle of frame F. */ @@ -1537,8 +1653,6 @@ menu_quit_handler (nextHandler, theEvent, userData) OSStatus err; UInt32 keyCode; UInt32 keyModifiers; - extern int mac_quit_char_modifiers; - extern int mac_quit_char_keycode; err = GetEventParameter (theEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode); @@ -1548,8 +1662,7 @@ menu_quit_handler (nextHandler, theEvent, userData) typeUInt32, NULL, sizeof(UInt32), NULL, &keyModifiers); - if (err == noErr && keyCode == mac_quit_char_keycode - && keyModifiers == mac_quit_char_modifiers) + if (err == noErr && mac_quit_char_key_p (keyModifiers, keyCode)) { MenuRef menu = userData != 0 ? (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) #endif } +/* Mac version of XDrawLine (to Pixmap). */ + void -mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) +XDrawLine (display, p, gc, x1, y1, x2, y2) Display *display; Pixmap p; GC gc; @@ -1628,9 +1630,9 @@ XChangeGC (display, gc, mask, xgcv) /* Mac replacement for XCreateGC. */ GC -XCreateGC (display, window, mask, xgcv) +XCreateGC (display, d, mask, xgcv) Display *display; - Window window; + void *d; unsigned long mask; XGCValues *xgcv; { @@ -1663,8 +1665,13 @@ XFreeGC (display, gc) if (gc->clip_region) DisposeRgn (gc->clip_region); #if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - CGColorRelease (gc->cg_fore_color); - CGColorRelease (gc->cg_back_color); +#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020 + if (CGColorGetTypeID != NULL) +#endif + { + CGColorRelease (gc->cg_fore_color); + CGColorRelease (gc->cg_back_color); + } #endif xfree (gc); } @@ -8967,7 +8974,7 @@ static const unsigned char fn_keycode_to_keycode_table[] = { }; #endif /* MAC_OSX */ -static unsigned int +static int #if USE_CARBON_EVENTS mac_to_emacs_modifiers (UInt32 mods) #else @@ -9014,6 +9021,23 @@ mac_to_emacs_modifiers (EventModifiers mods) return result; } +static UInt32 +mac_mapped_modifiers (modifiers) + UInt32 modifiers; +{ + UInt32 mapped_modifiers_all = + (NILP (Vmac_control_modifier) ? 0 : controlKey) + | (NILP (Vmac_option_modifier) ? 0 : optionKey) + | (NILP (Vmac_command_modifier) ? 0 : cmdKey); + +#ifdef MAC_OSX + mapped_modifiers_all |= + (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask); +#endif + + return mapped_modifiers_all & modifiers; +} + static int mac_get_emulated_btn ( UInt32 modifiers ) { @@ -9031,7 +9055,7 @@ mac_get_emulated_btn ( UInt32 modifiers ) #if USE_CARBON_EVENTS /* Obtains the event modifiers from the event ref and then calls mac_to_emacs_modifiers. */ -static UInt32 +static int mac_event_to_emacs_modifiers (EventRef eventRef) { UInt32 mods = 0; @@ -9256,6 +9280,9 @@ do_window_update (WindowPtr win) GetPortVisibleRegion (GetWindowPort (win), region); GetRegionBounds (region, &r); expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); +#if USE_CG_DRAWING + mac_prepare_for_quickdraw (f); +#endif UpdateControls (win, region); DisposeRgn (region); #else @@ -10067,21 +10094,10 @@ mac_handle_text_input_event (next_handler, event, data) err = GetEventParameter (kbd_event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof (UInt32), NULL, &modifiers); - if (err == noErr) - { - mapped_modifiers = - (NILP (Vmac_control_modifier) ? 0 : controlKey) - | (NILP (Vmac_option_modifier) ? 0 : optionKey) - | (NILP (Vmac_command_modifier) ? 0 : cmdKey); -#ifdef MAC_OSX - mapped_modifiers |= - (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask); -#endif - if (modifiers & mapped_modifiers) - /* There're mapped modifier keys. Process it in - XTread_socket. */ - return eventNotHandledErr; - } + if (err == noErr && mac_mapped_modifiers (modifiers)) + /* There're mapped modifier keys. Process it in + XTread_socket. */ + return eventNotHandledErr; if (err == noErr) err = GetEventParameter (kbd_event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0, &actual_size, @@ -11032,20 +11048,12 @@ XTread_socket (sd, expected, hold_quit) SInt16 current_key_script; UInt32 modifiers = er.modifiers, mapped_modifiers; - mapped_modifiers = - (NILP (Vmac_control_modifier) ? 0 : controlKey) - | (NILP (Vmac_option_modifier) ? 0 : optionKey) - | (NILP (Vmac_command_modifier) ? 0 : cmdKey); - #if USE_CARBON_EVENTS && defined (MAC_OSX) - mapped_modifiers |= - (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask); - GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, sizeof (UInt32), NULL, &modifiers); #endif - mapped_modifiers &= modifiers; + mapped_modifiers = mac_mapped_modifiers (modifiers); #if USE_CARBON_EVENTS && (defined (MAC_OSX) || USE_MAC_TSM) /* When using Carbon Events, we need to pass raw keyboard @@ -11639,34 +11647,33 @@ MakeMeTheFrontProcess () } /***** Code to handle C-g testing *****/ - -/* Contains the Mac modifier formed from quit_char */ -int mac_quit_char_modifiers = 0; -int mac_quit_char_keycode; extern int quit_char; +extern int make_ctrl_char P_ ((int)); -static void -mac_determine_quit_char_modifiers() -{ - /* Todo: Determine modifiers from quit_char. */ - UInt32 qc_modifiers = ctrl_modifier; +int +mac_quit_char_key_p (modifiers, key_code) + UInt32 modifiers, key_code; +{ + UInt32 char_code; + unsigned long some_state = 0; + Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); + int c, emacs_modifiers; + + /* Mask off modifier keys that are mapped to some Emacs modifiers. */ + key_code |= (modifiers & ~(mac_mapped_modifiers (modifiers))); + char_code = KeyTranslate (kchr_ptr, key_code, &some_state); + if (char_code & ~0xff) + return 0; - /* Map modifiers */ - mac_quit_char_modifiers = 0; - if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= controlKey; - if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= shiftKey; - if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= optionKey; -} + emacs_modifiers = mac_to_emacs_modifiers (modifiers); + if (emacs_modifiers & ctrl_modifier) + c = make_ctrl_char (char_code); -static void -init_quit_char_handler () -{ - /* TODO: Let this support keys other the 'g' */ - mac_quit_char_keycode = 5; - /* Look at <architecture/adb_kb_map.h> for details */ - /* http://gemma.apple.com/techpubs/mac/Toolbox/Toolbox-40.html#MARKER-9-184*/ + c |= (emacs_modifiers + & (meta_modifier | alt_modifier + | hyper_modifier | super_modifier)); - mac_determine_quit_char_modifiers(); + return c == quit_char; } #endif /* MAC_OSX */ @@ -11804,8 +11811,6 @@ mac_initialize () #if USE_CARBON_EVENTS #ifdef MAC_OSX init_service_handler (); - - init_quit_char_handler (); #endif /* MAC_OSX */ 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. */ #define FONT_BASE(f) ((f)->ascent) #define FONT_DESCENT(f) ((f)->descent) -#define FONT_MAX_WIDTH(f) FONT_WIDTH(f) /* fix later */ - /* Structure recording bitmaps and reference count. If REFCOUNT is 0 then this record is free to be reused. */ @@ -614,13 +612,12 @@ extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *, unsigned long, unsigned long, unsigned int)); extern void XFreePixmap P_ ((Display *, Pixmap)); -extern GC XCreateGC P_ ((Display *, Window, unsigned long, XGCValues *)); +extern GC XCreateGC P_ ((Display *, void *, unsigned long, XGCValues *)); extern void XFreeGC P_ ((Display *, GC)); extern void XSetForeground P_ ((Display *, GC, unsigned long)); extern void XSetBackground P_ ((Display *, GC, unsigned long)); extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long)); -extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int, - int, int)); +extern void XDrawLine P_ ((Display *, Pixmap, GC, int, int, int, int)); extern void mac_clear_area P_ ((struct frame *, int, int, unsigned int, unsigned int)); extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); @@ -636,6 +633,9 @@ extern void do_apple_menu P_ ((SInt16)); #if USE_CG_DRAWING extern void mac_prepare_for_quickdraw P_ ((struct frame *)); #endif +#ifdef MAC_OSX +extern int mac_quit_char_key_p P_ ((UInt32, UInt32)); +#endif #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 #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; static Time last_mouse_movement_time; +/* Time for last user interaction as returned in X events. */ + +static Time last_user_time; + /* Incremented by XTread_socket whenever it really tries to read events. */ @@ -5882,6 +5886,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) break; case SelectionNotify: + last_user_time = event.xselection.time; #ifdef USE_X_TOOLKIT if (! x_window_to_frame (dpyinfo, event.xselection.requestor)) goto OTHER; @@ -5890,6 +5895,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) break; case SelectionClear: /* Someone has grabbed ownership. */ + last_user_time = event.xselectionclear.time; #ifdef USE_X_TOOLKIT if (! x_window_to_frame (dpyinfo, event.xselectionclear.window)) goto OTHER; @@ -5906,6 +5912,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) break; case SelectionRequest: /* Someone wants our selection. */ + last_user_time = event.xselectionrequest.time; #ifdef USE_X_TOOLKIT if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner)) goto OTHER; @@ -5926,6 +5933,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) break; case PropertyNotify: + last_user_time = event.xproperty.time; #if 0 /* This is plain wrong. In the case that we are waiting for a PropertyNotify used as an ACK in incremental selection transfer, the property will be on the receiver's window. */ @@ -5949,6 +5957,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) /* Perhaps reparented due to a WM restart. Reset this. */ FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN; + FRAME_X_DISPLAY_INFO (f)->net_supported_window = 0; } goto OTHER; @@ -6107,6 +6116,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) case KeyPress: + last_user_time = event.xkey.time; ignore_next_mouse_click_timeout = 0; #if defined (USE_X_TOOLKIT) || defined (USE_GTK) @@ -6497,6 +6507,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) #endif case KeyRelease: + last_user_time = event.xkey.time; #ifdef HAVE_X_I18N /* Don't dispatch this event since XtDispatchEvent calls XFilterEvent, and two calls in a row may freeze the @@ -6507,6 +6518,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) #endif case EnterNotify: + last_user_time = event.xcrossing.time; x_detect_focus_change (dpyinfo, &event, &inev.ie); f = x_any_window_to_frame (dpyinfo, event.xcrossing.window); @@ -6547,6 +6559,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) goto OTHER; case LeaveNotify: + last_user_time = event.xcrossing.time; x_detect_focus_change (dpyinfo, &event, &inev.ie); f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); @@ -6580,6 +6593,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) case MotionNotify: { + last_user_time = event.xmotion.time; previous_help_echo_string = help_echo_string; help_echo_string = Qnil; @@ -6728,6 +6742,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) bzero (&compose_status, sizeof (compose_status)); last_mouse_glyph_frame = 0; + last_user_time = event.xbutton.time; if (dpyinfo->grabbed && last_mouse_frame @@ -8336,40 +8351,111 @@ x_set_offset (f, xoff, yoff, change_gravity) UNBLOCK_INPUT; } -/* Do fullscreen as specified in extended window manager hints */ +/* 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 -do_ewmh_fullscreen (f) +wm_supports (f, atomname) struct frame *f; + const char *atomname; { - int have_net_atom = FRAME_X_DISPLAY_INFO (f)->have_net_atoms; + 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); - if (!have_net_atom) + /* Check if window exists. */ + XSelectInput (dpy, wmcheck_window, StructureNotifyMask); + x_sync (f); + if (x_had_errors_p (dpy)) { - int num; - Atom *atoms = XListProperties (FRAME_X_DISPLAY (f), - FRAME_X_DISPLAY_INFO (f)->root_window, - &num); - if (atoms && num > 0) + x_uncatch_errors (); + UNBLOCK_INPUT; + return 0; + } + + if (dpyinfo->net_supported_window != wmcheck_window) + { + /* Window changed, reload atoms */ + if (dpyinfo->net_supported_atoms != NULL) + XFree (dpyinfo->net_supported_atoms); + dpyinfo->net_supported_atoms = NULL; + dpyinfo->nr_net_supported_atoms = 0; + dpyinfo->net_supported_window = 0; + + target_type = XA_ATOM; + prop_atom = XInternAtom (dpy, "_NET_SUPPORTED", False); + tmp_data = NULL; + 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_ATOM || x_had_errors_p (dpy)) { - char **names = (char **) xmalloc (num * sizeof(*names)); - if (XGetAtomNames (FRAME_X_DISPLAY (f), atoms, num, names)) - { - int i; - for (i = 0; i < num; ++i) - { - if (!have_net_atom) - have_net_atom = strncmp (names[i], "_NET_", 5) == 0; - XFree (names[i]); - } - } - xfree (names); + if (tmp_data) XFree (tmp_data); + x_uncatch_errors (); + UNBLOCK_INPUT; + return 0; } - if (atoms) - XFree (atoms); - FRAME_X_DISPLAY_INFO (f)->have_net_atoms = have_net_atom; + dpyinfo->net_supported_atoms = (Atom *)tmp_data; + dpyinfo->nr_net_supported_atoms = actual_size; + dpyinfo->net_supported_window = wmcheck_window; } + rc = 0; + want_atom = XInternAtom (dpy, atomname, False); + + for (i = 0; rc == 0 && i < dpyinfo->nr_net_supported_atoms; ++i) + rc = dpyinfo->net_supported_atoms[i] == want_atom; + + x_uncatch_errors (); + UNBLOCK_INPUT; + + return rc; +} + +/* Do fullscreen as specified in extended window manager hints */ + +static int +do_ewmh_fullscreen (f) + struct frame *f; +{ + int have_net_atom = wm_supports (f, "_NET_WM_STATE"); + if (have_net_atom) { Lisp_Object frame; @@ -8396,6 +8482,9 @@ do_ewmh_fullscreen (f) break; } + if (!wm_supports (f, what)) return 0; + + Fx_send_client_event (frame, make_number (0), frame, make_unibyte_string (atom, strlen (atom)), make_number (32), @@ -8796,23 +8885,27 @@ XTframe_raise_lower (f, raise_flag) /* The following code is needed for `raise-frame' to work on some versions of metacity; see Window Manager Specification/Extended Window Manager Hints at - http://freedesktop.org/wiki/Standards_2fwm_2dspec + http://freedesktop.org/wiki/Standards_2fwm_2dspec */ - However, on other versions (metacity 2.17.2-1.fc7), it +#if 0 + /* However, on other versions (metacity 2.17.2-1.fc7), it reportedly causes hangs when resizing frames. */ - /* Lisp_Object frame; - const char *atom = "_NET_ACTIVE_WINDOW"; */ - - x_raise_frame (f); - - /* XSETFRAME (frame, f); - Fx_send_client_event (frame, make_number (0), frame, - make_unibyte_string (atom, strlen (atom)), - make_number (32), - Fcons (make_number (1), - Fcons (make_number (time (NULL) * 1000), - Qnil))); */ + const char *atom = "_NET_ACTIVE_WINDOW"; + if (f->async_visible && wm_supports (f, atom)) + { + Lisp_Object frame; + XSETFRAME (frame, f); + Fx_send_client_event (frame, make_number (0), frame, + make_unibyte_string (atom, strlen (atom)), + make_number (32), + Fcons (make_number (1), + Fcons (make_number (last_user_time), + Qnil))); + } + else +#endif + x_raise_frame (f); } else x_lower_frame (f); @@ -10807,6 +10900,10 @@ x_term_init (display_name, xrm_option, resource_name) dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms) * dpyinfo->x_dnd_atoms_size); + dpyinfo->net_supported_atoms = NULL; + dpyinfo->nr_net_supported_atoms = 0; + dpyinfo->net_supported_window = 0; + connection = ConnectionNumber (dpyinfo->display); dpyinfo->connection = connection; 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 size_t x_dnd_atoms_size; size_t x_dnd_atoms_length; - int have_net_atoms; + /* Extended window manager hints, Atoms supported by the window manager */ + Atom *net_supported_atoms; + int nr_net_supported_atoms; + Window net_supported_window; }; #ifdef HAVE_X_I18N |