diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2012-05-19 08:23:24 -0700 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2012-05-19 08:23:24 -0700 |
commit | 9bf701fbd3fdaf793ea01e629c0d475615d45cd9 (patch) | |
tree | dedda240fac7fb6d4ccd56d90ee5553cbd8e4bfc /src | |
parent | c3e638087673f0f4b7a751685a97b7830a8d9a18 (diff) |
302.11302.11
Diffstat (limited to 'src')
-rw-r--r-- | src/gtk+-2.x/ctkdisplayconfig-utils.c | 46 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkdisplaydevice-crt.c | 387 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkdisplaydevice-crt.h | 85 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkdisplaydevice.c | 151 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkditheringcontrols.c | 99 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkframelock.c | 323 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkwindow.c | 31 | ||||
-rw-r--r-- | src/libXNVCtrl/NVCtrl.h | 2 | ||||
-rw-r--r-- | src/parse.c | 30 | ||||
-rw-r--r-- | src/src.mk | 2 | ||||
-rw-r--r-- | src/version.mk | 2 |
11 files changed, 361 insertions, 797 deletions
diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c index eed0604..7ed3d49 100644 --- a/src/gtk+-2.x/ctkdisplayconfig-utils.c +++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c @@ -456,6 +456,7 @@ static void apply_mode_attribute_token(char *token, char *value, void *data) } else if (!strcasecmp("PassiveRight", value)) { mode->passive_stereo_eye = PASSIVE_STEREO_EYE_RIGHT; } + return; } } /* apply_mode_attribute_token() */ @@ -1421,6 +1422,47 @@ static void screen_remove_metamodes(nvScreenPtr screen) + /** mode_strtok() *************************************************** + * + * Special strtok function for parsing modes. This function ignores + * anything between curly braces, including commas when parsing tokens + * deliminated by commas. + * + **/ +static char *mode_strtok(char *str) +{ + static char *intStr = NULL; + char *start; + + if (str) { + intStr = str; + } + + if (!intStr || *intStr == '\0') { + return NULL; + } + + /* Mark off the next token value */ + start = intStr; + while (*intStr != '\0') { + if (*intStr == '{') { + while (*intStr != '}' && *intStr != '\0') { + intStr++; + } + } + if (*intStr == ',') { + *intStr = '\0'; + intStr++; + break; + } + intStr++; + } + + return start; +} + + + /** screen_add_metamode() ******************************************** * * Parses a metamode string and adds the appropriate modes to the @@ -1471,9 +1513,9 @@ static Bool screen_add_metamode(nvScreenPtr screen, const char *metamode_str, metamode_copy = strdup(metamode_modes); if (!metamode_copy) goto fail; - for (mode_str_itr = strtok(metamode_copy, ","); + for (mode_str_itr = mode_strtok(metamode_copy); mode_str_itr; - mode_str_itr = strtok(NULL, ",")) { + mode_str_itr = mode_strtok(NULL)) { nvModePtr mode; nvDisplayPtr display; diff --git a/src/gtk+-2.x/ctkdisplaydevice-crt.c b/src/gtk+-2.x/ctkdisplaydevice-crt.c deleted file mode 100644 index aa15ee9..0000000 --- a/src/gtk+-2.x/ctkdisplaydevice-crt.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix - * and Linux systems. - * - * Copyright (C) 2004 NVIDIA Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses>. - */ - -#include <gtk/gtk.h> -#include <NvCtrlAttributes.h> - -#include "ctkbanner.h" - -#include "ctkdisplaydevice-crt.h" - -#include "ctkimagesliders.h" -#include "ctkedid.h" -#include "ctkconfig.h" -#include "ctkhelp.h" -#include "ctkutils.h" -#include <stdio.h> - -static void ctk_display_device_crt_class_init(CtkDisplayDeviceCrtClass *); -static void ctk_display_device_crt_finalize(GObject *); - -static void reset_button_clicked(GtkButton *button, gpointer user_data); - -static void ctk_display_device_crt_setup(CtkDisplayDeviceCrt - *ctk_display_device_crt); - -static void info_update_received(GtkObject *object, gpointer arg1, - gpointer user_data); - -static void crt_info_setup(CtkDisplayDeviceCrt *ctk_display_device_crt); - -static void enabled_displays_received(GtkObject *object, gpointer arg1, - gpointer user_data); - -static const char * __refresh_rate_help = "The refresh rate displays the " -"rate at which the screen is currently refreshing the image."; - -GType ctk_display_device_crt_get_type(void) -{ - static GType ctk_display_device_crt_type = 0; - - if (!ctk_display_device_crt_type) { - static const GTypeInfo ctk_display_device_crt_info = { - sizeof (CtkDisplayDeviceCrtClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ctk_display_device_crt_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CtkDisplayDeviceCrt), - 0, /* n_preallocs */ - NULL, /* instance_init */ - NULL /* value_table */ - }; - - ctk_display_device_crt_type = g_type_register_static (GTK_TYPE_VBOX, - "CtkDisplayDeviceCrt", &ctk_display_device_crt_info, 0); - } - - return ctk_display_device_crt_type; -} - -static void ctk_display_device_crt_class_init( - CtkDisplayDeviceCrtClass *ctk_display_device_crt_class -) -{ - GObjectClass *gobject_class = (GObjectClass *)ctk_display_device_crt_class; - gobject_class->finalize = ctk_display_device_crt_finalize; -} - -static void ctk_display_device_crt_finalize( - GObject *object -) -{ - CtkDisplayDeviceCrt *ctk_display_device_crt = CTK_DISPLAY_DEVICE_CRT(object); - g_free(ctk_display_device_crt->name); - g_signal_handlers_disconnect_matched(ctk_display_device_crt->ctk_event, - G_SIGNAL_MATCH_DATA, - 0, - 0, - NULL, - NULL, - (gpointer) ctk_display_device_crt); -} - -/* - * ctk_display_device_crt_new() - constructor for the CRT display - * device page. - */ - -GtkWidget* ctk_display_device_crt_new(NvCtrlAttributeHandle *handle, - CtkConfig *ctk_config, - CtkEvent *ctk_event, - char *name) -{ - GObject *object; - CtkDisplayDeviceCrt *ctk_display_device_crt; - GtkWidget *banner; - GtkWidget *hbox; - GtkWidget *tmpbox; - GtkWidget *tmphbox, *eventbox; - GtkWidget *frame; - GtkWidget *alignment; - - object = g_object_new(CTK_TYPE_DISPLAY_DEVICE_CRT, NULL); - if (!object) return NULL; - - ctk_display_device_crt = CTK_DISPLAY_DEVICE_CRT(object); - ctk_display_device_crt->handle = handle; - ctk_display_device_crt->ctk_config = ctk_config; - ctk_display_device_crt->ctk_event = ctk_event; - ctk_display_device_crt->name = g_strdup(name); - ctk_display_device_crt->txt_refresh_rate = gtk_label_new(""); - gtk_box_set_spacing(GTK_BOX(object), 10); - - /* banner */ - - banner = ctk_banner_image_new(BANNER_ARTWORK_CRT); - gtk_box_pack_start(GTK_BOX(object), banner, FALSE, FALSE, 0); - - /* - * create the reset button (which we need while creating the - * controls in this page so that we can set the button's - * sensitivity), though we pack it at the bottom of the page - */ - - ctk_display_device_crt->reset_button = - gtk_button_new_with_label("Reset CRT Hardware Defaults"); - - alignment = gtk_alignment_new(1, 1, 0, 0); - gtk_container_add(GTK_CONTAINER(alignment), - ctk_display_device_crt->reset_button); - gtk_box_pack_end(GTK_BOX(object), alignment, TRUE, TRUE, 0); - - g_signal_connect(G_OBJECT(ctk_display_device_crt->reset_button), - "clicked", G_CALLBACK(reset_button_clicked), - (gpointer) ctk_display_device_crt); - - ctk_config_set_tooltip(ctk_config, ctk_display_device_crt->reset_button, - ctk_help_create_reset_hardware_defaults_text("CRT", name)); - - /* pack the image sliders */ - - ctk_display_device_crt->image_sliders = - ctk_image_sliders_new(handle, ctk_config, ctk_event, - ctk_display_device_crt->reset_button, - name); - if (ctk_display_device_crt->image_sliders) { - gtk_box_pack_start(GTK_BOX(object), - ctk_display_device_crt->image_sliders, - FALSE, FALSE, 0); - } - /* add the label Refresh Rate and its value */ - - frame = gtk_frame_new(NULL); - gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0); - tmphbox = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(tmphbox), 5); - gtk_container_add(GTK_CONTAINER(frame), tmphbox); - - tmpbox = gtk_vbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(tmphbox), tmpbox); - - /* pack the Refresh Rate Label */ - { - typedef struct { - GtkWidget *label; - GtkWidget *txt; - const gchar *tooltip; - } TextLineInfo; - - TextLineInfo line = { - gtk_label_new("Refresh Rate:"), - ctk_display_device_crt->txt_refresh_rate, - __refresh_rate_help, - }; - - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), line.label, - FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), line.txt, - FALSE, FALSE, 5); - - /* Include tooltips */ - if (!line.tooltip) { - gtk_box_pack_start(GTK_BOX(tmpbox), hbox, FALSE, FALSE, 0); - } else { - eventbox = gtk_event_box_new(); - gtk_container_add(GTK_CONTAINER(eventbox), hbox); - ctk_config_set_tooltip(ctk_config, eventbox, line.tooltip); - gtk_box_pack_start(GTK_BOX(tmpbox), eventbox, FALSE, FALSE, 0); - } - } - /* pack the EDID button */ - - ctk_display_device_crt->edid = - ctk_edid_new(ctk_display_device_crt->handle, - ctk_display_device_crt->ctk_config, - ctk_display_device_crt->ctk_event, - ctk_display_device_crt->name); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), ctk_display_device_crt->edid, - TRUE, TRUE, 0); - - /* show the page */ - - gtk_widget_show_all(GTK_WIDGET(object)); - - /* Update the GUI */ - - update_display_enabled_flag(ctk_display_device_crt->handle, - &ctk_display_device_crt->display_enabled); - - ctk_display_device_crt_setup(ctk_display_device_crt); - - /* handle enable/disable events on the display device */ - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_ENABLED_DISPLAYS), - G_CALLBACK(enabled_displays_received), - (gpointer) ctk_display_device_crt); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_REFRESH_RATE), - G_CALLBACK(info_update_received), - (gpointer) ctk_display_device_crt); - - return GTK_WIDGET(object); -} - - - -GtkTextBuffer *ctk_display_device_crt_create_help(GtkTextTagTable *table, - CtkDisplayDeviceCrt - *ctk_display_device_crt) -{ - GtkTextIter i; - GtkTextBuffer *b; - GtkTooltipsData *td; - - b = gtk_text_buffer_new(table); - - gtk_text_buffer_get_iter_at_offset(b, &i, 0); - - ctk_help_title(b, &i, "%s Help", ctk_display_device_crt->name); - - ctk_help_heading(b, &i, "Refresh rate"); - ctk_help_para(b, &i, __refresh_rate_help); - - add_image_sliders_help - (CTK_IMAGE_SLIDERS(ctk_display_device_crt->image_sliders), b, &i); - - add_acquire_edid_help(b, &i); - - td = gtk_tooltips_data_get(GTK_WIDGET(ctk_display_device_crt->reset_button)); - ctk_help_reset_hardware_defaults (b, &i, td->tip_text); - - ctk_help_finish(b); - - return b; -} - - - -/* - * reset_button_clicked() - - */ - -static void reset_button_clicked(GtkButton *button, gpointer user_data) -{ - CtkDisplayDeviceCrt *ctk_display_device_crt = - CTK_DISPLAY_DEVICE_CRT(user_data); - - /* Disable the reset button here and allow the controls below to (re)enable - * it if need be,. - */ - gtk_widget_set_sensitive(ctk_display_device_crt->reset_button, FALSE); - - ctk_image_sliders_reset - (CTK_IMAGE_SLIDERS(ctk_display_device_crt->image_sliders)); - - ctk_config_statusbar_message(ctk_display_device_crt->ctk_config, - "Reset hardware defaults for %s.", - ctk_display_device_crt->name); - -} /* reset_button_clicked() */ - - - -/* - * Updates the display device page to reflect the current - * configuration of the display device. - */ -static void ctk_display_device_crt_setup(CtkDisplayDeviceCrt - *ctk_display_device_crt) -{ - /* Disable the reset button here and allow the controls below to (re)enable - * it if need be,. - */ - gtk_widget_set_sensitive(ctk_display_device_crt->reset_button, FALSE); - - - /* Update info */ - - crt_info_setup(ctk_display_device_crt); - - ctk_edid_setup(CTK_EDID(ctk_display_device_crt->edid)); - - /* Update controls */ - - ctk_image_sliders_setup - (CTK_IMAGE_SLIDERS(ctk_display_device_crt->image_sliders)); - -} /* ctk_display_device_crt_setup() */ - - - -static void crt_info_setup(CtkDisplayDeviceCrt *ctk_display_device_crt) -{ - ReturnStatus ret; - gint val; - - /* Refresh Rate */ - ret = NvCtrlGetAttribute(ctk_display_device_crt->handle, - NV_CTRL_REFRESH_RATE, &val); - if (ret == NvCtrlSuccess) { - char str[32]; - float fvalue = ((float)(val)) / 100.0f; - snprintf(str, 32, "%.2f Hz", fvalue); - gtk_label_set_text - (GTK_LABEL(ctk_display_device_crt->txt_refresh_rate), - str); - } else { - gtk_label_set_text - (GTK_LABEL(ctk_display_device_crt->txt_refresh_rate), - "Unknown"); - } -} -/* - * When the list of enabled displays on the GPU changes, - * this page should disable/enable access based on whether - * or not the display device is enabled. - */ -static void enabled_displays_received(GtkObject *object, gpointer arg1, - gpointer user_data) -{ - CtkDisplayDeviceCrt *ctk_object = CTK_DISPLAY_DEVICE_CRT(user_data); - - /* Requery display information only if display disabled */ - - update_display_enabled_flag(ctk_object->handle, - &ctk_object->display_enabled); - - ctk_display_device_crt_setup(ctk_object); - -} /* enabled_displays_received() */ - - -/* - * When resolution changes occur, we should update the GUI to reflect - * the current state. - */ - -static void info_update_received(GtkObject *object, gpointer arg1, - gpointer user_data) -{ - CtkDisplayDeviceCrt *ctk_object = CTK_DISPLAY_DEVICE_CRT(user_data); - - crt_info_setup(ctk_object); -} diff --git a/src/gtk+-2.x/ctkdisplaydevice-crt.h b/src/gtk+-2.x/ctkdisplaydevice-crt.h deleted file mode 100644 index e360343..0000000 --- a/src/gtk+-2.x/ctkdisplaydevice-crt.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix - * and Linux systems. - * - * Copyright (C) 2004 NVIDIA Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses>. - */ - -#ifndef __CTK_DISPLAYDEVICE_CRT_H__ -#define __CTK_DISPLAYDEVICE_CRT_H__ - -#include "ctkevent.h" -#include "ctkconfig.h" - -G_BEGIN_DECLS - -#define CTK_TYPE_DISPLAY_DEVICE_CRT (ctk_display_device_crt_get_type()) - -#define CTK_DISPLAY_DEVICE_CRT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), CTK_TYPE_DISPLAY_DEVICE_CRT, \ - CtkDisplayDeviceCrt)) - -#define CTK_DISPLAY_DEVICE_CRT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), CTK_TYPE_DISPLAY_DEVICE_CRT, \ - CtkDisplayDeviceCrtClass)) - -#define CTK_IS_DISPLAY_DEVICE_CRT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CTK_TYPE_DISPLAY_DEVICE_CRT)) - -#define CTK_IS_DISPLAY_DEVICE_CRT_CLASS(class) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), CTK_TYPE_DISPLAY_DEVICE_CRT)) - -#define CTK_DISPLAY_DEVICE_CRT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), CTK_TYPE_DISPLAY_DEVICE_CRT, \ - CtkDisplayDeviceCrtClass)) - - -typedef struct _CtkDisplayDeviceCrt CtkDisplayDeviceCrt; -typedef struct _CtkDisplayDeviceCrtClass CtkDisplayDeviceCrtClass; - -struct _CtkDisplayDeviceCrt -{ - GtkVBox parent; - - NvCtrlAttributeHandle *handle; - CtkConfig *ctk_config; - CtkEvent *ctk_event; - GtkWidget *image_sliders; - GtkWidget *reset_button; - GtkWidget *txt_refresh_rate; - - GtkWidget *edid; - - gboolean display_enabled; - - char *name; -}; - -struct _CtkDisplayDeviceCrtClass -{ - GtkVBoxClass parent_class; -}; - -GType ctk_display_device_crt_get_type (void) G_GNUC_CONST; -GtkWidget* ctk_display_device_crt_new (NvCtrlAttributeHandle *, - CtkConfig *, CtkEvent *, - char *); - -GtkTextBuffer *ctk_display_device_crt_create_help(GtkTextTagTable *, - CtkDisplayDeviceCrt *); - -G_END_DECLS - -#endif /* __CTK_DISPLAYDEVICE_CRT_H__ */ diff --git a/src/gtk+-2.x/ctkdisplaydevice.c b/src/gtk+-2.x/ctkdisplaydevice.c index 3421e75..647de1c 100644 --- a/src/gtk+-2.x/ctkdisplaydevice.c +++ b/src/gtk+-2.x/ctkdisplaydevice.c @@ -19,6 +19,7 @@ #include <gtk/gtk.h> #include <NvCtrlAttributes.h> +#include <string.h> #include "ctkbanner.h" @@ -42,6 +43,9 @@ static void update_device_info(CtkDisplayDevice *ctk_object); static void display_device_setup(CtkDisplayDevice *ctk_object); +static void callback_link_changed(GtkObject *object, gpointer arg1, + gpointer user_data); + static void enabled_displays_received(GtkObject *object, gpointer arg1, gpointer user_data); @@ -141,13 +145,16 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle, GObject *object; CtkDisplayDevice *ctk_object; GtkWidget *banner; - GtkWidget *frame; GtkWidget *hbox, *tmpbox; GtkWidget *alignment; GtkWidget *notebook; GtkWidget *nbox; GtkWidget *align; + GtkWidget *label; + GtkWidget *hseparator; + GtkWidget *button; + gchar *str; object = g_object_new(CTK_TYPE_DISPLAY_DEVICE, NULL); if (!object) return NULL; @@ -160,39 +167,33 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle, gtk_box_set_spacing(GTK_BOX(object), 10); - /* banner */ + /* Banner */ - banner = ctk_banner_image_new(BANNER_ARTWORK_DFP); + if (strcmp(typeBaseName, "CRT") == 0) { + banner = ctk_banner_image_new(BANNER_ARTWORK_CRT); + } else { + banner = ctk_banner_image_new(BANNER_ARTWORK_DFP); + } gtk_box_pack_start(GTK_BOX(object), banner, FALSE, FALSE, 0); - /* - * create the reset button (which we need while creating the - * controls in this page so that we can set the button's - * sensitivity), though we pack it at the bottom of the page - */ + /* Reset button */ - ctk_object->reset_button = - gtk_button_new_with_label("Reset Hardware Defaults"); + button = gtk_button_new_with_label("Reset Hardware Defaults"); + str = ctk_help_create_reset_hardware_defaults_text(typeBaseName, + name); + ctk_config_set_tooltip(ctk_config, button, str); + ctk_object->reset_button = button; alignment = gtk_alignment_new(1, 1, 0, 0); - gtk_container_add(GTK_CONTAINER(alignment), ctk_object->reset_button); - gtk_box_pack_end(GTK_BOX(object), alignment, TRUE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(alignment), button); + gtk_box_pack_end(GTK_BOX(object), alignment, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(ctk_object->reset_button), - "clicked", G_CALLBACK(reset_button_clicked), - (gpointer) ctk_object); - - ctk_config_set_tooltip(ctk_config, ctk_object->reset_button, - ctk_help_create_reset_hardware_defaults_text(typeBaseName, - name)); /* Create tabbed notebook for widget */ notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); - align = gtk_alignment_new(0, 0, 1, 1); - gtk_container_add(GTK_CONTAINER(align), notebook); - gtk_box_pack_start(GTK_BOX(object), align, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(object), notebook, TRUE, TRUE, 0); /* Create first tab for device info */ @@ -201,16 +202,24 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle, gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nbox, gtk_label_new("Information")); + + /* Device info */ + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(nbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new("Display Device Information"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + hseparator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); + + /* create the hbox to store device info */ hbox = gtk_hbox_new(FALSE, FRAME_PADDING); gtk_box_pack_start(GTK_BOX(nbox), hbox, FALSE, FALSE, FRAME_PADDING); - /* Device info */ - - frame = gtk_frame_new("Device Information"); - gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, FALSE, 0); - /* * insert a vbox between the frame and the widgets, so that the * widgets don't expand to fill all of the space within the @@ -219,7 +228,7 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle, tmpbox = gtk_vbox_new(FALSE, FRAME_PADDING); gtk_container_set_border_width(GTK_CONTAINER(tmpbox), FRAME_PADDING); - gtk_container_add(GTK_CONTAINER(frame), tmpbox); + gtk_container_add(GTK_CONTAINER(hbox), tmpbox); /* Make the txt widgets that will get updated */ ctk_object->txt_chip_location = gtk_label_new(""); @@ -377,18 +386,28 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle, gtk_label_new("Controls")); } - /* show the page */ + /* Update the GUI */ gtk_widget_show_all(GTK_WIDGET(object)); + display_device_setup(ctk_object); - /* Update the GUI */ + /* Listen to events */ - update_display_enabled_flag(ctk_object->handle, - &ctk_object->display_enabled); + g_signal_connect(G_OBJECT(ctk_object->reset_button), + "clicked", G_CALLBACK(reset_button_clicked), + (gpointer) ctk_object); - display_device_setup(ctk_object); + if (ctk_object->txt_link) { + g_signal_connect(G_OBJECT(ctk_event), + CTK_EVENT_NAME(NV_CTRL_FLATPANEL_LINK), + G_CALLBACK(callback_link_changed), + (gpointer) ctk_object); - /* handle enable/disable events on the display device */ + g_signal_connect(G_OBJECT(ctk_event), + CTK_EVENT_NAME(NV_CTRL_DISPLAYPORT_LINK_RATE), + G_CALLBACK(callback_link_changed), + (gpointer) ctk_object); + } g_signal_connect(G_OBJECT(ctk_event), CTK_EVENT_NAME(NV_CTRL_ENABLED_DISPLAYS), @@ -544,13 +563,6 @@ static void update_link(CtkDisplayDevice *ctk_object) } -static void callback_link_changed(GtkObject *object, gpointer arg1, - gpointer user_data) -{ - CtkDisplayDevice *ctk_object = CTK_DISPLAY_DEVICE(user_data); - - update_link(ctk_object); -} /* * update_device_info() - (Re)Queries the static display device information. @@ -559,59 +571,48 @@ static void update_device_info(CtkDisplayDevice *ctk_object) { ReturnStatus ret; gint val; - char *chip_location, *link, *signal; - CtkEvent *ctk_event = ctk_object->ctk_event; - - chip_location = link = signal = "Unknown"; + gchar *str; /* Chip location */ + str = "Unknown"; ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_CHIP_LOCATION, &val); if (ret == NvCtrlSuccess) { switch (val) { case NV_CTRL_FLATPANEL_CHIP_LOCATION_INTERNAL: - chip_location = "Internal"; + str = "Internal"; break; case NV_CTRL_FLATPANEL_CHIP_LOCATION_EXTERNAL: - chip_location = "External"; + str = "External"; break; } } - gtk_label_set_text(GTK_LABEL(ctk_object->txt_chip_location), chip_location); + gtk_label_set_text(GTK_LABEL(ctk_object->txt_chip_location), str); /* Signal */ + str = "Unknown"; ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_SIGNAL, &val); if (ret == NvCtrlSuccess) { switch (val) { case NV_CTRL_FLATPANEL_SIGNAL_LVDS: - signal = "LVDS"; + str = "LVDS"; break; case NV_CTRL_FLATPANEL_SIGNAL_TMDS: - signal = "TMDS"; + str = "TMDS"; break; case NV_CTRL_FLATPANEL_SIGNAL_DISPLAYPORT: - signal = "DisplayPort"; + str = "DisplayPort"; break; } } - gtk_label_set_text(GTK_LABEL(ctk_object->txt_signal), signal); + gtk_label_set_text(GTK_LABEL(ctk_object->txt_signal), str); ctk_object->signal_type = val; /* Link */ - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_FLATPANEL_LINK), - G_CALLBACK(callback_link_changed), - (gpointer) ctk_object); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_DISPLAYPORT_LINK_RATE), - G_CALLBACK(callback_link_changed), - (gpointer) ctk_object); - update_link(ctk_object); /* Native Resolution */ @@ -619,11 +620,10 @@ static void update_device_info(CtkDisplayDevice *ctk_object) ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_NATIVE_RESOLUTION, &val); if (ret == NvCtrlSuccess) { - gchar *resolution = - g_strdup_printf("%dx%d", (val >> 16), (val & 0xFFFF)); + str = g_strdup_printf("%dx%d", (val >> 16), (val & 0xFFFF)); gtk_label_set_text(GTK_LABEL(ctk_object->txt_native_resolution), - resolution); - g_free(resolution); + str); + g_free(str); } else { gtk_label_set_text(GTK_LABEL(ctk_object->txt_native_resolution), "Unknown"); @@ -633,10 +633,10 @@ static void update_device_info(CtkDisplayDevice *ctk_object) ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_REFRESH_RATE, &val); if (ret == NvCtrlSuccess) { - char str[32]; float fvalue = ((float)(val)) / 100.0f; - snprintf(str, 32, "%.2f Hz", fvalue); + str = g_strdup_printf("%.2f Hz", fvalue); gtk_label_set_text(GTK_LABEL(ctk_object->txt_refresh_rate), str); + g_free(str); } else { gtk_label_set_text(GTK_LABEL(ctk_object->txt_refresh_rate), "Unknown"); } @@ -656,6 +656,8 @@ static void display_device_setup(CtkDisplayDevice *ctk_object) */ gtk_widget_set_sensitive(ctk_object->reset_button, FALSE); + update_display_enabled_flag(ctk_object->handle, + &ctk_object->display_enabled); /* Update info */ @@ -676,6 +678,16 @@ static void display_device_setup(CtkDisplayDevice *ctk_object) +static void callback_link_changed(GtkObject *object, gpointer arg1, + gpointer user_data) +{ + CtkDisplayDevice *ctk_object = CTK_DISPLAY_DEVICE(user_data); + + update_link(ctk_object); +} + + + /* * When the list of enabled displays on the GPU changes, * this page should disable/enable access based on whether @@ -688,9 +700,6 @@ static void enabled_displays_received(GtkObject *object, gpointer arg1, /* Requery display information only if display disabled */ - update_display_enabled_flag(ctk_object->handle, - &ctk_object->display_enabled); - display_device_setup(ctk_object); } /* enabled_displays_received() */ diff --git a/src/gtk+-2.x/ctkditheringcontrols.c b/src/gtk+-2.x/ctkditheringcontrols.c index 6898489..95fd3f7 100644 --- a/src/gtk+-2.x/ctkditheringcontrols.c +++ b/src/gtk+-2.x/ctkditheringcontrols.c @@ -494,8 +494,9 @@ void ctk_dithering_controls_setup(CtkDitheringControls *ctk_dithering_controls) if (!update_dithering_info((gpointer)ctk_dithering_controls)) { - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_controls_box, - FALSE); + gtk_widget_hide(ctk_dithering_controls->dithering_controls_box); + } else { + gtk_widget_show(ctk_dithering_controls->dithering_controls_box); } setup_reset_button(ctk_dithering_controls); @@ -507,33 +508,33 @@ static Bool update_dithering_info(gpointer user_data) { CtkDitheringControls *ctk_dithering_controls = CTK_DITHERING_CONTROLS(user_data); - gint val, dithering_mode, dithering_depth; + ReturnStatus ret; + gint val; - /* requested dithering */ - if (NvCtrlSuccess != - NvCtrlGetAttribute(ctk_dithering_controls->handle, - NV_CTRL_DITHERING, &val)) { - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_controls_box, - FALSE); - } else if (val == NV_CTRL_DITHERING_ENABLED || - val == NV_CTRL_DITHERING_AUTO) { - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_controls_box, + ret = NvCtrlGetAttribute(ctk_dithering_controls->handle, + NV_CTRL_DITHERING, &val); + if (ret != NvCtrlSuccess) { + /* Dithering is not currently available */ + return FALSE; + } + + if (val == NV_CTRL_DITHERING_ENABLED || + val == NV_CTRL_DITHERING_AUTO) { + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, TRUE); - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, TRUE); - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_depth_box, TRUE); - gtk_widget_show(ctk_dithering_controls->dithering_mode_box); - gtk_widget_show(ctk_dithering_controls->dithering_depth_box); - } else if (val == NV_CTRL_DITHERING_DISABLED) { - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_controls_box, + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_depth_box, TRUE); - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, FALSE); - gtk_widget_set_sensitive(ctk_dithering_controls->dithering_depth_box, FALSE); + } else if (val == NV_CTRL_DITHERING_DISABLED) { + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, + FALSE); + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_depth_box, + FALSE); } /* current dithering */ - if (NvCtrlSuccess != - NvCtrlGetAttribute(ctk_dithering_controls->handle, - NV_CTRL_CURRENT_DITHERING, &val)) { + ret = NvCtrlGetAttribute(ctk_dithering_controls->handle, + NV_CTRL_CURRENT_DITHERING, &val); + if (ret != NvCtrlSuccess) { val = NV_CTRL_CURRENT_DITHERING_DISABLED; } @@ -546,15 +547,13 @@ static Bool update_dithering_info(gpointer user_data) } /* dithering mode */ - if (NvCtrlSuccess != - NvCtrlGetAttribute(ctk_dithering_controls->handle, - NV_CTRL_DITHERING_MODE, - &dithering_mode)) { - dithering_mode = NV_CTRL_DITHERING_MODE_AUTO; + ret = NvCtrlGetAttribute(ctk_dithering_controls->handle, + NV_CTRL_DITHERING_MODE, &val); + if (ret != NvCtrlSuccess) { + val = NV_CTRL_DITHERING_MODE_AUTO; } - dithering_mode = map_nvctrl_value_to_table(ctk_dithering_controls, - dithering_mode); + val = map_nvctrl_value_to_table(ctk_dithering_controls, val); g_signal_handlers_block_by_func (G_OBJECT(ctk_dithering_controls->dithering_mode_menu), @@ -562,8 +561,7 @@ static Bool update_dithering_info(gpointer user_data) (gpointer) ctk_dithering_controls); gtk_option_menu_set_history - (GTK_OPTION_MENU(ctk_dithering_controls->dithering_mode_menu), - dithering_mode); + (GTK_OPTION_MENU(ctk_dithering_controls->dithering_mode_menu), val); g_signal_handlers_unblock_by_func (G_OBJECT(ctk_dithering_controls->dithering_mode_menu), @@ -571,14 +569,13 @@ static Bool update_dithering_info(gpointer user_data) (gpointer) ctk_dithering_controls); /* current dithering mode */ - if (NvCtrlSuccess != - NvCtrlGetAttribute(ctk_dithering_controls->handle, - NV_CTRL_CURRENT_DITHERING_MODE, - &dithering_mode)) { - dithering_mode = NV_CTRL_CURRENT_DITHERING_MODE_NONE; + ret = NvCtrlGetAttribute(ctk_dithering_controls->handle, + NV_CTRL_CURRENT_DITHERING_MODE, &val); + if (ret != NvCtrlSuccess) { + val = NV_CTRL_CURRENT_DITHERING_MODE_NONE; } - switch (dithering_mode) { + switch (val) { case NV_CTRL_CURRENT_DITHERING_MODE_DYNAMIC_2X2: gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_mode_txt), "Dynamic 2x2"); @@ -599,11 +596,10 @@ static Bool update_dithering_info(gpointer user_data) } /* dithering depth */ - if (NvCtrlSuccess != - NvCtrlGetAttribute(ctk_dithering_controls->handle, - NV_CTRL_DITHERING_DEPTH, - &dithering_depth)) { - dithering_depth = NV_CTRL_DITHERING_DEPTH_AUTO; + ret = NvCtrlGetAttribute(ctk_dithering_controls->handle, + NV_CTRL_DITHERING_DEPTH, &val); + if (ret != NvCtrlSuccess) { + val = NV_CTRL_DITHERING_DEPTH_AUTO; } g_signal_handlers_block_by_func @@ -612,8 +608,7 @@ static Bool update_dithering_info(gpointer user_data) (gpointer) ctk_dithering_controls); gtk_option_menu_set_history - (GTK_OPTION_MENU(ctk_dithering_controls->dithering_depth_menu), - dithering_depth); + (GTK_OPTION_MENU(ctk_dithering_controls->dithering_depth_menu), val); g_signal_handlers_unblock_by_func (G_OBJECT(ctk_dithering_controls->dithering_depth_menu), @@ -621,14 +616,13 @@ static Bool update_dithering_info(gpointer user_data) (gpointer) ctk_dithering_controls); /* current dithering depth */ - if (NvCtrlSuccess != - NvCtrlGetAttribute(ctk_dithering_controls->handle, - NV_CTRL_CURRENT_DITHERING_DEPTH, - &dithering_depth)) { - dithering_depth = NV_CTRL_CURRENT_DITHERING_DEPTH_NONE; + ret = NvCtrlGetAttribute(ctk_dithering_controls->handle, + NV_CTRL_CURRENT_DITHERING_DEPTH, &val); + if (ret != NvCtrlSuccess) { + val = NV_CTRL_CURRENT_DITHERING_DEPTH_NONE; } - switch (dithering_depth) { + switch (val) { case NV_CTRL_CURRENT_DITHERING_DEPTH_6_BITS: gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_depth_txt), "6 bpc"); @@ -644,7 +638,8 @@ static Bool update_dithering_info(gpointer user_data) break; } - return True; + return TRUE; + } /* update_dithering_info() */ static diff --git a/src/gtk+-2.x/ctkframelock.c b/src/gtk+-2.x/ctkframelock.c index 6c6bfb6..b93617c 100644 --- a/src/gtk+-2.x/ctkframelock.c +++ b/src/gtk+-2.x/ctkframelock.c @@ -79,9 +79,7 @@ enum * that entry. */ -#define NUM_GPU_SIGNALS 7 - -const char *__GPUSignals[NUM_GPU_SIGNALS] = +const char *__GPUSignals[] = { CTK_EVENT_NAME(NV_CTRL_FRAMELOCK_MASTER), CTK_EVENT_NAME(NV_CTRL_FRAMELOCK_SLAVES), @@ -99,9 +97,7 @@ const char *__GPUSignals[NUM_GPU_SIGNALS] = * that entry. */ -#define NUM_FRAMELOCK_SIGNALS 4 - -const char *__FrameLockSignals[NUM_FRAMELOCK_SIGNALS] = +const char *__FrameLockSignals[] = { CTK_EVENT_NAME(NV_CTRL_USE_HOUSE_SYNC), CTK_EVENT_NAME(NV_CTRL_FRAMELOCK_SYNC_INTERVAL), @@ -200,9 +196,6 @@ struct _nvGPUDataRec { GtkWidget *timing_label; GtkWidget *timing_hbox; /* LED */ - /* Signal Handler IDs */ - gulong signal_ids[NUM_GPU_SIGNALS]; - GtkWidget *label; }; @@ -213,9 +206,6 @@ struct _nvFrameLockDataRec { int sync_delay_resolution; - /* Signal Handler IDs */ - gulong signal_ids[NUM_FRAMELOCK_SIGNALS]; - GtkWidget *label; GtkWidget *receiving_label; @@ -329,10 +319,10 @@ static const char * __client_checkbox_help = -static unsigned int add_framelock_devices(CtkFramelock *, gpointer, int); -static unsigned int add_gpu_devices(CtkFramelock *, nvListEntryPtr); -static unsigned int add_display_devices(CtkFramelock *, nvListEntryPtr); -static gint add_devices(CtkFramelock *, const gchar *, gboolean); +static void add_framelock_devices(CtkFramelock *, gpointer, int); +static void add_gpu_devices(CtkFramelock *, nvListEntryPtr); +static void add_display_devices(CtkFramelock *, nvListEntryPtr); +static void add_devices(CtkFramelock *, const gchar *, gboolean); static GtkWidget *create_add_devices_dialog(CtkFramelock *); static GtkWidget *create_remove_devices_dialog(CtkFramelock *); @@ -923,27 +913,23 @@ static char *get_framelock_name(nvFrameLockDataPtr data, gboolean simple) -/** get_entry_label() ************************************************ +/** list_entry_get_name() ******************************************** * * Returns the correct label for the given entry. * */ -static gchar *get_entry_label(nvListEntryPtr entry, gboolean simple) +static gchar *list_entry_get_name(nvListEntryPtr entry, gboolean simple) { - char *str = NULL; - - if (entry->data_type == ENTRY_DATA_FRAMELOCK) { - str = get_framelock_name((nvFrameLockDataPtr)(entry->data), simple); - - } else if (entry->data_type == ENTRY_DATA_GPU) { - str = get_gpu_name((nvGPUDataPtr)(entry->data), simple); - - } else if (entry->data_type == ENTRY_DATA_DISPLAY) { - str = get_display_name((nvDisplayDataPtr)(entry->data), simple); - + switch (entry->data_type) { + case ENTRY_DATA_FRAMELOCK: + return get_framelock_name((nvFrameLockDataPtr)(entry->data), simple); + case ENTRY_DATA_GPU: + return get_gpu_name((nvGPUDataPtr)(entry->data), simple); + case ENTRY_DATA_DISPLAY: + return get_display_name((nvDisplayDataPtr)(entry->data), simple); } - return str; + return NULL; } @@ -956,31 +942,32 @@ static gchar *get_entry_label(nvListEntryPtr entry, gboolean simple) static void update_entry_label(CtkFramelock *ctk_framelock, nvListEntryPtr entry) { - char *str = NULL; + char *str; gboolean simple; simple = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(ctk_framelock->short_labels_button)); - if (entry->data_type == ENTRY_DATA_FRAMELOCK) { - str = get_framelock_name((nvFrameLockDataPtr)(entry->data), simple); + str = list_entry_get_name(entry, simple); + + switch (entry->data_type) { + case ENTRY_DATA_FRAMELOCK: gtk_label_set_text(GTK_LABEL (((nvFrameLockDataPtr)(entry->data))->label), str?str:"Unknown G-Sync"); - - } else if (entry->data_type == ENTRY_DATA_GPU) { - str = get_gpu_name((nvGPUDataPtr)(entry->data), simple); + break; + case ENTRY_DATA_GPU: gtk_label_set_text(GTK_LABEL (((nvGPUDataPtr)(entry->data))->label), str?str:"Unknown GPU"); - - } else if (entry->data_type == ENTRY_DATA_DISPLAY) { - str = get_display_name((nvDisplayDataPtr)(entry->data), simple); + break; + case ENTRY_DATA_DISPLAY: gtk_label_set_text(GTK_LABEL (((nvDisplayDataPtr)(entry->data))->label), str?str:"Unknown Display"); + break; } - + if (str) { g_free(str); } @@ -1019,15 +1006,15 @@ static void show_remove_devices_dialog(GtkWidget *button, { nvListTreePtr tree; nvListEntryPtr entry; - gchar *str = NULL, *label; + gchar *str = NULL, *name; tree = (nvListTreePtr)(ctk_framelock->tree); entry = tree->selected_entry; if (!entry) return; - label = get_entry_label(entry, 0); - if (!label) { + name = list_entry_get_name(entry, 0); + if (!name) { str = g_strconcat("Would you like to remove the selected entry " "from the group?" "\n\nNOTE: This will also remove any entries " @@ -1036,17 +1023,18 @@ static void show_remove_devices_dialog(GtkWidget *button, } else if (entry->nchildren) { str = g_strconcat("Would you like to remove the following entry " "from the group?\n\n<span weight=\"bold\" " - "size=\"larger\">", label, "</span>", + "size=\"larger\">", name, "</span>", "\n\nNOTE: This will also remove any entries " "under this one.", NULL); - g_free(label); } else { str = g_strconcat("Would you like to remove the following entry " "from the group?\n\n<span weight=\"bold\" " - "size=\"larger\">", label, "</span>", + "size=\"larger\">", name, "</span>", NULL); - g_free(label); + } + if (name) { + g_free(name); } gtk_label_set_line_wrap(GTK_LABEL(ctk_framelock->remove_devices_label), @@ -1058,7 +1046,7 @@ static void show_remove_devices_dialog(GtkWidget *button, str); g_free(str); } - + gtk_widget_show_all(ctk_framelock->remove_devices_dialog); } @@ -1294,14 +1282,16 @@ static void list_entry_update_controls(CtkFramelock *ctk_framelock, { if (!entry) return; - if (entry->data_type == ENTRY_DATA_FRAMELOCK) { + switch (entry->data_type) { + case ENTRY_DATA_FRAMELOCK: list_entry_update_framelock_controls(ctk_framelock, entry); - - } else if (entry->data_type == ENTRY_DATA_GPU) { + break; + case ENTRY_DATA_GPU: list_entry_update_gpu_controls(ctk_framelock, entry); - - } else if (entry->data_type == ENTRY_DATA_DISPLAY) { + break; + case ENTRY_DATA_DISPLAY: list_entry_update_display_controls(ctk_framelock, entry); + break; } /* @@ -1791,6 +1781,41 @@ static nvListEntryPtr list_entry_new(void) +static void framelock_data_free(nvFrameLockDataPtr data) +{ + if (!data) return; + + if (data->handle) { + NvCtrlAttributeClose(data->handle); + } + + free(data); +} + + + +static void gpu_data_free(nvGPUDataPtr data) +{ + if (!data) return; + + if (data->handle) { + NvCtrlAttributeClose(data->handle); + } + + free(data); +} + + + +static void display_data_free(nvDisplayDataPtr data) +{ + if (!data) return; + + free(data); +} + + + /** list_entry_free() ************************************************ * * - Frees an existing list entry. @@ -1798,49 +1823,34 @@ static nvListEntryPtr list_entry_new(void) */ static void list_entry_free(nvListEntryPtr entry) { - int i; - - if (!entry) { return; } - /* XXX DON"T Need these? - gtk_widget_destroy(entry->vbox); - gtk_widget_destroy(entry->title_hbox); - gtk_widget_destroy(entry->data_hbox); - gtk_widget_destroy(entry->ebox); - */ - /* Remove signal callbacks */ if (entry->ctk_event) { - if (entry->data_type == ENTRY_DATA_GPU) { - - nvGPUDataPtr data = (nvGPUDataPtr) entry->data; - - for (i = 0; i < NUM_GPU_SIGNALS; i++) { - if (g_signal_handler_is_connected(G_OBJECT(entry->ctk_event), - data->signal_ids[i])) { - g_signal_handler_disconnect(G_OBJECT(entry->ctk_event), - data->signal_ids[i]); - } - } - - } else if (entry->data_type == ENTRY_DATA_FRAMELOCK) { - - nvFrameLockDataPtr data = (nvFrameLockDataPtr) entry->data; - - for (i = 0; i < NUM_FRAMELOCK_SIGNALS; i++) { - if (g_signal_handler_is_connected(G_OBJECT(entry->ctk_event), - data->signal_ids[i])) { - g_signal_handler_disconnect(G_OBJECT(entry->ctk_event), - data->signal_ids[i]); - } - } - } + g_signal_handlers_disconnect_matched(G_OBJECT(entry->ctk_event), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, (gpointer) entry); + + // XXX Free ctk_event object when we add that functionality. + } - /* XXX We should probably free/destroy the ctk_event objects here */ + /* Free any data associated with the entry */ + + if (entry->data) { + switch (entry->data_type) { + case ENTRY_DATA_FRAMELOCK: + framelock_data_free((nvFrameLockDataPtr)entry->data); + break; + case ENTRY_DATA_GPU: + gpu_data_free((nvGPUDataPtr)entry->data); + break; + case ENTRY_DATA_DISPLAY: + display_data_free((nvDisplayDataPtr)entry->data); + break; + } } free(entry); @@ -3736,12 +3746,16 @@ static void list_entry_update_status(CtkFramelock *ctk_framelock, list_entry_update_status(ctk_framelock, entry->children); - if (entry->data_type == ENTRY_DATA_FRAMELOCK) { + switch (entry->data_type) { + case ENTRY_DATA_FRAMELOCK: list_entry_update_framelock_status(ctk_framelock, entry); - } else if (entry->data_type == ENTRY_DATA_GPU) { + break; + case ENTRY_DATA_GPU: list_entry_update_gpu_status(ctk_framelock, entry); - } else if (entry->data_type == ENTRY_DATA_DISPLAY) { + break; + case ENTRY_DATA_DISPLAY: list_entry_update_display_status(ctk_framelock, entry); + break; } list_entry_update_status(ctk_framelock, entry->next_sibling); @@ -4904,8 +4918,7 @@ static void add_devices_response(GtkWidget *button, gint response, { CtkFramelock *ctk_framelock = CTK_FRAMELOCK(user_data); const gchar *display_name; - gint devices_added; - + /* hide the dialog box */ gtk_widget_hide_all(ctk_framelock->add_devices_dialog); @@ -4924,9 +4937,10 @@ static void add_devices_response(GtkWidget *button, gint response, gtk_entry_get_text(GTK_ENTRY(ctk_framelock->add_devices_entry)); /* Add all devices found on the server */ - - devices_added = add_devices(ctk_framelock, display_name, TRUE); - if (!devices_added) { + + add_devices(ctk_framelock, display_name, TRUE); + if (!ctk_framelock->tree || + !((nvListTreePtr)(ctk_framelock->tree))->nentries) { /* Nothing was added, nothing to update */ return; } @@ -4959,15 +4973,15 @@ static void remove_devices_response(GtkWidget *button, gint response, CtkFramelock *ctk_framelock = CTK_FRAMELOCK(user_data); nvListTreePtr tree = (nvListTreePtr)(ctk_framelock->tree); nvListEntryPtr entry = tree->selected_entry; - gchar *label; - + gchar *name; + gtk_widget_hide_all(ctk_framelock->remove_devices_dialog); if (response != GTK_RESPONSE_OK) return; if (!entry) return; - label = get_entry_label(entry, 0); + name = list_entry_get_name(entry, 0); /* Remove entry from list */ list_tree_remove_entry(tree, entry); @@ -4992,8 +5006,8 @@ static void remove_devices_response(GtkWidget *button, gint response, ctk_config_statusbar_message(ctk_framelock->ctk_config, "Removed '%s' from the frame lock group.", - label); - g_free(label); + name); + g_free(name); } @@ -5004,10 +5018,9 @@ static void remove_devices_response(GtkWidget *button, gint response, * are bound to the given GPU List Entry. * */ -static unsigned int add_display_devices(CtkFramelock *ctk_framelock, - nvListEntryPtr gpu_entry) +static void add_display_devices(CtkFramelock *ctk_framelock, + nvListEntryPtr gpu_entry) { - unsigned int displays_added = 0; nvDisplayDataPtr display_data = NULL; nvGPUDataPtr gpu_data; @@ -5021,9 +5034,8 @@ static unsigned int add_display_devices(CtkFramelock *ctk_framelock, unsigned int slaves_mask; gfloat fvalue; /* To print the refresh rate */ gchar rr_str[32]; - + nvListEntryPtr server_entry = NULL; - nvDisplayDataPtr server_data = NULL; if (!gpu_entry || gpu_entry->data_type != ENTRY_DATA_GPU) { @@ -5032,9 +5044,6 @@ static unsigned int add_display_devices(CtkFramelock *ctk_framelock, server_entry = get_display_server_entry((nvListTreePtr)(ctk_framelock->tree)); - if (server_entry) { - server_data = (nvDisplayDataPtr)(server_entry->data); - } gpu_data = (nvGPUDataPtr)(gpu_entry->data); @@ -5213,21 +5222,16 @@ static unsigned int add_display_devices(CtkFramelock *ctk_framelock, "toggled", G_CALLBACK(toggle_client), (gpointer) entry); - - displays_added++; } display_mask <<= 1; } - return displays_added; + return; /* Handle failures */ - fail: - if (display_data) { - free(display_data); - } - return displays_added; + fail: + display_data_free(display_data); } @@ -5238,11 +5242,10 @@ static unsigned int add_display_devices(CtkFramelock *ctk_framelock, * the given frame lock list entry. * */ -static unsigned int add_gpu_devices(CtkFramelock *ctk_framelock, - nvListEntryPtr framelock_entry) +static void add_gpu_devices(CtkFramelock *ctk_framelock, + nvListEntryPtr framelock_entry) { unsigned int num_gpus; - unsigned int gpus_added = 0; unsigned int gpu_id; unsigned int gpu_idx; nvGPUDataPtr gpu_data = NULL; @@ -5274,14 +5277,11 @@ static unsigned int add_gpu_devices(CtkFramelock *ctk_framelock, gpus = (int *)data; num_gpus = gpus[0]; for (gpu_idx = 0; gpu_idx < num_gpus; gpu_idx++) { - int displays_added = 0; - gpu_id = gpus[gpu_idx +1]; /* Create the GPU data structure */ gpu_data = (nvGPUDataPtr) calloc(1, sizeof(nvGPUDataRec)); if (!gpu_data) { - XFree(data); goto fail; } @@ -5303,8 +5303,8 @@ static unsigned int add_gpu_devices(CtkFramelock *ctk_framelock, list_entry_update_status(ctk_framelock, entry); /* Add Displays tied to this GPU */ - displays_added = add_display_devices(ctk_framelock, entry); - if (displays_added) { + add_display_devices(ctk_framelock, entry); + if (entry->children) { int i; list_entry_add_child(framelock_entry, entry); @@ -5320,15 +5320,12 @@ static unsigned int add_gpu_devices(CtkFramelock *ctk_framelock, entry->ctk_event = CTK_EVENT(ctk_event_new(gpu_data->handle)); - for (i = 0; i < NUM_GPU_SIGNALS; i++) { - gpu_data->signal_ids[i] = - g_signal_connect(G_OBJECT(entry->ctk_event), - __GPUSignals[i], - G_CALLBACK(gpu_state_received), - (gpointer) entry); + for (i = 0; i < ARRAY_LEN(__GPUSignals); i++) { + g_signal_connect(G_OBJECT(entry->ctk_event), + __GPUSignals[i], + G_CALLBACK(gpu_state_received), + (gpointer) entry); } - - gpus_added++; } else { /* No Displays found, don't add this GPU device */ list_entry_free(entry); @@ -5337,18 +5334,13 @@ static unsigned int add_gpu_devices(CtkFramelock *ctk_framelock, XFree(data); - return gpus_added; + return; /* Handle failures */ fail: - if (gpu_data) { - if (gpu_data->handle) { - NvCtrlAttributeClose(gpu_data->handle); - } - free(gpu_data); - } - return gpus_added; + XFree(data); + gpu_data_free(gpu_data); } @@ -5359,12 +5351,11 @@ static unsigned int add_gpu_devices(CtkFramelock *ctk_framelock, * the frame lock group, * */ -static unsigned int add_framelock_devices(CtkFramelock *ctk_framelock, - gpointer handle, - int server_id) +static void add_framelock_devices(CtkFramelock *ctk_framelock, + gpointer handle, + int server_id) { unsigned int num_framelocks; - unsigned int framelocks_added = 0; unsigned int framelock_id; nvFrameLockDataPtr framelock_data = NULL; nvListEntryPtr entry; @@ -5382,7 +5373,6 @@ static unsigned int add_framelock_devices(CtkFramelock *ctk_framelock, /* Add frame lock devices found */ for (framelock_id = 0; framelock_id < num_framelocks; framelock_id++) { - int gpus_added = 0; int val; char *revision_str = NULL; @@ -5455,45 +5445,36 @@ static unsigned int add_framelock_devices(CtkFramelock *ctk_framelock, update_entry_label(ctk_framelock, entry); list_entry_update_status(ctk_framelock, entry); - + /* Add GPUs tied to this G-Sync */ - gpus_added = add_gpu_devices(ctk_framelock, entry); - if (gpus_added) { + add_gpu_devices(ctk_framelock, entry); + if (entry->children) { int i; list_tree_add_entry((nvListTreePtr)(ctk_framelock->tree), entry); - + entry->ctk_event = CTK_EVENT(ctk_event_new(framelock_data->handle)); - for (i = 0; i < NUM_FRAMELOCK_SIGNALS; i++) { - framelock_data->signal_ids[i] = - g_signal_connect(G_OBJECT(entry->ctk_event), - __FrameLockSignals[i], - G_CALLBACK(framelock_state_received), - (gpointer) entry); + for (i = 0; i < ARRAY_LEN(__FrameLockSignals); i++) { + g_signal_connect(G_OBJECT(entry->ctk_event), + __FrameLockSignals[i], + G_CALLBACK(framelock_state_received), + (gpointer) entry); } - - framelocks_added++; } else { /* No GPUs found, don't add this frame lock device */ list_entry_free(entry); } } - return framelocks_added; + return; /* Handle failures */ fail: - if (framelock_data) { - if (framelock_data->handle) { - NvCtrlAttributeClose(framelock_data->handle); - } - free(framelock_data); - } - return framelocks_added; + framelock_data_free(framelock_data); } @@ -5504,14 +5485,13 @@ static unsigned int add_framelock_devices(CtkFramelock *ctk_framelock, * frame lock group, * */ -static gint add_devices(CtkFramelock *ctk_framelock, +static void add_devices(CtkFramelock *ctk_framelock, const gchar *display_name, gboolean error_dialog) { gpointer handle = NULL; Display *display; int server_id = -1; - gint devices_added = 0; char *server_name = NULL; char *ptr; @@ -5606,8 +5586,9 @@ static gint add_devices(CtkFramelock *ctk_framelock, /* Add frame lock devices found on server */ - devices_added = add_framelock_devices(ctk_framelock, handle, server_id); - if (!devices_added) { + add_framelock_devices(ctk_framelock, handle, server_id); + if (!ctk_framelock->tree || + !((nvListTreePtr)(ctk_framelock->tree))->nentries) { if (error_dialog) { error_msg(ctk_framelock, "<span weight=\"bold\" " "size=\"larger\">No frame lock devices " @@ -5636,7 +5617,7 @@ static gint add_devices(CtkFramelock *ctk_framelock, NvCtrlAttributeClose(handle); } - return devices_added; + return; } diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c index d3d24f8..f8dec3e 100644 --- a/src/gtk+-2.x/ctkwindow.c +++ b/src/gtk+-2.x/ctkwindow.c @@ -56,7 +56,6 @@ #include "ctkpowersavings.h" #include "ctk3dvisionpro.h" -#include "ctkdisplaydevice-crt.h" #include "ctkdisplaydevice-tv.h" #include "ctkdisplaydevice.h" @@ -120,7 +119,6 @@ static void save_settings_and_exit(CtkWindow *); static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, NvCtrlAttributeHandle *handle, - CtkEvent *ctk_event, GtkTextTagTable *tag_table, UpdateDisplaysData *data); @@ -854,14 +852,13 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, data->gpu_handle = gpu_handle; data->parent_iter = iter; data->tag_table = tag_table; - + g_signal_connect(G_OBJECT(ctk_event), CTK_EVENT_NAME(NV_CTRL_PROBE_DISPLAYS), G_CALLBACK(update_display_devices), - (gpointer) data); - - add_display_devices(ctk_window, &iter, gpu_handle, ctk_event, - tag_table, data); + (gpointer) data); + + add_display_devices(ctk_window, &iter, gpu_handle, tag_table, data); } /* add the per-vcs (e.g. Quadro Plex) entries into the tree model */ @@ -1352,7 +1349,6 @@ void add_special_config_file_attributes(CtkWindow *ctk_window) static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, NvCtrlAttributeHandle *gpu_handle, - CtkEvent *ctk_event, GtkTextTagTable *tag_table, UpdateDisplaysData *data) { @@ -1391,6 +1387,7 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, char *typeIdName; GtkWidget *widget; gchar *title; + CtkEvent *ctk_event; display_handle = NvCtrlAttributeInit(NvCtrlGetDisplayPtr(gpu_handle), @@ -1401,6 +1398,8 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, continue; } + ctk_event = CTK_EVENT(ctk_event_new(display_handle)); + /* Query display's names */ ret = NvCtrlGetStringAttribute(display_handle, NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME, @@ -1431,17 +1430,13 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, XFree(typeIdName); /* Create the appropriate page for the display */ - if (strcmp(typeBaseName, "CRT") == 0) { - widget = ctk_display_device_crt_new - (display_handle, ctk_window->ctk_config, ctk_event, title); - help = ctk_display_device_crt_create_help - (tag_table, CTK_DISPLAY_DEVICE_CRT(widget)); - } else if (strcmp(typeBaseName, "TV") == 0) { + if (strcmp(typeBaseName, "TV") == 0) { widget = ctk_display_device_tv_new (display_handle, ctk_window->ctk_config, ctk_event, title); help = ctk_display_device_tv_create_help (tag_table, CTK_DISPLAY_DEVICE_TV(widget)); - } else if (strcmp(typeBaseName, "DFP") == 0) { + } else if ((strcmp(typeBaseName, "DFP") == 0) || + (strcmp(typeBaseName, "CRT") == 0)) { widget = ctk_display_device_new(display_handle, ctk_window->ctk_config, ctk_event, title, typeBaseName); @@ -1480,7 +1475,6 @@ static void update_display_devices(GtkObject *object, gpointer arg1, UpdateDisplaysData *data = (UpdateDisplaysData *) user_data; CtkWindow *ctk_window = data->window; - CtkEvent *ctk_event = data->event; NvCtrlAttributeHandle *gpu_handle = data->gpu_handle; GtkTreeIter parent_iter = data->parent_iter; GtkTextTagTable *tag_table = data->tag_table; @@ -1520,10 +1514,9 @@ static void update_display_devices(GtkObject *object, gpointer arg1, data->num_displays--; } - + /* Add back all the connected display devices */ - add_display_devices(ctk_window, &parent_iter, gpu_handle, ctk_event, - tag_table, data); + add_display_devices(ctk_window, &parent_iter, gpu_handle, tag_table, data); /* Expand the GPU entry if it used to be */ if (parent_expanded) { diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h index dbefc6e..b749c85 100644 --- a/src/libXNVCtrl/NVCtrl.h +++ b/src/libXNVCtrl/NVCtrl.h @@ -3964,6 +3964,8 @@ * for details. * "nv-control" - the MetaMode was added via the NV-CONTROL X * extension to the currently running X server. + * "RandR" - the MetaMode was modified in response to an + * RandR RRSetCrtcConfig request. * * Additional tokens may be added in the future, so it is recommended * that any token parser processing the returned string from diff --git a/src/parse.c b/src/parse.c index 0df6942..496931a 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1705,8 +1705,9 @@ const char *parse_read_name(const char *str, char **name, char term) str = parse_skip_whitespace(str); tmp = str; - while (*str && !name_terminated(*str, term)) + while (*str && !name_terminated(*str, term)) { str++; + } *name = calloc(1, str - tmp + 1); if (!(*name)) { @@ -1830,33 +1831,48 @@ int parse_read_float_range(const char *str, float *min, float *max) * and dispatches the handeling of tokens to the given function with * the given data as an extra argument. * + * Note that the value may be in parentheses: "token=(value), ..." + * **/ int parse_token_value_pairs(const char *str, apply_token_func func, void *data) { char *token; char *value; + char endChar; if (str) { /* Parse each token */ while (*str) { - + /* Read the token */ str = parse_read_name(str, &token, '='); if (!str) return 0; - + /* Read the value */ - str = parse_read_name(str, &value, ','); + if (str && *str == '(') { + str++; + endChar = ')'; + } else { + endChar = ','; + } + str = parse_read_name(str, &value, endChar); if (!str) return 0; - + if (endChar == ')' && *str == ')') { + str++; + } + if (*str == ',') { + str++; + } + /* Remove trailing whitespace */ parse_chop_whitespace(token); parse_chop_whitespace(value); - + func(token, value, data); - + free(token); free(value); } @@ -188,7 +188,6 @@ GTK_SRC += gtk+-2.x/ctkopengl.c GTK_SRC += gtk+-2.x/ctkglx.c GTK_SRC += gtk+-2.x/ctkhelp.c GTK_SRC += gtk+-2.x/ctkimagesliders.c -GTK_SRC += gtk+-2.x/ctkdisplaydevice-crt.c GTK_SRC += gtk+-2.x/ctkdisplaydevice-tv.c GTK_SRC += gtk+-2.x/ctkdisplaydevice.c GTK_SRC += gtk+-2.x/ctkditheringcontrols.c @@ -236,7 +235,6 @@ GTK_EXTRA_DIST += gtk+-2.x/ctkopengl.h GTK_EXTRA_DIST += gtk+-2.x/ctkglx.h GTK_EXTRA_DIST += gtk+-2.x/ctkhelp.h GTK_EXTRA_DIST += gtk+-2.x/ctkimagesliders.h -GTK_EXTRA_DIST += gtk+-2.x/ctkdisplaydevice-crt.h GTK_EXTRA_DIST += gtk+-2.x/ctkdisplaydevice-tv.h GTK_EXTRA_DIST += gtk+-2.x/ctkdisplaydevice.h GTK_EXTRA_DIST += gtk+-2.x/ctkditheringcontrols.h diff --git a/src/version.mk b/src/version.mk index c29a7ba..8863143 100644 --- a/src/version.mk +++ b/src/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 302.07 +NVIDIA_VERSION = 302.11 |