Skip to content

Commit

Permalink
randr: assign one output as primary
Browse files Browse the repository at this point in the history
RandR doesn't guarantee that there is always one monitor marked as
primary.  Certain operations in FVWM expect this, therefore if a primary
monitor hasn't been set, assign the first monitor found as a default.

Helps address #78
  • Loading branch information
ThomasAdam committed May 22, 2020
1 parent d9e5b8f commit b6d6265
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static bool is_randr_present;
static struct monitor *monitor_new(void);
static void monitor_set_flags(struct monitor *);
static void scan_screens(Display *);
static void monitor_check_primary(void);

static void GetMouseXY(XEvent *eventp, int *x, int *y)
{
Expand Down Expand Up @@ -198,6 +199,12 @@ monitor_by_primary(void)
return (m);
}

static void
monitor_check_primary(void)
{
if (monitor_by_primary() == NULL)
TAILQ_FIRST(&monitor_q)->si->is_primary = 1;
}

int
monitor_get_all_widths(void)
Expand Down Expand Up @@ -285,6 +292,8 @@ monitor_output_change(Display *dpy, XRRScreenChangeNotifyEvent *e)
TAILQ_FOREACH(m, &monitor_q, entry)
monitor_set_flags(m);

monitor_check_primary();

}

static void
Expand Down Expand Up @@ -331,6 +340,8 @@ scan_screens(Display *dpy)
m->virtual_scr.MyDisplayHeight = monitor_get_all_heights();

}

monitor_check_primary();
}

void FScreenInit(Display *dpy)
Expand Down Expand Up @@ -392,6 +403,8 @@ void FScreenInit(Display *dpy)
monitor_set_flags(m);
}

monitor_check_primary();

return;

single_screen:
Expand Down

0 comments on commit b6d6265

Please sign in to comment.