+ else
+ {
+ /* Even if not deactivating the mark, set PRIMARY if
+ `select-active-regions' is non-nil. */
+ if (!NILP (Fwindow_system (Qnil))
+ /* Even if mark_active is non-nil, the actual buffer
+ marker may not have been set yet (Bug#7044). */
+ && XMARKER (BVAR (current_buffer, mark))->buffer
+ && (EQ (Vselect_active_regions, Qonly)
+ ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
+ : (!NILP (Vselect_active_regions)
+ && !NILP (Vtransient_mark_mode)))
+ && !EQ (Vthis_command, Qhandle_switch_frame))
+ {
+ EMACS_INT beg =
+ XINT (Fmarker_position (BVAR (current_buffer, mark)));
+ EMACS_INT end = PT;
+ if (beg < end)
+ call2 (Qx_set_selection, QPRIMARY,
+ make_buffer_string (beg, end, 0));
+ else if (beg > end)
+ call2 (Qx_set_selection, QPRIMARY,
+ make_buffer_string (end, beg, 0));
+ /* Don't set empty selections. */
+ }
+
+ if (current_buffer != prev_buffer || MODIFF != prev_modiff)
+ call1 (Vrun_hooks, intern ("activate-mark-hook"));
+ }
+
+ Vsaved_region_selection = Qnil;