+/* use the following priority lists for choose_monitor()
+
+ When a window is being placed in the FOREGROUND, use a monitor chosen in
+ the following order:
+ 1. per-app settings
+ 2. same monitor as parent
+ 3. primary monitor if placement=PRIMARY
+ active monitor if placement=ACTIVE
+ pointer monitor if placement=MOUSE
+ 4. primary monitor
+ 5. other monitors where the window has group members on the same desktop
+ 6. other monitors where the window has group members on other desktops
+ 7. other monitors
+
+ When a window is being placed in the BACKGROUND, use a monitor chosen in the
+ following order:
+ 1. per-app settings
+ 2. same monitor as parent
+ 3. other monitors where the window has group members on the same desktop
+ 3a. primary monitor in this set
+ 3b. other monitors in this set
+ 4. other monitors where the window has group members on other desktops
+ 4a. primary monitor in this set
+ 4b. other monitors in this set
+ 5. other monitors
+ 5a. primary monitor in this set
+ 5b. other monitors in this set
+*/
+
+/*! One for each possible head, used to sort them in order of precedence. */
+typedef struct {
+ guint monitor;
+ guint flags;
+} ObPlaceHead;
+
+/*! Flags for ObPlaceHead */
+enum {
+ HEAD_PARENT = 1 << 0, /* parent's monitor */
+ HEAD_PLACED = 1 << 1, /* chosen monitor by placement */
+ HEAD_PRIMARY = 1 << 2, /* primary monitor */
+ HEAD_GROUP_DESK = 1 << 3, /* has a group member on the same desktop */
+ HEAD_GROUP = 1 << 4, /* has a group member on another desktop */
+ HEAD_PERAPP = 1 << 5, /* chosen by per-app settings */
+};
+
+gint cmp_foreground(const void *a, const void *b)