+2013-05-25 Jan Djärv <jan.h.d@swipnet.se>
+
+ * xfns.c (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): Remove.
+ (struct MonitorInfo, free_monitors): Remove.
+ (x_make_monitor_attribute_list): Call make_monitor_attribute_list.
+ (Fx_display_monitor_attributes_list): Call make_monitor_attribute_list.
+ (syms_of_xfns): Remove DEFSYM for Qgeometry, Qworkarea, Qmm_size,
+ Qframes, Qsource.
+
+ * nsfns.m (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): Remove.
+ (struct MonitorInfo, free_monitors): Remove.
+ (ns_screen_name): Make static.
+ (ns_make_monitor_attribute_list): Call make_monitor_attribute_list.
+ (syms_of_nsfns): Remove DEFSYM for Qgeometry, Qworkarea, Qmm_size,
+ Qframes, Qsource.
+
+ * frame.h (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): Declare.
+ (struct MonitorInfo): New struct.
+ (free_monitors, make_monitor_attribute_list): Declare.
+
+ * frame.c (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): New
+ Lisp_Object:s.
+ (free_monitors, make_monitor_attribute_list): New functions.
+ (syms_of_frame): DEFSYM Qgeometry, Qworkarea, Qmm_size, Qframes,
+ Qsource.
+
2013-05-25 Xue Fuqiao <xfq.free@gmail.com>
* callproc.c (call_process): Refine the doc string. (Bug#14045)
Lisp_Object Qauto_raise, Qauto_lower;
Lisp_Object Qborder_color, Qborder_width;
Lisp_Object Qcursor_color, Qcursor_type;
-static Lisp_Object Qgeometry; /* Not used */
Lisp_Object Qheight, Qwidth;
Lisp_Object Qleft, Qright;
Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name;
static Lisp_Object Qdelete_frame_functions;
+Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource;
+
#ifdef HAVE_WINDOW_SYSTEM
static void x_report_frame_params (struct frame *, Lisp_Object *);
#endif
return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt;
}
+
+\f
+/***********************************************************************
+ Multimonitor data
+ ***********************************************************************/
+
+#ifdef HAVE_WINDOW_SYSTEM
+
+void
+free_monitors (struct MonitorInfo *monitors, int n_monitors)
+{
+ int i;
+ for (i = 0; i < n_monitors; ++i)
+ xfree (monitors[i].name);
+ xfree (monitors);
+}
+
+Lisp_Object
+make_monitor_attribute_list (struct MonitorInfo *monitors,
+ int n_monitors,
+ int primary_monitor,
+ Lisp_Object monitor_frames,
+ const char *source)
+{
+ Lisp_Object attributes_list = Qnil;
+ Lisp_Object primary_monitor_attributes = Qnil;
+ int i;
+
+ for (i = 0; i < n_monitors; ++i)
+ {
+ Lisp_Object geometry, workarea, attributes = Qnil;
+ struct MonitorInfo *mi = &monitors[i];
+
+ if (mi->geom.width == 0) continue;
+
+ workarea = list4i (mi->work.x, mi->work.y,
+ mi->work.width, mi->work.height);
+ geometry = list4i (mi->geom.x, mi->geom.y,
+ mi->geom.width, mi->geom.height);
+ attributes = Fcons (Fcons (Qsource,
+ make_string (source, strlen (source))),
+ attributes);
+ attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
+ attributes);
+ attributes = Fcons (Fcons (Qmm_size,
+ list2i (mi->mm_width, mi->mm_height)),
+ attributes);
+ attributes = Fcons (Fcons (Qworkarea, workarea), attributes);
+ attributes = Fcons (Fcons (Qgeometry, geometry), attributes);
+ if (mi->name)
+ attributes = Fcons (Fcons (Qname, make_string (mi->name,
+ strlen (mi->name))),
+ attributes);
+
+ if (i == primary_monitor)
+ primary_monitor_attributes = attributes;
+ else
+ attributes_list = Fcons (attributes, attributes_list);
+ }
+
+ if (!NILP (primary_monitor_attributes))
+ attributes_list = Fcons (primary_monitor_attributes, attributes_list);
+ return attributes_list;
+}
+
+#endif /* HAVE_WINDOW_SYSTEM */
+
\f
/***********************************************************************
Initialization
DEFSYM (Qterminal, "terminal");
DEFSYM (Qterminal_live_p, "terminal-live-p");
+ DEFSYM (Qgeometry, "geometry");
+ DEFSYM (Qworkarea, "workarea");
+ DEFSYM (Qmm_size, "mm-size");
+ DEFSYM (Qframes, "frames");
+ DEFSYM (Qsource, "source");
+
#ifdef HAVE_NS
DEFSYM (Qns_parse_geometry, "ns-parse-geometry");
#endif
extern Lisp_Object Qrun_hook_with_args;
+extern Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource;
+
#ifdef HAVE_WINDOW_SYSTEM
/* The class of this X application. */
extern void x_query_color (struct frame *f, XColor *);
#endif /* HAVE_WINDOW_SYSTEM */
+\f
+/***********************************************************************
+ Multimonitor data
+ ***********************************************************************/
+
+#ifdef HAVE_WINDOW_SYSTEM
+
+struct MonitorInfo {
+ XRectangle geom, work;
+ int mm_width, mm_height;
+ char *name;
+};
+
+extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
+extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
+ int n_monitors,
+ int primary_monitor,
+ Lisp_Object monitor_frames,
+ const char *source);
+
+#endif /* HAVE_WINDOW_SYSTEM */
+
INLINE_HEADER_END
static ptrdiff_t image_cache_refcount;
#endif
-static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource;
/* ==========================================================================
return make_number (x_display_pixel_height (dpyinfo));
}
-struct MonitorInfo {
- XRectangle geom, work;
- int mm_width, mm_height;
- char *name;
-};
-
-static void
-free_monitors (struct MonitorInfo *monitors, int n_monitors)
-{
- int i;
- for (i = 0; i < n_monitors; ++i)
- xfree (monitors[i].name);
- xfree (monitors);
-}
-
#ifdef NS_IMPL_COCOA
/* Returns the name for the screen that DICT came from, or NULL.
Caller must free return value.
*/
-char *
+static char *
ns_screen_name (CGDirectDisplayID did)
{
char *name = NULL;
const char *source)
{
Lisp_Object monitor_frames = Fmake_vector (make_number (n_monitors), Qnil);
- Lisp_Object frame, rest, attributes_list = Qnil;
- Lisp_Object primary_monitor_attributes = Qnil;
+ Lisp_Object frame, rest;
NSArray *screens = [NSScreen screens];
int i;
}
}
- for (i = 0; i < n_monitors; ++i)
- {
- Lisp_Object geometry, workarea, attributes = Qnil;
- struct MonitorInfo *mi = &monitors[i];
-
- if (mi->geom.width == 0) continue;
-
- workarea = list4i (mi->work.x, mi->work.y,
- mi->work.width, mi->work.height);
- geometry = list4i (mi->geom.x, mi->geom.y,
- mi->geom.width, mi->geom.height);
- attributes = Fcons (Fcons (Qsource,
- make_string (source, strlen (source))),
- attributes);
- attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
- attributes);
- attributes = Fcons (Fcons (Qmm_size,
- list2i (mi->mm_width, mi->mm_height)),
- attributes);
- attributes = Fcons (Fcons (Qworkarea, workarea), attributes);
- attributes = Fcons (Fcons (Qgeometry, geometry), attributes);
- if (mi->name)
- attributes = Fcons (Fcons (Qname, make_string (mi->name,
- strlen (mi->name))),
- attributes);
-
- if (i == primary_monitor)
- primary_monitor_attributes = attributes;
- else
- attributes_list = Fcons (attributes, attributes_list);
- }
-
- if (!NILP (primary_monitor_attributes))
- attributes_list = Fcons (primary_monitor_attributes, attributes_list);
- return attributes_list;
+ return make_monitor_attribute_list (monitors, n_monitors, primary_monitor,
+ monitor_frames, source);
}
DEFUN ("ns-display-monitor-attributes-list",
void
syms_of_nsfns (void)
{
- DEFSYM (Qgeometry, "geometry");
- DEFSYM (Qworkarea, "workarea");
- DEFSYM (Qmm_size, "mm-size");
- DEFSYM (Qframes, "frames");
- DEFSYM (Qsource, "source");
Qfontsize = intern_c_string ("fontsize");
staticpro (&Qfontsize);
static Lisp_Object Qsuppress_icon;
static Lisp_Object Qundefined_color;
static Lisp_Object Qcompound_text, Qcancel_timer;
-static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource;
Lisp_Object Qfont_param;
#ifdef GLYPH_DEBUG
#ifndef USE_GTK
-struct MonitorInfo {
- XRectangle geom, work;
- int mm_width, mm_height;
- char *name;
-};
-
-#if defined HAVE_XINERAMA || defined HAVE_XRANDR
-static void
-free_monitors (struct MonitorInfo *monitors, int n_monitors)
-{
- int i;
- for (i = 0; i < n_monitors; ++i)
- xfree (monitors[i].name);
- xfree (monitors);
-}
-#endif /* HAVE_XINERAMA || HAVE_XRANDR */
-
-
/* Return monitor number where F is "most" or closest to. */
static int
x_get_monitor_for_frame (struct frame *f,
const char *source)
{
Lisp_Object monitor_frames = Fmake_vector (make_number (n_monitors), Qnil);
- Lisp_Object frame, rest, attributes_list = Qnil;
- Lisp_Object primary_monitor_attributes = Qnil;
- int i;
+ Lisp_Object frame, rest;
FOR_EACH_FRAME (rest, frame)
{
if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo
&& !EQ (frame, tip_frame))
{
- i = x_get_monitor_for_frame (f, monitors, n_monitors);
+ int i = x_get_monitor_for_frame (f, monitors, n_monitors);
ASET (monitor_frames, i, Fcons (frame, AREF (monitor_frames, i)));
}
}
- for (i = 0; i < n_monitors; ++i)
- {
- Lisp_Object geometry, workarea, attributes = Qnil;
- struct MonitorInfo *mi = &monitors[i];
-
- if (mi->geom.width == 0) continue;
-
- workarea = list4i (mi->work.x, mi->work.y,
- mi->work.width, mi->work.height);
- geometry = list4i (mi->geom.x, mi->geom.y,
- mi->geom.width, mi->geom.height);
- attributes = Fcons (Fcons (Qsource,
- make_string (source, strlen (source))),
- attributes);
- attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
- attributes);
- attributes = Fcons (Fcons (Qmm_size,
- list2i (mi->mm_width, mi->mm_height)),
- attributes);
- attributes = Fcons (Fcons (Qworkarea, workarea), attributes);
- attributes = Fcons (Fcons (Qgeometry, geometry), attributes);
- if (mi->name)
- attributes = Fcons (Fcons (Qname, make_string (mi->name,
- strlen (mi->name))),
- attributes);
-
- if (i == primary_monitor)
- primary_monitor_attributes = attributes;
- else
- attributes_list = Fcons (attributes, attributes_list);
- }
-
- if (!NILP (primary_monitor_attributes))
- attributes_list = Fcons (primary_monitor_attributes, attributes_list);
- return attributes_list;
+ return make_monitor_attribute_list (monitors, n_monitors, primary_monitor,
+ monitor_frames, source);
}
static Lisp_Object
GdkDisplay *gdpy;
GdkScreen *gscreen;
gint primary_monitor = 0, n_monitors, i;
- Lisp_Object primary_monitor_attributes = Qnil;
Lisp_Object monitor_frames, rest, frame;
static const char *source = "Gdk";
+ struct MonitorInfo *monitors;
block_input ();
mm_width_per_pixel = ((double) WidthMMOfScreen (dpyinfo->screen)
#endif
n_monitors = gdk_screen_get_n_monitors (gscreen);
monitor_frames = Fmake_vector (make_number (n_monitors), Qnil);
+ monitors = (struct MonitorInfo *) xzalloc (n_monitors * sizeof (*monitors));
+
FOR_EACH_FRAME (rest, frame)
{
struct frame *f = XFRAME (frame);
}
}
- i = n_monitors;
- while (i-- > 0)
+ for (i = 0; i < n_monitors; ++i)
{
- Lisp_Object geometry, workarea, attributes = Qnil;
gint width_mm = -1, height_mm = -1;
- GdkRectangle rec;
-
- attributes = Fcons (Fcons (Qsource,
- make_string (source, strlen (source))),
- attributes);
- attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
- attributes);
+ GdkRectangle rec, work;
+ struct MonitorInfo *mi = &monitors[i];
gdk_screen_get_monitor_geometry (gscreen, i, &rec);
- geometry = list4i (rec.x, rec.y, rec.width, rec.height);
#if GTK_CHECK_VERSION (2, 14, 0)
width_mm = gdk_screen_get_monitor_width_mm (gscreen, i);
width_mm = rec.width * mm_width_per_pixel + 0.5;
if (height_mm < 0)
height_mm = rec.height * mm_height_per_pixel + 0.5;
- attributes = Fcons (Fcons (Qmm_size,
- list2i (width_mm, height_mm)),
- attributes);
#if GTK_CHECK_VERSION (3, 4, 0)
- gdk_screen_get_monitor_workarea (gscreen, i, &rec);
- workarea = list4i (rec.x, rec.y, rec.width, rec.height);
+ gdk_screen_get_monitor_workarea (gscreen, i, &work);
#else
/* Emulate the behavior of GTK+ 3.4. */
{
XRectangle workarea_r;
- workarea = Qnil;
if (i == primary_monitor && x_get_net_workarea (dpyinfo, &workarea_r))
{
- GdkRectangle work;
-
work.x = workarea_r.x;
work.y = workarea_r.y;
work.width = workarea_r.width;
work.height = workarea_r.height;
- if (gdk_rectangle_intersect (&rec, &work, &work))
- workarea = list4i (work.x, work.y, work.width, work.height);
- }
- if (NILP (workarea))
- workarea = geometry;
+ if (! gdk_rectangle_intersect (&rec, &work, &work))
+ work = rec;
+ }
+ else
+ work = rec;
}
#endif
- attributes = Fcons (Fcons (Qworkarea, workarea), attributes);
- attributes = Fcons (Fcons (Qgeometry, geometry), attributes);
+
+ mi->geom.x = rec.x;
+ mi->geom.y = rec.y;
+ mi->geom.width = rec.width;
+ mi->geom.height = rec.height;
+ mi->work.x = work.x;
+ mi->work.y = work.y;
+ mi->work.width = work.width;
+ mi->work.height = work.height;
+ mi->mm_width = width_mm;
+ mi->mm_height = height_mm;
+
#if GTK_CHECK_VERSION (2, 14, 0)
- {
- char *name = gdk_screen_get_monitor_plug_name (gscreen, i);
- if (name)
- attributes = Fcons (Fcons (Qname, make_string (name, strlen (name))),
- attributes);
- }
+ mi->name = gdk_screen_get_monitor_plug_name (gscreen, i);
#endif
-
- if (i == primary_monitor)
- primary_monitor_attributes = attributes;
- else
- attributes_list = Fcons (attributes, attributes_list);
}
- if (!NILP (primary_monitor_attributes))
- attributes_list = Fcons (primary_monitor_attributes, attributes_list);
+ attributes_list = make_monitor_attribute_list (monitors,
+ n_monitors,
+ primary_monitor,
+ monitor_frames,
+ source);
unblock_input ();
#else /* not USE_GTK */
DEFSYM (Qundefined_color, "undefined-color");
DEFSYM (Qcompound_text, "compound-text");
DEFSYM (Qcancel_timer, "cancel-timer");
- DEFSYM (Qgeometry, "geometry");
- DEFSYM (Qworkarea, "workarea");
- DEFSYM (Qmm_size, "mm-size");
- DEFSYM (Qframes, "frames");
- DEFSYM (Qsource, "source");
DEFSYM (Qfont_param, "font-parameter");
/* This is the end of symbol initialization. */