}
else
{
- // Flip y coordinate as NS has y starting from the bottom.
+ /* Flip y coordinate as NS screen coordinates originate from
+ the bottom. */
y = (short) (primary_display_height - fr.size.height - fr.origin.y);
vy = (short) (primary_display_height -
vfr.size.height - vfr.origin.y);
m->geom.height = (unsigned short) fr.size.height;
m->work.x = (short) vfr.origin.x;
- // y is flipped on NS, so vy - y are pixels missing at the bottom,
- // and fr.size.height - vfr.size.height are pixels missing in total.
- // Pixels missing at top are
- // fr.size.height - vfr.size.height - vy + y.
- // work.y is then pixels missing at top + y.
+ /* y is flipped on NS, so vy - y are pixels missing at the
+ bottom, and fr.size.height - vfr.size.height are pixels
+ missing in total.
+
+ Pixels missing at top are fr.size.height - vfr.size.height -
+ vy + y. work.y is then pixels missing at top + y. */
m->work.y = (short) (fr.size.height - vfr.size.height) - vy + y + y;
m->work.width = (unsigned short) vfr.size.width;
m->work.height = (unsigned short) vfr.size.height;
}
#else
- // Assume 92 dpi as x-display-mm-height/x-display-mm-width does.
+ /* Assume 92 dpi as x-display-mm-height and x-display-mm-width
+ do. */
m->mm_width = (int) (25.4 * fr.size.width / 92.0);
m->mm_height = (int) (25.4 * fr.size.height / 92.0);
#endif
}
- // Primary monitor is always first for NS.
+ /* Primary monitor is always ordered first for NS. */
attributes_list = ns_make_monitor_attribute_list (monitors, n_monitors,
0, "NS");
static EmacsMenu *mainMenu;
#endif
+/* The last known monitor attributes list. */
+static Lisp_Object last_known_monitors;
+
/* ==========================================================================
NSTRACE, Trace support.
/* The following use "volatile" since they can be accessed from
parallel threads. */
-volatile int nstrace_num = 0;
-volatile int nstrace_depth = 0;
+volatile int nstrace_num;
+volatile int nstrace_depth;
/* When 0, no trace is emitted. This is used by NSTRACE_WHEN and
NSTRACE_UNLESS to silence functions called.
volatile int nstrace_enabled_global = 1;
/* Called when nstrace_enabled goes out of scope. */
-void nstrace_leave(int * pointer_to_nstrace_enabled)
+void
+nstrace_leave (int *pointer_to_nstrace_enabled)
{
if (*pointer_to_nstrace_enabled)
- {
- --nstrace_depth;
- }
+ --nstrace_depth;
}
/* Called when nstrace_saved_enabled_global goes out of scope. */
-void nstrace_restore_global_trace_state(int * pointer_to_saved_enabled_global)
+void
+nstrace_restore_global_trace_state (int *pointer_to_saved_enabled_global)
{
nstrace_enabled_global = *pointer_to_saved_enabled_global;
}
-char const * nstrace_fullscreen_type_name (int fs_type)
+const char *
+nstrace_fullscreen_type_name (int fs_type)
{
switch (fs_type)
{
- case -1: return "-1";
- case FULLSCREEN_NONE: return "FULLSCREEN_NONE";
- case FULLSCREEN_WIDTH: return "FULLSCREEN_WIDTH";
- case FULLSCREEN_HEIGHT: return "FULLSCREEN_HEIGHT";
- case FULLSCREEN_BOTH: return "FULLSCREEN_BOTH";
- case FULLSCREEN_MAXIMIZED: return "FULLSCREEN_MAXIMIZED";
- default: return "FULLSCREEN_?????";
+ case -1:
+ return "-1";
+ case FULLSCREEN_NONE:
+ return "FULLSCREEN_NONE";
+ case FULLSCREEN_WIDTH:
+ return "FULLSCREEN_WIDTH";
+ case FULLSCREEN_HEIGHT:
+ return "FULLSCREEN_HEIGHT";
+ case FULLSCREEN_BOTH:
+ return "FULLSCREEN_BOTH";
+ case FULLSCREEN_MAXIMIZED:
+ return "FULLSCREEN_MAXIMIZED";
+ default:
+ return "FULLSCREEN_?????";
}
}
#endif
{
struct input_event ie;
union buffered_input_event *ev;
+ Lisp_Object new_monitors;
EVENT_INIT (ie);
+ new_monitors = Fns_display_monitor_attributes_list (Qnil);
+
+ if (!NILP (Fequal (new_monitors, last_known_monitors)))
+ return;
+
+ last_known_monitors = new_monitors;
+
ev = (kbd_store_ptr == kbd_buffer
? kbd_buffer + KBD_BUFFER_SIZE - 1
: kbd_store_ptr - 1);
CGDisplayRegisterReconfigurationCallback (ns_displays_reconfigured,
NULL);
#endif
+ last_known_monitors = Fns_display_monitor_attributes_list (Qnil);
NSTRACE_MSG ("ns_term_init done");
- (id)init
{
+#ifdef NS_IMPL_GNUSTEP
+ NSNotificationCenter *notification_center;
+#endif
+
NSTRACE ("[EmacsApp init]");
if ((self = [super init]))
#endif
}
+#ifdef NS_IMPL_GNUSTEP
+ notification_center = [NSNotificationCenter defaultCenter];
+ [notification_center addObserver: self
+ selector: @selector(updateMonitors:)
+ name: NSApplicationDidChangeScreenParametersNotification
+ object: nil];
+#endif
+
return self;
}
#define NSAppKitVersionNumber10_9 1265
#endif
- if ((int)NSAppKitVersionNumber != NSAppKitVersionNumber10_9)
- {
- [super run];
- return;
- }
+ if ((int) NSAppKitVersionNumber != NSAppKitVersionNumber10_9)
+ {
+ [super run];
+ return;
+ }
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
return YES;
}
+#ifdef NS_IMPL_GNUSTEP
+- (void) updateMonitors: (NSNotification *) notification
+{
+ struct input_event ie;
+ union buffered_input_event *ev;
+ Lisp_Object new_monitors;
+
+ EVENT_INIT (ie);
+
+ new_monitors = Fns_display_monitor_attributes_list (Qnil);
+
+ if (!NILP (Fequal (new_monitors, last_known_monitors)))
+ return;
+
+ last_known_monitors = new_monitors;
+
+ ev = (kbd_store_ptr == kbd_buffer
+ ? kbd_buffer + KBD_BUFFER_SIZE - 1
+ : kbd_store_ptr - 1);
+
+ if (kbd_store_ptr != kbd_fetch_ptr
+ && ev->ie.kind == MONITORS_CHANGED_EVENT)
+ return;
+
+ ie.kind = MONITORS_CHANGED_EVENT;
+ XSETTERMINAL (ie.arg, x_display_list->terminal);
+
+ kbd_buffer_store_event (&ie);
+}
+#endif
/* **************************************************************************
syms_of_nsfont ();
#endif
+ last_known_monitors = Qnil;
+ staticpro (&last_known_monitors);
}