diff --git a/src/ChangeLog b/src/ChangeLog index acbbfb0a50cfdf44d2e1d50bdad995c4708abe77..5bcdb7ed068de1c573c622da064d02b8f4ec935d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,29 @@ +2013-05-25 Jan Djärv + + * 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 * callproc.c (call_process): Refine the doc string. (Bug#14045) diff --git a/src/frame.c b/src/frame.c index ccd50122f509f15e4cf8223cadc8e05f13f8dced..e88432b98022713de9a938f73814cdedfb2e2deb 100644 --- a/src/frame.c +++ b/src/frame.c @@ -76,7 +76,6 @@ Lisp_Object Qterminal_live_p; 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; @@ -115,6 +114,8 @@ Lisp_Object Qface_set_after_frame_default; 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 @@ -4129,6 +4130,73 @@ selected frame. This is useful when `make-pointer-invisible' is set. */) return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt; } + + +/*********************************************************************** + 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 */ + /*********************************************************************** Initialization @@ -4187,6 +4255,12 @@ syms_of_frame (void) 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 diff --git a/src/frame.h b/src/frame.h index fc0a1dc828bd29657f8b1d06dec7c62820960686..12aa48b2d92ed8161af74e4f349ba21129c0f4e0 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1198,6 +1198,8 @@ extern Lisp_Object Qdisplay; 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. */ @@ -1288,6 +1290,28 @@ extern void x_query_colors (struct frame *f, XColor *, int); extern void x_query_color (struct frame *f, XColor *); #endif /* HAVE_WINDOW_SYSTEM */ + +/*********************************************************************** + 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 diff --git a/src/nsfns.m b/src/nsfns.m index 7643c8b6e1df24e81e80c4793c88de482f63a39b..1170472573e63bc80e9b5fb35d40b0975e9ae784 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -105,7 +105,6 @@ Updated by Christian Limpach (chris@nice.ch) static ptrdiff_t image_cache_refcount; #endif -static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; /* ========================================================================== @@ -2328,27 +2327,12 @@ and GNUstep implementations ("distributor-specific release 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; @@ -2377,8 +2361,7 @@ and GNUstep implementations ("distributor-specific release 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; @@ -2404,41 +2387,8 @@ and GNUstep implementations ("distributor-specific release } } - 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", @@ -2922,11 +2872,6 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename 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); diff --git a/src/xfns.c b/src/xfns.c index af29c5bdc3f5f5f95b2ee8e678dab94b261a6788..a1c709a6c26eddd5c1d40da17e720b403c309dfe 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -133,7 +133,6 @@ extern LWLIB_ID widget_id_tick; 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 @@ -3882,24 +3881,6 @@ x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect) #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, @@ -3971,9 +3952,7 @@ x_make_monitor_attribute_list (struct MonitorInfo *monitors, 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) { @@ -3982,46 +3961,13 @@ x_make_monitor_attribute_list (struct MonitorInfo *monitors, 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 @@ -4270,9 +4216,9 @@ Internal use only, use `display-monitor-attributes-list' instead. */) 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) @@ -4286,6 +4232,8 @@ Internal use only, use `display-monitor-attributes-list' instead. */) #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); @@ -4300,21 +4248,13 @@ Internal use only, use `display-monitor-attributes-list' instead. */) } } - 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); @@ -4324,54 +4264,50 @@ Internal use only, use `display-monitor-attributes-list' instead. */) 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 */ @@ -6294,11 +6230,6 @@ syms_of_xfns (void) 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. */