Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAdam committed Oct 22, 2023
1 parent 3335000 commit 95b6d8c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
55 changes: 52 additions & 3 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ static bool randr_initialised;

static void scan_screens(Display *);
static struct monitor *monitor_by_name(const char *);
static void monitor_set_ordering(void);

enum monitor_tracking monitor_mode;
bool is_tracking_shared;
struct screen_infos screen_info_q;
struct screen_infos screen_info_q, screen_info_q_temp;
struct monitors monitor_q;
int randr_event;
const char *prev_focused_monitor;
Expand Down Expand Up @@ -473,7 +474,22 @@ scan_screens(Display *dpy)
memset(&m->virtual_scr, 0, sizeof(m->virtual_scr));

TAILQ_INSERT_TAIL(&screen_info_q, m->si, entry);
TAILQ_INSERT_TAIL(&monitor_q, m, entry);

if (TAILQ_EMPTY(&monitor_q))
TAILQ_INSERT_HEAD(&monitor_q, m, entry);

struct monitor *m2;
TAILQ_FOREACH(m2, &monitor_q, entry) {
if (m == m2)
continue;
fvwm_debug(__func__, "LOOKING AT: %s (%d), WANT: %s (%d)",
m2->si->name, m2->si->x, m->si->name, rrm[i].x);
if (rrm[i].x < m2->si->x) {
fvwm_debug(__func__, "INSERTING: %s",
m->si->name);
TAILQ_INSERT_HEAD(&monitor_q, m, entry);
}
}

goto set_coords;
}
Expand Down Expand Up @@ -504,9 +520,42 @@ scan_screens(Display *dpy)

monitor_scan_edges(m);
monitor_check_primary();
monitor_set_ordering();
XRRFreeMonitors(rrm);
}

static void
monitor_set_ordering(void)
{
#if 0
struct screen_info *si, *si_next;

if (TAILQ_EMPTY(&screen_info_q_temp))
TAILQ_INIT(&screen_info_q_temp);

TAILQ_FOREACH(si, &screen_info_q, entry) {
if ((si_next = TAILQ_NEXT(si, entry)) != NULL) {
fvwm_debug(__func__, "SEEING: %s (%d), NEXT: %s (%d)", si->name, si->x, si_next->name, si_next->x);
if (si->x > si_next->x) {
TAILQ_INSERT_TAIL(&screen_info_q_temp, si, entry);
} else {

TAILQ_INSERT_HEAD(&screen_info_q_temp, si_next, entry);
}
}
}

TAILQ_FOREACH(si, &screen_info_q_temp, entry) {
fvwm_debug(__func__, "NEW: %s", si->name);
}
#endif
struct monitor *m;

TAILQ_FOREACH(m, &monitor_q, entry) {
fvwm_debug(__func__, "MON IS: %s (%d)", m->si->name, m->si->x);
}
}

void FScreenInit(Display *dpy)
{
XRRScreenResources *res = NULL;
Expand Down Expand Up @@ -1271,4 +1320,4 @@ int FScreenFetchMangledScreenFromUSPosHints(XSizeHints *hints)
screen = 0;

return screen;
}
}
4 changes: 2 additions & 2 deletions libs/FScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct screen_info {
};
TAILQ_HEAD(screen_infos, screen_info);

extern struct screen_infos screen_info_q;
extern struct screen_infos screen_info_q, screen_info_q_temp;

struct screen_info *screen_info_new(void);
struct screen_info *screen_info_by_name(const char *);
Expand Down Expand Up @@ -205,4 +205,4 @@ int FScreenGetGeometry(
void FScreenMangleScreenIntoUSPosHints(fscreen_scr_t screen, XSizeHints *hints);
int FScreenFetchMangledScreenFromUSPosHints(XSizeHints *hints);

#endif /* FVWMLIB_FSCRREN_H */
#endif /* FVWMLIB_FSCRREN_H */
2 changes: 1 addition & 1 deletion libs/safemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ xvasprintf(char **ret, const char *fmt, va_list ap)
}

return (i);
}
}
2 changes: 1 addition & 1 deletion libs/safemalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ char *fxstrdup(const char *);
int xasprintf(char **, const char *, ...);
int xvasprintf(char **, const char *, va_list);

#endif
#endif

0 comments on commit 95b6d8c

Please sign in to comment.