#include "termhooks.h"
#include "termopts.h"
#include "termchar.h"
-#include "gnu.h"
#include "disptab.h"
#include "buffer.h"
#include "window.h"
struct mac_display_info *mac_display_info_for_display (Display *);
static void x_update_window_end P_ ((struct window *, int, int));
-static int x_io_error_quitter P_ ((Display *));
int x_catch_errors P_ ((Display *));
void x_uncatch_errors P_ ((Display *, int));
void x_lower_frame P_ ((struct frame *));
#endif
}
-/* x_sync is a no-op on Mac. */
-void
-x_sync (f)
- void *f;
-{
-}
-
-
/* Flush display of frame F, or of all frames if F is null. */
static void
unsigned short *bits;
int h, wd;
{
- unsigned short *mask_bits;
int i;
CGDataProviderRef provider;
static void x_draw_image_glyph_string P_ ((struct glyph_string *));
static void x_draw_image_relief P_ ((struct glyph_string *));
static void x_draw_image_foreground P_ ((struct glyph_string *));
-static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap));
static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
int, int, int));
static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
mac_compute_glyph_string_overhangs (s)
struct glyph_string *s;
{
- if (s->cmp == NULL
- && s->first_glyph->type == CHAR_GLYPH)
- if (!s->two_byte_p
+ if (!(s->cmp == NULL
+ && s->first_glyph->type == CHAR_GLYPH))
+ return;
+
+ if (!s->two_byte_p
#if USE_ATSUI
- || s->font->mac_style
+ || s->font->mac_style
#endif
- )
- {
- XCharStruct cs;
+ )
+ {
+ XCharStruct cs;
- mac_text_extents_16 (s->font, s->char2b, s->nchars, &cs);
- s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0;
- s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0;
- }
- else
- {
- Rect r;
- MacFontStruct *font = s->font;
+ mac_text_extents_16 (s->font, s->char2b, s->nchars, &cs);
+ s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0;
+ s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0;
+ }
+ else
+ {
+ Rect r;
+ MacFontStruct *font = s->font;
- TextFont (font->mac_fontnum);
- TextSize (font->mac_fontsize);
- TextFace (font->mac_fontface);
+ TextFont (font->mac_fontnum);
+ TextSize (font->mac_fontsize);
+ TextFace (font->mac_fontface);
- QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
+ QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
- s->right_overhang = r.right > s->width ? r.right - s->width : 0;
- s->left_overhang = r.left < 0 ? -r.left : 0;
- }
+ s->right_overhang = r.right > s->width ? r.right - s->width : 0;
+ s->left_overhang = r.left < 0 ? -r.left : 0;
+ }
}
int box_line_hwidth = abs (s->face->box_line_width);
int box_line_vwidth = max (s->face->box_line_width, 0);
int height;
- Pixmap pixmap = 0;
height = s->height - 2 * box_line_vwidth;
\f
-/* Keyboard processing - modifier keys, vendor-specific keysyms, etc. */
-
-#if 0 /* MAC_TODO */
-/* Initialize mode_switch_bit and modifier_meaning. */
-static void
-x_find_modifier_meanings (dpyinfo)
- struct x_display_info *dpyinfo;
-{
- int min_code, max_code;
- KeySym *syms;
- int syms_per_code;
- XModifierKeymap *mods;
-
- dpyinfo->meta_mod_mask = 0;
- dpyinfo->shift_lock_mask = 0;
- dpyinfo->alt_mod_mask = 0;
- dpyinfo->super_mod_mask = 0;
- dpyinfo->hyper_mod_mask = 0;
-
-#ifdef HAVE_X11R4
- XDisplayKeycodes (dpyinfo->display, &min_code, &max_code);
-#else
- min_code = dpyinfo->display->min_keycode;
- max_code = dpyinfo->display->max_keycode;
-#endif
-
- syms = XGetKeyboardMapping (dpyinfo->display,
- min_code, max_code - min_code + 1,
- &syms_per_code);
- mods = XGetModifierMapping (dpyinfo->display);
-
- /* Scan the modifier table to see which modifier bits the Meta and
- Alt keysyms are on. */
- {
- int row, col; /* The row and column in the modifier table. */
-
- for (row = 3; row < 8; row++)
- for (col = 0; col < mods->max_keypermod; col++)
- {
- KeyCode code
- = mods->modifiermap[(row * mods->max_keypermod) + col];
-
- /* Zeroes are used for filler. Skip them. */
- if (code == 0)
- continue;
-
- /* Are any of this keycode's keysyms a meta key? */
- {
- int code_col;
-
- for (code_col = 0; code_col < syms_per_code; code_col++)
- {
- int sym = syms[((code - min_code) * syms_per_code) + code_col];
-
- switch (sym)
- {
- case XK_Meta_L:
- case XK_Meta_R:
- dpyinfo->meta_mod_mask |= (1 << row);
- break;
-
- case XK_Alt_L:
- case XK_Alt_R:
- dpyinfo->alt_mod_mask |= (1 << row);
- break;
-
- case XK_Hyper_L:
- case XK_Hyper_R:
- dpyinfo->hyper_mod_mask |= (1 << row);
- break;
-
- case XK_Super_L:
- case XK_Super_R:
- dpyinfo->super_mod_mask |= (1 << row);
- break;
-
- case XK_Shift_Lock:
- /* Ignore this if it's not on the lock modifier. */
- if ((1 << row) == LockMask)
- dpyinfo->shift_lock_mask = LockMask;
- break;
- }
- }
- }
- }
- }
-
- /* If we couldn't find any meta keys, accept any alt keys as meta keys. */
- if (! dpyinfo->meta_mod_mask)
- {
- dpyinfo->meta_mod_mask = dpyinfo->alt_mod_mask;
- dpyinfo->alt_mod_mask = 0;
- }
-
- /* If some keys are both alt and meta,
- make them just meta, not alt. */
- if (dpyinfo->alt_mod_mask & dpyinfo->meta_mod_mask)
- {
- dpyinfo->alt_mod_mask &= ~dpyinfo->meta_mod_mask;
- }
-
- XFree ((char *) syms);
- XFreeModifiermap (mods);
-}
-
-#endif /* MAC_TODO */
-
-/* Convert between the modifier bits X uses and the modifier bits
- Emacs uses. */
-
-static unsigned int
-x_mac_to_emacs_modifiers (dpyinfo, state)
- struct x_display_info *dpyinfo;
- unsigned short state;
-{
- return (((state & shiftKey) ? shift_modifier : 0)
- | ((state & controlKey) ? ctrl_modifier : 0)
- | ((state & cmdKey) ? meta_modifier : 0)
- | ((state & optionKey) ? alt_modifier : 0));
-}
-
-#if 0 /* MAC_TODO */
-static unsigned short
-x_emacs_to_x_modifiers (dpyinfo, state)
- struct x_display_info *dpyinfo;
- unsigned int state;
-{
- return ( ((state & alt_modifier) ? dpyinfo->alt_mod_mask : 0)
- | ((state & super_modifier) ? dpyinfo->super_mod_mask : 0)
- | ((state & hyper_modifier) ? dpyinfo->hyper_mod_mask : 0)
- | ((state & shift_modifier) ? ShiftMask : 0)
- | ((state & ctrl_modifier) ? ControlMask : 0)
- | ((state & meta_modifier) ? dpyinfo->meta_mod_mask : 0));
-}
-#endif /* MAC_TODO */
-
/* Convert a keysym to its name. */
char *
#ifdef USE_TOOLKIT_SCROLL_BARS
if (NILP (bar->track_top))
- if (sb_width >= disp_height)
- {
- XSETINT (bar->track_top, 0);
- XSETINT (bar->track_height, 0);
- }
- else
- {
- ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
- Rect r0, r1;
+ {
+ if (sb_width >= disp_height)
+ {
+ XSETINT (bar->track_top, 0);
+ XSETINT (bar->track_height, 0);
+ }
+ else
+ {
+ ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+ Rect r0, r1;
- BLOCK_INPUT;
+ BLOCK_INPUT;
- SetControl32BitMinimum (ch, 0);
- SetControl32BitMaximum (ch, 1);
- SetControlViewSize (ch, 1);
+ SetControl32BitMinimum (ch, 0);
+ SetControl32BitMaximum (ch, 1);
+ SetControlViewSize (ch, 1);
- /* Move the scroll bar thumb to the top. */
- SetControl32BitValue (ch, 0);
- get_control_part_bounds (ch, kControlIndicatorPart, &r0);
+ /* Move the scroll bar thumb to the top. */
+ SetControl32BitValue (ch, 0);
+ get_control_part_bounds (ch, kControlIndicatorPart, &r0);
- /* Move the scroll bar thumb to the bottom. */
- SetControl32BitValue (ch, 1);
- get_control_part_bounds (ch, kControlIndicatorPart, &r1);
+ /* Move the scroll bar thumb to the bottom. */
+ SetControl32BitValue (ch, 1);
+ get_control_part_bounds (ch, kControlIndicatorPart, &r1);
- UnionRect (&r0, &r1, &r0);
- XSETINT (bar->track_top, r0.top);
- XSETINT (bar->track_height, r0.bottom - r0.top);
+ UnionRect (&r0, &r1, &r0);
+ XSETINT (bar->track_top, r0.top);
+ XSETINT (bar->track_height, r0.bottom - r0.top);
- /* Don't show the scroll bar if its height is not enough to
- display the scroll bar thumb. */
- if (r0.bottom - r0.top > 0)
- ShowControl (ch);
+ /* Don't show the scroll bar if its height is not enough to
+ display the scroll bar thumb. */
+ if (r0.bottom - r0.top > 0)
+ ShowControl (ch);
- UNBLOCK_INPUT;
- }
+ UNBLOCK_INPUT;
+ }
+ }
x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole);
#else /* not USE_TOOLKIT_SCROLL_BARS */
struct input_event buf;
if (IsWindowVisible (wp))
- if (IsWindowCollapsed (wp))
- iconified = 1;
- else
- visible = 1;
+ {
+ if (IsWindowCollapsed (wp))
+ iconified = 1;
+ else
+ visible = 1;
+ }
if (!f->async_visible && visible)
{
x_make_frame_visible (f)
struct frame *f;
{
- Lisp_Object type;
- int original_top, original_left;
-
BLOCK_INPUT;
if (! FRAME_VISIBLE_P (f))
before the window gets really visible. */
if (! FRAME_ICONIFIED_P (f)
&& ! f->output_data.mac->asked_for_visible)
+ {
#if TARGET_API_MAC_CARBON
- if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
- {
- struct frame *sf = SELECTED_FRAME ();
- if (!FRAME_MAC_P (sf))
- RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
- kWindowCenterOnMainScreen);
- else
- RepositionWindow (FRAME_MAC_WINDOW (f),
- FRAME_MAC_WINDOW (sf),
+ if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
+ {
+ struct frame *sf = SELECTED_FRAME ();
+ if (!FRAME_MAC_P (sf))
+ RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
+ kWindowCenterOnMainScreen);
+ else
+ RepositionWindow (FRAME_MAC_WINDOW (f),
+ FRAME_MAC_WINDOW (sf),
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
- kWindowCascadeStartAtParentWindowScreen
+ kWindowCascadeStartAtParentWindowScreen
#else
- kWindowCascadeOnParentWindowScreen
+ kWindowCascadeOnParentWindowScreen
#endif
- );
- x_real_positions (f, &f->left_pos, &f->top_pos);
- }
- else
+ );
+ x_real_positions (f, &f->left_pos, &f->top_pos);
+ }
+ else
#endif
- x_set_offset (f, f->left_pos, f->top_pos, 0);
+ x_set_offset (f, f->left_pos, f->top_pos, 0);
+ }
f->output_data.mac->asked_for_visible = 1;
else
{
if (last_char == '?')
- if (anychar_head > pat->buf && *(anychar_head - 1) == '*')
- /* ...*??* -> ...*?? */
- continue;
- else
- /* ...a??* -> ...a*?? */
- {
- *anychar_head++ = '*';
- c = '?';
- }
+ {
+ if (anychar_head > pat->buf && *(anychar_head - 1) == '*')
+ /* ...*??* -> ...*?? */
+ continue;
+ else
+ /* ...a??* -> ...a*?? */
+ {
+ *anychar_head++ = '*';
+ c = '?';
+ }
+ }
nblocks++;
}
else if (c == '?')
if (xlfdpat_match (pat, font_name_table[i]))
{
font_list = Fcons (build_string (font_name_table[i]), font_list);
- if (exact || maxnames > 0 && ++n_fonts >= maxnames)
+ if (exact || (maxnames > 0 && ++n_fonts >= maxnames))
break;
}
else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0
{
font_list = Fcons (build_string (scaled), font_list);
xfree (scaled);
- if (exact || maxnames > 0 && ++n_fonts >= maxnames)
+ if (exact || (maxnames > 0 && ++n_fonts >= maxnames))
break;
}
else
/* Load the font and add it to the table. */
{
- char *full_name;
struct MacFontStruct *font;
struct font_info *fontp;
- unsigned long value;
int i;
fontname = (char *) SDATA (XCAR (font_names));
#endif
+#ifdef MAC_OS8
static void
do_get_menus (void)
{
exit (1);
}
}
+#endif /* MAC_OS8 */
static void
do_window_update (WindowPtr win)
static void
do_zoom_window (WindowPtr w, int zoom_in_or_out)
{
- GrafPtr save_port;
Rect zoom_rect, port_rect;
- Point top_left;
- int w_title_height, columns, rows, width, height;
+ int columns, rows, width, height;
struct frame *f = mac_window_to_frame (w);
struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
-
#if TARGET_API_MAC_CARBON
- {
- Point standard_size;
+ Point standard_size;
- standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
- standard_size.v = dpyinfo->height;
+ standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
+ standard_size.v = dpyinfo->height;
- if (IsWindowInStandardState (w, &standard_size, &zoom_rect))
- zoom_in_or_out = inZoomIn;
- else
- {
- /* Adjust the standard size according to character boundaries. */
-
- columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, zoom_rect.right - zoom_rect.left);
- rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top);
- standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
- standard_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
- GetWindowBounds (w, kWindowContentRgn, &port_rect);
- if (IsWindowInStandardState (w, &standard_size, &zoom_rect)
- && port_rect.left == zoom_rect.left
- && port_rect.top == zoom_rect.top)
- zoom_in_or_out = inZoomIn;
- else
- zoom_in_or_out = inZoomOut;
- }
+ if (IsWindowInStandardState (w, &standard_size, &zoom_rect))
+ zoom_in_or_out = inZoomIn;
+ else
+ {
+ /* Adjust the standard size according to character boundaries. */
- ZoomWindowIdeal (w, zoom_in_or_out, &standard_size);
- }
+ columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, zoom_rect.right - zoom_rect.left);
+ rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top);
+ standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
+ standard_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
+ GetWindowBounds (w, kWindowContentRgn, &port_rect);
+ if (IsWindowInStandardState (w, &standard_size, &zoom_rect)
+ && port_rect.left == zoom_rect.left
+ && port_rect.top == zoom_rect.top)
+ zoom_in_or_out = inZoomIn;
+ else
+ zoom_in_or_out = inZoomOut;
+ }
+
+ ZoomWindowIdeal (w, zoom_in_or_out, &standard_size);
#else /* not TARGET_API_MAC_CARBON */
+ GrafPtr save_port;
+ Point top_left;
+ int w_title_height;
+
GetPort (&save_port);
SetPortWindowPort (w);
mac_find_apple_event_spec (0, command.commandID,
&class_key, &id_key, &binding);
if (!NILP (binding) && !EQ (binding, Qundefined))
- if (INTEGERP (binding))
- return XINT (binding);
- else
- {
- AppleEvent apple_event;
- UInt32 modifiers;
- static EventParamName names[] = {kEventParamDirectObject,
- kEventParamKeyModifiers};
- static EventParamType types[] = {typeHICommand,
- typeUInt32};
- err = create_apple_event_from_event_ref (event, 2, names, types,
- &apple_event);
- if (err == noErr)
- {
- err = mac_store_apple_event (class_key, id_key, &apple_event);
- AEDisposeDesc (&apple_event);
- }
- if (err == noErr)
- return noErr;
- }
+ {
+ if (INTEGERP (binding))
+ return XINT (binding);
+ else
+ {
+ AppleEvent apple_event;
+ static EventParamName names[] = {kEventParamDirectObject,
+ kEventParamKeyModifiers};
+ static EventParamType types[] = {typeHICommand,
+ typeUInt32};
+ err = create_apple_event_from_event_ref (event, 2, names, types,
+ &apple_event);
+ if (err == noErr)
+ {
+ err = mac_store_apple_event (class_key, id_key, &apple_event);
+ AEDisposeDesc (&apple_event);
+ }
+ if (err == noErr)
+ return noErr;
+ }
+ }
return eventNotHandledErr;
}
static OSErr
init_command_handler ()
{
- OSErr err = noErr;
EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}};
static EventHandlerUPP handle_command_eventUPP = NULL;
XSETINT (inev.x, mouse_loc.h);
XSETINT (inev.y, mouse_loc.v);
- if (dpyinfo->grabbed && tracked_scroll_bar
- || ch != 0
+ if ((dpyinfo->grabbed && tracked_scroll_bar)
+ || (ch != 0
#ifndef USE_TOOLKIT_SCROLL_BARS
- /* control_part_code becomes kControlNoPart if
- a progress indicator is clicked. */
- && control_part_code != kControlNoPart
+ /* control_part_code becomes kControlNoPart if
+ a progress indicator is clicked. */
+ && control_part_code != kControlNoPart
#else /* USE_TOOLKIT_SCROLL_BARS */
#ifdef MAC_OSX
- && control_kind.kind == kControlKindScrollBar
+ && control_kind.kind == kControlKindScrollBar
#endif /* MAC_OSX */
#endif /* USE_TOOLKIT_SCROLL_BARS */
- )
+ ))
{
struct scroll_bar *bar;
extern int inhibit_window_system;
extern int noninteractive;
CFBundleRef appsBundle;
- pid_t child;
/* No need to test if already -nw*/
if (inhibit_window_system || noninteractive)