summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-05-28 10:44:43 -0700
committerAaron Plattner <aplattner@nvidia.com>2008-05-28 10:44:43 -0700
commit57525859c5a1b37d5e8b31f3a924901643687ba0 (patch)
tree6c3c015f5d41d1f472dce75c4bed3886d2c6b448
parente595fe4cfdc12c8e6eaea71c11f79addecd97ecc (diff)
173.14.05173.14.05
-rw-r--r--src/XF86Config-parser/Merge.c98
-rw-r--r--src/XF86Config-parser/Monitor.c17
-rw-r--r--src/XF86Config-parser/Scan.c1
-rw-r--r--src/XF86Config-parser/xf86Parser.h2
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig-utils.c112
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig.c34
-rw-r--r--src/gtk+-2.x/ctkdisplaylayout.c4
-rw-r--r--src/gtk+-2.x/ctkdisplaylayout.h23
-rw-r--r--src/gtk+-2.x/ctkmultisample.c2
-rw-r--r--src/gtk+-2.x/ctkwindow.c10
-rw-r--r--src/parse.c19
11 files changed, 211 insertions, 111 deletions
diff --git a/src/XF86Config-parser/Merge.c b/src/XF86Config-parser/Merge.c
index a9f2c97..aaf66bc 100644
--- a/src/XF86Config-parser/Merge.c
+++ b/src/XF86Config-parser/Merge.c
@@ -43,22 +43,30 @@ static void xconfigAddRemovedOptionComment(char **existing_comments,
{
int len;
char *str;
+ char *name, *value;
if (!option || !existing_comments)
return;
- len = 32 + strlen(xconfigOptionName(option)) +
- strlen(xconfigOptionValue(option));
+ name = xconfigOptionName(option);
+ value = xconfigOptionValue(option);
- str = (char *)malloc(len);
+ if (!name) return;
- if (str) {
- snprintf(str, len, "# Removed Option \"%s\" \"%s\"",
- xconfigOptionName(option),
- xconfigOptionValue(option));
- *existing_comments = xconfigAddComment(*existing_comments, str);
+ if (value) {
+ len = 32 + strlen(name) + strlen(value);
+ str = malloc(len);
+ if (!str) return;
+ snprintf(str, len, "# Removed Option \"%s\" \"%s\"", name, value);
+ } else {
+ len = 32 + strlen(name);
+ str = malloc(len);
+ if (!str) return;
+ snprintf(str, len, "# Removed Option \"%s\"", name);
}
+ *existing_comments = xconfigAddComment(*existing_comments, str);
+
} /* xconfigAddRemovedOptionComment() */
@@ -86,6 +94,36 @@ static void xconfigRemoveNamedOption(XConfigOptionPtr *head, char *name,
/*
+ * xconfigOptionValuesDiffer() - return '1' if the option values for
+ * option0 and option1 are different; return '0' if the option values
+ * are the same.
+ */
+
+static int xconfigOptionValuesDiffer(XConfigOptionPtr option0,
+ XConfigOptionPtr option1)
+{
+ char *value0, *value1;
+
+ value0 = value1 = NULL;
+
+ if (!option0 && !option1) return 0;
+ if (!option0 && option1) return 1;
+ if ( option0 && !option1) return 1;
+
+ value0 = xconfigOptionValue(option0);
+ value1 = xconfigOptionValue(option1);
+
+ if (!value0 && !value1) return 0;
+ if (!value0 && value1) return 1;
+ if ( value0 && !value1) return 1;
+
+ return (strcmp(value0, value1) != 0);
+
+} /* xconfigOptionValuesDiffer() */
+
+
+
+/*
* xconfigMergeOption() - Merge option "name" from option source
* list "srcHead" to option destination list "dstHead".
*
@@ -107,20 +145,35 @@ static void xconfigMergeOption(XConfigOptionPtr *dstHead,
{
XConfigOptionPtr srcOption = xconfigFindOption(*srcHead, name);
XConfigOptionPtr dstOption = xconfigFindOption(*dstHead, name);
-
- if (!srcOption) {
- if (dstOption) {
- *dstHead = xconfigRemoveOption(*dstHead, dstOption);
- }
- } else {
- if (!dstOption || strcmp(xconfigOptionValue(srcOption),
- xconfigOptionValue(dstOption))) {
- if (dstOption && comments) {
+ char *srcValue = NULL;
+
+ if (srcOption) srcValue = xconfigOptionValue(srcOption);
+
+ if (!srcOption && dstOption) {
+
+ /* option does not exist in src, but exists in dst: remove from dst */
+ *dstHead = xconfigRemoveOption(*dstHead, dstOption);
+
+ } else if (srcOption && !dstOption) {
+
+ /* option exists in src but not in dst: add to dst */
+ *dstHead = xconfigAddNewOption(*dstHead, name, srcValue);
+
+ } else if (srcOption && dstOption) {
+
+ /*
+ * option exists in src and in dst; if the option values are
+ * different, replace the dst's option value with src's option
+ * value; note that xconfigAddNewOption() will remove the old
+ * option first, if necessary
+ */
+
+ if (xconfigOptionValuesDiffer(srcOption, dstOption)) {
+ if (comments) {
xconfigAddRemovedOptionComment(comments, dstOption);
}
- *dstHead = xconfigAddNewOption
- (*dstHead, name, xconfigOptionValue(srcOption));
+ *dstHead = xconfigAddNewOption(*dstHead, name, srcValue);
}
}
@@ -387,13 +440,12 @@ static int xconfigMergeDriverOptions(XConfigScreenPtr dstScreen,
XConfigOptionPtr old =
xconfigFindOption(dstScreen->options, name);
- if (!old || !strcmp(xconfigOptionValue(option),
- xconfigOptionValue(old))) {
+ if (old && xconfigOptionValuesDiffer(option, old)) {
xconfigRemoveNamedOption(&(dstScreen->options), name,
- NULL);
+ &(dstScreen->comment));
} else {
xconfigRemoveNamedOption(&(dstScreen->options), name,
- &(dstScreen->comment));
+ NULL);
}
}
diff --git a/src/XF86Config-parser/Monitor.c b/src/XF86Config-parser/Monitor.c
index e8d8e3c..32080a9 100644
--- a/src/XF86Config-parser/Monitor.c
+++ b/src/XF86Config-parser/Monitor.c
@@ -132,9 +132,9 @@ xconfigParseModeLine (void)
ptr->identifier = val.str;
/* DotClock */
- if (xconfigGetSubToken (&(ptr->comment)) != NUMBER)
+ if ((xconfigGetSubToken (&(ptr->comment)) != NUMBER) || !val.str)
Error ("ModeLine dotclock expected", NULL);
- ptr->clock = (int) (val.realnum * 1000.0 + 0.5);
+ ptr->clock = xconfigStrdup(val.str);
/* HDisplay */
if (xconfigGetSubToken (&(ptr->comment)) != NUMBER)
@@ -264,9 +264,9 @@ xconfigParseVerboseMode (void)
ptr->comment = xconfigAddComment(ptr->comment, val.str);
break;
case DOTCLOCK:
- if ((token = xconfigGetSubToken (&(ptr->comment))) != NUMBER)
+ if ((xconfigGetSubToken (&(ptr->comment)) != NUMBER) || !val.str)
Error (NUMBER_MSG, "DotClock");
- ptr->clock = (int) (val.realnum * 1000.0 + 0.5);
+ ptr->clock = xconfigStrdup(val.str);
had_dotclock = 1;
break;
case HTIMINGS:
@@ -692,8 +692,8 @@ xconfigPrintMonitorSection (FILE * cf, XConfigMonitorPtr ptr)
}
for (mlptr = ptr->modelines; mlptr; mlptr = mlptr->next)
{
- fprintf (cf, " ModeLine \"%s\" %2.1f ",
- mlptr->identifier, mlptr->clock / 1000.0);
+ fprintf (cf, " ModeLine \"%s\" %s ",
+ mlptr->identifier, mlptr->clock);
fprintf (cf, "%d %d %d %d %d %d %d %d",
mlptr->hdisplay, mlptr->hsyncstart,
mlptr->hsyncend, mlptr->htotal,
@@ -743,8 +743,8 @@ xconfigPrintModesSection (FILE * cf, XConfigModesPtr ptr)
fprintf (cf, " Identifier \"%s\"\n", ptr->identifier);
for (mlptr = ptr->modelines; mlptr; mlptr = mlptr->next)
{
- fprintf (cf, " ModeLine \"%s\" %2.1f ",
- mlptr->identifier, mlptr->clock / 1000.0);
+ fprintf (cf, " ModeLine \"%s\" %s ",
+ mlptr->identifier, mlptr->clock);
fprintf (cf, "%d %d %d %d %d %d %d %d",
mlptr->hdisplay, mlptr->hsyncstart,
mlptr->hsyncend, mlptr->htotal,
@@ -827,6 +827,7 @@ xconfigFreeModeLineList (XConfigModeLinePtr ptr)
{
TEST_FREE (ptr->identifier);
TEST_FREE (ptr->comment);
+ TEST_FREE (ptr->clock);
prev = ptr;
ptr = ptr->next;
free (prev);
diff --git a/src/XF86Config-parser/Scan.c b/src/XF86Config-parser/Scan.c
index 22b6557..d0a4258 100644
--- a/src/XF86Config-parser/Scan.c
+++ b/src/XF86Config-parser/Scan.c
@@ -422,6 +422,7 @@ again:
configRBuf[i] = '\0';
val.num = xconfigStrToUL (configRBuf);
val.realnum = atof (configRBuf);
+ val.str = configRBuf;
return (NUMBER);
}
diff --git a/src/XF86Config-parser/xf86Parser.h b/src/XF86Config-parser/xf86Parser.h
index c81574c..6598d5e 100644
--- a/src/XF86Config-parser/xf86Parser.h
+++ b/src/XF86Config-parser/xf86Parser.h
@@ -216,7 +216,7 @@ typedef struct {
typedef struct __xconfigconfmodelinerec {
struct __xconfigconfmodelinerec *next;
char *identifier;
- int clock;
+ char *clock; /* stored in MHz */
int hdisplay;
int hsyncstart;
int hsyncend;
diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c
index 4bf924d..d99168c 100644
--- a/src/gtk+-2.x/ctkdisplayconfig-utils.c
+++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c
@@ -238,13 +238,14 @@ void apply_screen_info_token(char *token, char *value, void *data)
* "mode_name" dot_clock timings flags
*
**/
-static nvModeLinePtr modeline_parse(const char *modeline_str)
+static nvModeLinePtr modeline_parse(const char *modeline_str,
+ const int broken_doublescan_modelines)
{
nvModeLinePtr modeline = NULL;
const char *str = modeline_str;
char *tmp;
- char *tokens;
-
+ char *tokens, *nptr;
+ double pclk, htotal, vtotal, factor;
if (!str) return NULL;
@@ -270,25 +271,11 @@ static nvModeLinePtr modeline_parse(const char *modeline_str)
if (!str) goto fail;
/* Read dot clock */
- {
- int digits = 100;
- str = parse_read_integer(str, &(modeline->data.clock));
- modeline->data.clock *= 1000;
- if (*str == '.') {
- str++;
- while (digits &&
- *str &&
- *str != ' ' && *str != '\t' &&
- *str != '\n' && *str != '\r') {
-
- modeline->data.clock += digits * (*str - '0');
- digits /= 10;
- str++;
- }
- }
- str = parse_skip_whitespace(str);
- }
+ str = parse_read_name(str, &(modeline->data.clock), 0);
+ if (!str) goto fail;
+
+ /* Read the mode timings */
str = parse_read_integer(str, &(modeline->data.hdisplay));
str = parse_read_integer(str, &(modeline->data.hsyncstart));
@@ -301,7 +288,7 @@ static nvModeLinePtr modeline_parse(const char *modeline_str)
/* Parse modeline flags */
- while ((str = parse_read_name(str, &tmp, ' ')) && strlen(tmp)) {
+ while ((str = parse_read_name(str, &tmp, 0)) && strlen(tmp)) {
if (!xconfigNameCompare(tmp, "+hsync")) {
modeline->data.flags |= XCONFIG_MODE_PHSYNC;
@@ -360,6 +347,40 @@ static nvModeLinePtr modeline_parse(const char *modeline_str)
free(tmp);
}
+
+ /*
+ * Calculate the vertical refresh rate of the modeline in Hz;
+ * divide by two for double scan modes (if the double scan
+ * modeline isn't broken; i.e., already has a correct vtotal), and
+ * multiply by two for interlaced modes (so that we report the
+ * field rate, rather than the frame rate)
+ */
+
+ htotal = (double) modeline->data.htotal;
+ vtotal = (double) modeline->data.vtotal;
+
+ pclk = strtod(modeline->data.clock, &nptr);
+
+ if ((pclk == 0.0) || !nptr || *nptr != '\0' || ((htotal * vtotal) == 0)) {
+ nv_warning_msg("Failed to compute the refresh rate "
+ "for the modeline '%s'", str);
+ goto fail;
+ }
+
+ modeline->refresh_rate = (pclk * 1000000.0) / (htotal * vtotal);
+
+ factor = 1.0;
+
+ if ((modeline->data.flags & V_DBLSCAN) && !broken_doublescan_modelines) {
+ factor *= 0.5;
+ }
+
+ if (modeline->data.flags & V_INTERLACE) {
+ factor *= 2.0;
+ }
+
+ modeline->refresh_rate *= factor;
+
return modeline;
@@ -407,7 +428,7 @@ nvModePtr mode_parse(nvDisplayPtr display, const char *mode_str)
/* Read the mode name */
- str = parse_read_name(str, &mode_name, ' ');
+ str = parse_read_name(str, &mode_name, 0);
if (!str || !mode_name) goto fail;
@@ -720,6 +741,7 @@ static void display_remove_modelines(nvDisplayPtr display)
if (display) {
while (display->modelines) {
modeline = display->modelines;
+ free(modeline->data.clock);
display->modelines = display->modelines->next;
free(modeline);
}
@@ -743,6 +765,28 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, gchar **err_str)
int len;
ReturnStatus ret, ret1;
int major = 0, minor = 0;
+ int broken_doublescan_modelines;
+
+ /*
+ * check the version of the NV-CONTROL protocol -- versions <=
+ * 1.13 had a bug in how they reported double scan modelines
+ * (vsyncstart, vsyncend, and vtotal were doubled); determine
+ * if this X server has this bug, so that we can use
+ * broken_doublescan_modelines to correctly compute the
+ * refresh rate.
+ */
+ broken_doublescan_modelines = 1;
+
+ ret = NvCtrlGetAttribute(display->gpu->handle,
+ NV_CTRL_ATTR_NV_MAJOR_VERSION, &major);
+ ret1 = NvCtrlGetAttribute(display->gpu->handle,
+ NV_CTRL_ATTR_NV_MINOR_VERSION, &minor);
+
+ if ((ret == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) &&
+ ((major > 1) || ((major == 1) && (minor > 13)))) {
+ broken_doublescan_modelines = 0;
+ }
+
/* Free any old mode lines */
display_remove_modelines(display);
@@ -769,7 +813,7 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, gchar **err_str)
str = modeline_strs;
while (strlen(str)) {
- modeline = modeline_parse(str);
+ modeline = modeline_parse(str, broken_doublescan_modelines);
if (!modeline) {
*err_str = g_strdup_printf("Failed to parse the following "
"modeline of display device\n"
@@ -784,26 +828,6 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, gchar **err_str)
goto fail;
}
- /*
- * check the version of the NV-CONTROL protocol -- versions <=
- * 1.13 had a bug in how they reported double scan modelines
- * (vsyncstart, vsyncend, and vtotal were doubled); determine
- * if this X server has this bug, so that we can use
- * broken_doublescan_modelines to correctly compute the
- * refresh rate.
- */
- modeline->broken_doublescan_modelines = 1;
-
- ret = NvCtrlGetAttribute(display->gpu->handle,
- NV_CTRL_ATTR_NV_MAJOR_VERSION, &major);
- ret1 = NvCtrlGetAttribute(display->gpu->handle,
- NV_CTRL_ATTR_NV_MINOR_VERSION, &minor);
-
- if ((ret == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) &&
- ((major > 1) || ((major == 1) && (minor > 13)))) {
- modeline->broken_doublescan_modelines = 0;
- }
-
/* Add the modeline at the end of the display's modeline list */
display->modelines = (nvModeLinePtr)xconfigAddListItem
((GenericListPtr)display->modelines, (GenericListPtr)modeline);
diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c
index e52e8c4..ee4c133 100644
--- a/src/gtk+-2.x/ctkdisplayconfig.c
+++ b/src/gtk+-2.x/ctkdisplayconfig.c
@@ -71,6 +71,8 @@ static void display_position_offset_activate(GtkWidget *widget, gpointer user_da
static void display_position_relative_changed(GtkWidget *widget, gpointer user_data);
static void display_panning_activate(GtkWidget *widget, gpointer user_data);
+static gboolean display_panning_focus_out(GtkWidget *widget, GdkEvent *event,
+ gpointer user_data);
static void setup_screen_page(CtkDisplayConfig *ctk_object);
@@ -1187,7 +1189,9 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle,
g_signal_connect(G_OBJECT(ctk_object->txt_display_panning), "activate",
G_CALLBACK(display_panning_activate),
(gpointer) ctk_object);
-
+ g_signal_connect(G_OBJECT(ctk_object->txt_display_panning), "focus-out-event",
+ G_CALLBACK(display_panning_focus_out),
+ (gpointer) ctk_object);
/* X screen number */
ctk_object->txt_screen_num = gtk_label_new("");
@@ -2043,7 +2047,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object)
}
modelines = display->modelines;
cur_modeline = display->cur_mode->modeline;
- cur_rate = GET_MODELINE_REFRESH_RATE(cur_modeline);
+ cur_rate = cur_modeline->refresh_rate;
/* Create the menu index -> modeline pointer lookup table */
@@ -2096,7 +2100,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object)
continue;
}
- modeline_rate = GET_MODELINE_REFRESH_RATE(modeline);
+ modeline_rate = modeline->refresh_rate;
is_doublescan = (modeline->data.flags & V_DBLSCAN);
is_interlaced = (modeline->data.flags & V_INTERLACE);
@@ -2107,7 +2111,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object)
count_ref = 0; /* # modelines with similar refresh rates */
num_ref = 0; /* Modeline # in a group of similar refresh rates */
for (m = modelines; m; m = m->next) {
- float m_rate = GET_MODELINE_REFRESH_RATE(m);
+ float m_rate = m->refresh_rate;
gchar *tmp = g_strdup_printf("%.0f Hz", m_rate);
if (!IS_NVIDIA_DEFAULT_MODE(m) &&
@@ -2184,8 +2188,8 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object)
if (modeline->data.hdisplay == cur_modeline->data.hdisplay &&
modeline->data.vdisplay == cur_modeline->data.vdisplay) {
- float prev_rate = GET_MODELINE_REFRESH_RATE(ctk_object->refresh_table[cur_idx]);
- float rate = GET_MODELINE_REFRESH_RATE(modeline);
+ float prev_rate = ctk_object->refresh_table[cur_idx]->refresh_rate;
+ float rate = modeline->refresh_rate;
if (ctk_object->refresh_table[cur_idx]->data.hdisplay != cur_modeline->data.hdisplay ||
ctk_object->refresh_table[cur_idx]->data.vdisplay != cur_modeline->data.vdisplay) {
@@ -5204,6 +5208,24 @@ static void display_panning_activate(GtkWidget *widget, gpointer user_data)
+/** display_panning_focus_out() **************************************
+ *
+ * Called when user leaves the panning entry
+ *
+ **/
+
+static gboolean display_panning_focus_out(GtkWidget *widget, GdkEvent *event,
+ gpointer user_data)
+{
+ display_panning_activate(widget, user_data);
+
+ return FALSE;
+
+} /* display_panning_focus_out() */
+
+
+
+
/** screen_depth_changed() *******************************************
*
* Called when user selects a new color depth for a screen.
diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c
index 2928a93..3f38c1e 100644
--- a/src/gtk+-2.x/ctkdisplaylayout.c
+++ b/src/gtk+-2.x/ctkdisplaylayout.c
@@ -2106,7 +2106,7 @@ static char *get_display_tooltip(CtkDisplayLayout *ctk_object,
/* Display has mode/modeline */
} else {
- float ref = GET_MODELINE_REFRESH_RATE(display->cur_mode->modeline);
+ float ref = display->cur_mode->modeline->refresh_rate;
tip = g_strdup_printf("%s : %dx%d @ %.0f Hz",
display->name,
display->cur_mode->modeline->data.hdisplay,
@@ -2135,7 +2135,7 @@ static char *get_display_tooltip(CtkDisplayLayout *ctk_object,
/* Display has mode/modeline */
} else {
- float ref = GET_MODELINE_REFRESH_RATE(display->cur_mode->modeline);
+ float ref = display->cur_mode->modeline->refresh_rate;
tip = g_strdup_printf("%s : %dx%d @ %.0f Hz (Screen: %d) "
"(GPU: %s)",
display->name,
diff --git a/src/gtk+-2.x/ctkdisplaylayout.h b/src/gtk+-2.x/ctkdisplaylayout.h
index 5b51c7a..580ca26 100644
--- a/src/gtk+-2.x/ctkdisplaylayout.h
+++ b/src/gtk+-2.x/ctkdisplaylayout.h
@@ -124,20 +124,6 @@ G_BEGIN_DECLS
(!strcmp(( m )->data.identifier, "nvidia-auto-select"))
-/* Calculates the vertical refresh rate of the modeline in Hz; if the
- * divide by two for double scan modes (if the double scan modeline
- * isn't broken; i.e., already has a correct vtotal), and multiply by
- * two for interlaced modes (so that we report the field rate, rather
- * than the frame rate)
- */
-#define GET_MODELINE_REFRESH_RATE(m) \
-((((double)((m)->data.clock) * 1000) / \
- ((double)((m)->data.htotal) * (double)((m)->data.vtotal))) * \
- ((((m)->data.flags & V_DBLSCAN) && \
- !(m)->broken_doublescan_modelines) ? 0.5 : 1.0) * \
- (((m)->data.flags & V_INTERLACE) ? 2.0 : 1.0))
-
-
/* Calculates the horizontal refresh rate (sync) of the modeline in kHz */
#define GET_MODELINE_HSYNC(m) \
(((double)((m)->data.clock)) / (2.0f * (double)((m)->data.htotal)))
@@ -153,17 +139,12 @@ typedef struct nvModeLineRec {
XConfigModeLineRec data; /* Modeline information */
+ double refresh_rate; /* in Hz */
+
/* Extra information */
unsigned int source;
char *xconfig_name;
- /* older versions of the NV-CONTROL protocol reported doublescan
- * modeline values with doubled vsyncstart, vsyncend, and vtotal;
- * track whether this X server has this bug, so we know how to
- * compute the refresh rate from the modeline
- */
- int broken_doublescan_modelines;
-
} nvModeLine, *nvModeLinePtr;
diff --git a/src/gtk+-2.x/ctkmultisample.c b/src/gtk+-2.x/ctkmultisample.c
index 1e2b9d0..94647c2 100644
--- a/src/gtk+-2.x/ctkmultisample.c
+++ b/src/gtk+-2.x/ctkmultisample.c
@@ -305,6 +305,8 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
gtk_box_pack_start(GTK_BOX(vbox), check_button,
FALSE, FALSE, 0);
+
+ ctk_multisample->fsaa_app_override_check_button = check_button;
}
g_signal_connect(G_OBJECT(ctk_event),
diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c
index 84f8f48..2d1f010 100644
--- a/src/gtk+-2.x/ctkwindow.c
+++ b/src/gtk+-2.x/ctkwindow.c
@@ -392,6 +392,7 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles,
GtkCellRenderer *renderer;
GtkTreeSelection *selection;
GtkTreeModel *model;
+ GtkTreeIter iter;
GtkTextTagTable *tag_table;
GtkTextBuffer *help;
@@ -600,7 +601,6 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles,
for (i = 0; i < num_screen_handles; i++) {
- GtkTreeIter iter;
gchar *screen_name;
GtkWidget *child;
NvCtrlAttributeHandle *screen_handle = screen_handles[i];
@@ -746,7 +746,6 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles,
for (i = 0; i < num_gpu_handles; i++) {
- GtkTreeIter iter;
gchar *gpu_product_name;
gchar *gpu_name;
GtkWidget *child;
@@ -849,7 +848,6 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles,
for (i = 0; i < num_vcs_handles; i++) {
- GtkTreeIter iter;
gchar *vcs_product_name;
gchar *vcs_name;
GtkWidget *child;
@@ -944,6 +942,12 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles,
gtk_tree_view_expand_all(ctk_window->treeview);
gtk_tree_view_columns_autosize(ctk_window->treeview);
+ /* Make sure the first item is selected */
+ if ( gtk_tree_model_get_iter_first(model, &iter) ) {
+ gtk_tree_selection_select_iter(selection, &iter);
+ }
+
+
/* set the window title */
gtk_window_set_title(GTK_WINDOW(object), "NVIDIA X Server Settings");
diff --git a/src/parse.c b/src/parse.c
index 52a1051..5bc6f9a 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -1449,22 +1449,35 @@ const char *parse_read_integer_pair(const char *str,
* terminating character 'term'. The location where parsing stopped
* is returned, or NULL on failure.
*
+ * The 'term' value 0 is used to indicate that any whitespace should
+ * be treated as a terminator.
+ *
**/
+
+static int name_terminated(const char ch, const char term)
+{
+ if (term == 0) {
+ return (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
+ } else {
+ return (ch == term);
+ }
+}
+
const char *parse_read_name(const char *str, char **name, char term)
{
const char *tmp;
str = parse_skip_whitespace(str);
tmp = str;
- while (*str && *str != term) {
+ while (*str && !name_terminated(*str, term))
str++;
- }
+
*name = (char *)calloc(1, str -tmp +1);
if (!(*name)) {
return NULL;
}
strncpy(*name, tmp, str -tmp);
- if (*str == term) {
+ if (name_terminated(*str, term)) {
str++;
}
return parse_skip_whitespace(str);