f64fd8d27d
I guess the best way to get testers is to submit it... OBS-URL: https://build.opensuse.org/request/show/88834 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gnome-session?expand=0&rev=132
103 lines
3.0 KiB
Diff
103 lines
3.0 KiB
Diff
commit 2613036679b7691c93f5bbd1e15379d80fbb9bf6
|
|
Author: Vincent Untz <vuntz@gnome.org>
|
|
Date: Wed Oct 19 13:14:50 2011 +0200
|
|
|
|
tools: Look at gnome.fallback argument in kernel boot line
|
|
|
|
This is a quick way to let users easily force the fallback (or
|
|
non-fallback mode) with gnome.fallback=0/1 on boot.
|
|
|
|
diff --git a/tools/gnome-session-check-accelerated-helper.c b/tools/gnome-session-check-accelerated-helper.c
|
|
index 3f83f76..c1fbe9d 100644
|
|
--- a/tools/gnome-session-check-accelerated-helper.c
|
|
+++ b/tools/gnome-session-check-accelerated-helper.c
|
|
@@ -70,7 +70,9 @@
|
|
/* for strcasestr */
|
|
#define _GNU_SOURCE
|
|
|
|
+#include <ctype.h>
|
|
#include <stdio.h>
|
|
+#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
@@ -87,6 +89,54 @@ _print_error (const char *str)
|
|
}
|
|
|
|
static int
|
|
+_parse_kcmdline (void)
|
|
+{
|
|
+ FILE *kcmdline;
|
|
+ char *line = NULL;
|
|
+ size_t line_len = 0;
|
|
+ int ret = -1;
|
|
+
|
|
+ kcmdline = fopen("/proc/cmdline", "r");
|
|
+ if (kcmdline == NULL)
|
|
+ return ret;
|
|
+
|
|
+ while (getline (&line, &line_len, kcmdline) != -1) {
|
|
+ const char *arg;
|
|
+ const char *str;
|
|
+ int key_len = strlen ("gnome.fallback=");
|
|
+
|
|
+ if (line == NULL)
|
|
+ break;
|
|
+
|
|
+ /* don't break if we found the argument once: last mention wins */
|
|
+
|
|
+ str = line;
|
|
+ do {
|
|
+ arg = strstr (str, "gnome.fallback=");
|
|
+ str = arg + key_len;
|
|
+
|
|
+ if (arg &&
|
|
+ (arg == line || isspace (arg[-1])) && /* gnome.fallback= is really the beginning of an argument */
|
|
+ (isdigit (arg[key_len]))) { /* the first character of the value of this argument is an integer */
|
|
+ if ((arg[key_len+1] == '\0' || isspace (arg[key_len+1]))) /* the value of this argument is only one character long */
|
|
+ ret = arg[key_len] - '0';
|
|
+ else /* invalid value */
|
|
+ ret = 0xDEAD;
|
|
+
|
|
+ }
|
|
+ } while (arg != NULL);
|
|
+
|
|
+ free (line);
|
|
+ line = NULL;
|
|
+ line_len = 0;
|
|
+ }
|
|
+
|
|
+ fclose (kcmdline);
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static int
|
|
_has_composite (Display *display)
|
|
{
|
|
int dummy1, dummy2;
|
|
@@ -257,9 +307,23 @@ _is_max_texture_size_big_enough (Display *display)
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
+ int kcmdline_parsed;
|
|
Display *display = NULL;
|
|
int ret = 1;
|
|
|
|
+ kcmdline_parsed = _parse_kcmdline ();
|
|
+ if (kcmdline_parsed >= 0) {
|
|
+ if (kcmdline_parsed == 0) {
|
|
+ _print_error ("Non-fallback mode forced by kernel command line.");
|
|
+ ret = 0;
|
|
+ goto out;
|
|
+ } else if (kcmdline_parsed == 1) {
|
|
+ _print_error ("Fallback mode forced by kernel command line.");
|
|
+ goto out;
|
|
+ } else
|
|
+ _print_error ("Invalid value for gnome.fallback passed in kernel command line.");
|
|
+ }
|
|
+
|
|
display = XOpenDisplay (NULL);
|
|
if (!display) {
|
|
_print_error ("No X display.");
|