[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] [PATCH 7/7] Select xrandr primary screen at startup if possible
From: |
Mathieu OTHACEHE |
Subject: |
[RP] [PATCH 7/7] Select xrandr primary screen at startup if possible |
Date: |
Wed, 7 Dec 2016 10:03:58 +0100 |
If xrandr support is enabled and a screen is marked primary, use it as
current screen at startup.
Otherwise, use the first screen in sorted screen list as current screen
at startup.
---
src/main.c | 7 -------
src/screen.c | 27 +++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/src/main.c b/src/main.c
index cce4f94..76af702 100644
--- a/src/main.c
+++ b/src/main.c
@@ -589,7 +589,6 @@ main (int argc, char *argv[])
int c;
char **cmd = NULL;
int cmd_count = 0;
- rp_screen *cur;
char *display = NULL;
unsigned char interactive = 0;
char *alt_rcfile = NULL;
@@ -739,12 +738,6 @@ main (int argc, char *argv[])
initialize_default_keybindings ();
history_load ();
- list_for_each_entry (cur, &rp_screens, node)
- {
- if (!rp_current_screen)
- rp_current_screen = cur;
- }
-
scanwins ();
if (read_startup_files (alt_rcfile) == -1)
diff --git a/src/screen.c b/src/screen.c
index 811a947..095040c 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -249,6 +249,32 @@ screen_set_numbers (void)
}
static void
+screen_select_primary (void)
+{
+ rp_screen *cur;
+
+ /* By default, take the first screen as current screen */
+ list_first(cur, &rp_screens, node);
+ if (!rp_current_screen)
+ rp_current_screen = cur;
+
+#ifdef HAVE_XRANDR
+ if (!rp_have_xrandr)
+ return;
+
+ list_for_each_entry (cur, &rp_screens, node)
+ {
+ if (xrandr_is_primary(cur)) {
+ rp_current_screen = cur;
+ PRINT_DEBUG(("Xrandr primary screen %d detected\n",
+ rp_current_screen->number));
+ break;
+ }
+ }
+#endif
+}
+
+static void
init_global_screen (rp_global_screen *s)
{
int screen_num;
@@ -299,6 +325,7 @@ init_screens (void)
screen_sort ();
screen_set_numbers ();
+ screen_select_primary ();
free (rr_outputs);
}
--
2.10.0
- [RP] [PATCH 0/7] Add xrandr primary screen support, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 2/7] Move function declaration to the right header, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 1/7] Remove useless argument from is_rp_window_for_screen function, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 4/7] Store RootWindow in global_screen structure, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 5/7] Add a function to find a screen matching a given XWindowAttributes, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 3/7] Add primary screen detection, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 7/7] Select xrandr primary screen at startup if possible,
Mathieu OTHACEHE <=
- [RP] [PATCH 6/7] Simplify scanwins function, Mathieu OTHACEHE, 2016/12/07
- Re: [RP] [PATCH 0/7] Add xrandr primary screen support, Jeremie Courreges-Anglas, 2016/12/09