/* NeXT/Open/GNUstep / MacOSX communication module.
-Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2012
- Free Software Foundation, Inc.
+Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2013 Free Software
+Foundation, Inc.
This file is part of GNU Emacs.
#include "ccl.h"
#include "termhooks.h"
-#include "termopts.h"
#include "termchar.h"
#include "window.h"
/* event loop */
static BOOL send_appdefined = YES;
-static NSEvent *last_appdefined_event = 0;
+#define NO_APPDEFINED_DATA (-8)
+static int last_appdefined_event_data = NO_APPDEFINED_DATA;
static NSTimer *timed_entry = 0;
static NSTimer *scroll_repeat_entry = nil;
static fd_set select_readfds, select_writefds;
*ns_pending_service_args;
static BOOL ns_do_open_file = NO;
+static struct {
+ struct input_event *q;
+ int nr, cap;
+} hold_event_q = {
+ NULL, 0, 0
+};
+
/* Convert modifiers in a NeXTstep event to emacs style modifiers. */
#define NS_FUNCTION_KEY_MASK 0x800000
#define NSLeftControlKeyMask (0x000001 | NSControlKeyMask)
kbd_buffer_store_event_hold (emacs_event, q_event_ptr); \
} \
else \
- kbd_buffer_store_event (emacs_event); \
+ hold_event (emacs_event); \
EVENT_INIT (*emacs_event); \
ns_send_appdefined (-1); \
}
========================================================================== */
+static void
+hold_event (struct input_event *event)
+{
+ if (hold_event_q.nr == hold_event_q.cap)
+ {
+ if (hold_event_q.cap == 0) hold_event_q.cap = 10;
+ else hold_event_q.cap *= 2;
+ hold_event_q.q = (struct input_event *)
+ xrealloc (hold_event_q.q, hold_event_q.cap * sizeof (*hold_event_q.q));
+ }
+
+ hold_event_q.q[hold_event_q.nr++] = *event;
+ /* Make sure ns_read_socket is called, i.e. we have input. */
+ kill (0, SIGIO);
+ send_appdefined = YES;
+}
static Lisp_Object
append2 (Lisp_Object list, Lisp_Object item)
ns_fullscreen_hook (FRAME_PTR f)
{
EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
-
+
if (! f->async_visible) return;
#ifndef NEW_STYLE_FS
if (f->want_fullscreen == FULLSCREEN_BOTH)
Draw a wavy line under glyph string s. The wave fills wave_height
pixels from y.
- x wave_length = 3
+ x wave_length = 2
--
y * * * * *
|* * * * * * * * *
static void
ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x)
{
- int wave_height = 3, wave_length = 3;
+ int wave_height = 3, wave_length = 2;
int y, dx, dy, odd, xmax;
NSPoint a, b;
NSRect waveClip;
dx = wave_length;
dy = wave_height - 1;
- y = s->ybase + 1;
+ y = s->ybase - wave_height + 3;
xmax = x + width;
/* Find and set clipping rectangle */
NSRectClip (waveClip);
/* Draw the waves */
- a.x = x - ((int)(x) % dx);
+ a.x = x - ((int)(x) % dx) + 0.5;
b.x = a.x + dx;
odd = (int)(a.x/dx) % 2;
- a.y = b.y = y;
+ a.y = b.y = y + 0.5;
if (odd)
a.y += dy;
{
[NSBezierPath strokeLineFromPoint:a toPoint:b];
a.x = b.x, a.y = b.y;
- b.x += dx, b.y = y + odd*dy;
+ b.x += dx, b.y = y + 0.5 + odd*dy;
odd = !odd;
}
/* If the prev was underlined, match its appearance. */
if (s->prev && s->prev->face->underline_p
+ && s->prev->face->underline_type == FACE_UNDER_LINE
&& s->prev->underline_thickness > 0)
{
thickness = s->prev->underline_thickness;
if ([NSApp modalWindow] != nil)
return -1;
+ if (hold_event_q.nr > 0)
+ {
+ int i;
+ for (i = 0; i < hold_event_q.nr; ++i)
+ kbd_buffer_store_event_hold (&hold_event_q.q[i], hold_quit);
+ hold_event_q.nr = 0;
+ return i;
+ }
+
block_input ();
n_emacs_events_pending = 0;
EVENT_INIT (ev);
-------------------------------------------------------------------------- */
{
int result;
- NSEvent *ev;
- int k, nr = 0;
+ int t, k, nr = 0;
struct input_event event;
char c;
/* NSTRACE (ns_select); */
- for (k = 0; readfds && k < nfds+1; k++)
- if (FD_ISSET(k, readfds)) ++nr;
+ if (hold_event_q.nr > 0)
+ {
+ /* We already have events pending. */
+ kill (0, SIGIO);
+ errno = EINTR;
+ return -1;
+ }
+
+ for (k = 0; k < nfds+1; k++)
+ {
+ if (readfds && FD_ISSET(k, readfds)) ++nr;
+ if (writefds && FD_ISSET(k, writefds)) ++nr;
+ }
if (NSApp == nil
|| (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0))
}
unblock_input ();
- ev = last_appdefined_event;
+ t = last_appdefined_event_data;
- if (ev)
+ if (t != NO_APPDEFINED_DATA)
{
- int t;
- if ([ev type] != NSApplicationDefined)
- emacs_abort ();
-
- t = [ev data1];
- last_appdefined_event = 0;
+ last_appdefined_event_data = NO_APPDEFINED_DATA;
if (t == -2)
{
modal loop. Just defer it until later. */
if ([NSApp modalWindow] == nil)
{
- last_appdefined_event = theEvent;
+ last_appdefined_event_data = [theEvent data1];
[self stop: self];
}
else
if (waiting)
{
SELECT_TYPE fds;
-
+ FD_ZERO (&fds);
FD_SET (selfds[0], &fds);
result = select (selfds[0]+1, &fds, NULL, NULL, NULL);
if (result > 0)
[w setBackgroundColor: col];
if ([col alphaComponent] != 1.0)
[w setOpaque: NO];
-
+
f->border_width = bwidth;
FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height;
FRAME_TOOLBAR_HEIGHT (f) = tobar_height;
}
break;
}
-
+
emacsframe->want_fullscreen = FULLSCREEN_NONE;
}
[self setFloatValue: pos knobProportion: por];
#endif
}
+
+ /* Events may come here even if the event loop is not running.
+ If we don't enter the event loop, the scroll bar will not update.
+ So send SIGIO to ourselves. */
+ if (apploopnr == 0) kill (0, SIGIO);
+
return self;
}
kbd_buffer_store_event_hold (emacs_event, q_event_ptr);
}
else
- kbd_buffer_store_event (emacs_event);
+ hold_event (emacs_event);
EVENT_INIT (*emacs_event);
ns_send_appdefined (-1);
}