@@ -114,6 +114,7 @@ struct _XAppGpuOffloadHelper
114114
115115 GMutex gpu_infos_mutex ;
116116 GList * gpu_infos ; // XAppGpuInfos
117+ GHashTable * discrete_infos ;
117118
118119 gboolean ready ;
119120
@@ -136,6 +137,7 @@ process_gpus_property (XAppGpuOffloadHelper *helper,
136137{
137138 GVariant * gpus ;
138139 GList * infos = NULL ;
140+ GHashTable * discrete_infos = g_hash_table_new (g_direct_hash , g_direct_equal );
139141 gint num_children , i ;
140142 gboolean default_found = FALSE;
141143
@@ -195,9 +197,12 @@ process_gpus_property (XAppGpuOffloadHelper *helper,
195197 info -> display_name = g_strdup (name );
196198 info -> env_strv = g_strdupv ((gchar * * ) env_strv );
197199 info -> is_default = is_default ;
198- info -> is_discrete = is_discrete ;
199200
200201 infos = g_list_append (infos , info );
202+ if (is_discrete )
203+ {
204+ g_hash_table_add (discrete_infos , info );
205+ }
201206 }
202207
203208 if (infos == NULL )
@@ -221,6 +226,7 @@ process_gpus_property (XAppGpuOffloadHelper *helper,
221226 g_list_free_full (helper -> gpu_infos , (GDestroyNotify ) xapp_gpu_info_free );
222227 helper -> gpu_infos = infos ;
223228 helper -> num_gpus = g_list_length (helper -> gpu_infos );
229+ helper -> discrete_infos = discrete_infos ;
224230
225231 g_mutex_unlock (& helper -> gpu_infos_mutex );
226232}
@@ -440,6 +446,7 @@ xapp_gpu_offload_helper_dispose (GObject *object)
440446 helper -> gpu_infos = NULL ;
441447 }
442448
449+ g_clear_pointer (& helper -> discrete_infos , g_hash_table_unref );
443450 g_clear_object (& helper -> cancellable );
444451 g_clear_object (& helper -> control );
445452
@@ -639,7 +646,7 @@ xapp_gpu_offload_helper_get_offload_infos (XAppGpuOffloadHelper *helper)
639646 if (!info -> is_default )
640647 continue ;
641648
642- if (info -> is_discrete )
649+ if (g_hash_table_contains ( helper -> discrete_infos , info ) )
643650 retval = g_list_append (retval , info );
644651 break ;
645652 }
@@ -649,7 +656,7 @@ xapp_gpu_offload_helper_get_offload_infos (XAppGpuOffloadHelper *helper)
649656 {
650657 XAppGpuInfo * info = l -> data ;
651658
652- if (!info -> is_discrete )
659+ if (!g_hash_table_contains ( helper -> discrete_infos , info ) )
653660 continue ;
654661
655662 retval = g_list_append (retval , info );
0 commit comments