mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-11-04 04:30:04 +00:00 
			
		
		
		
	Merge pull request #479 from AdenKoperczak/no-wayland-on-nvidia
Disable Wayland platform plugin on Nvidia
This commit is contained in:
		
						commit
						4bd749d976
					
				
					 1 changed files with 34 additions and 0 deletions
				
			
		| 
						 | 
					@ -19,6 +19,8 @@
 | 
				
			||||||
#include <scwx/util/logger.hpp>
 | 
					#include <scwx/util/logger.hpp>
 | 
				
			||||||
#include <scwx/util/threads.hpp>
 | 
					#include <scwx/util/threads.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <filesystem>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,6 +44,7 @@ static const auto        logger_    = scwx::util::Logger::Create(logPrefix_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void ConfigureTheme(const std::vector<std::string>& args);
 | 
					static void ConfigureTheme(const std::vector<std::string>& args);
 | 
				
			||||||
static void OverrideDefaultStyle(const std::vector<std::string>& args);
 | 
					static void OverrideDefaultStyle(const std::vector<std::string>& args);
 | 
				
			||||||
 | 
					static void OverridePlatform();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char* argv[])
 | 
					int main(int argc, char* argv[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -52,6 +55,8 @@ int main(int argc, char* argv[])
 | 
				
			||||||
      args.push_back(argv[i]);
 | 
					      args.push_back(argv[i]);
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   OverridePlatform();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   // Initialize logger
 | 
					   // Initialize logger
 | 
				
			||||||
   auto& logManager = scwx::qt::manager::LogManager::Instance();
 | 
					   auto& logManager = scwx::qt::manager::LogManager::Instance();
 | 
				
			||||||
   logManager.Initialize();
 | 
					   logManager.Initialize();
 | 
				
			||||||
| 
						 | 
					@ -252,3 +257,32 @@ OverrideDefaultStyle([[maybe_unused]] const std::vector<std::string>& args)
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void OverridePlatform()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if defined(__linux__)
 | 
				
			||||||
 | 
					   static const std::string NVIDIA_ID = "0x10de";
 | 
				
			||||||
 | 
					   namespace fs                       = std::filesystem;
 | 
				
			||||||
 | 
					   for (const auto& entry : fs::directory_iterator("/sys/class/drm"))
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					      if (!entry.is_directory() ||
 | 
				
			||||||
 | 
					          !entry.path().filename().string().starts_with("card"))
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					         continue;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      auto          vendorPath = entry.path() / "device" / "vendor";
 | 
				
			||||||
 | 
					      std::ifstream vendorFile(vendorPath);
 | 
				
			||||||
 | 
					      std::string   vendor;
 | 
				
			||||||
 | 
					      if (vendorFile && std::getline(vendorFile, vendor))
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					         if (vendor == NVIDIA_ID)
 | 
				
			||||||
 | 
					         {
 | 
				
			||||||
 | 
					            // Force xcb on NVIDIA
 | 
				
			||||||
 | 
					            setenv("QT_QPA_PLATFORM", "xcb", 1);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue