Skip to content

Quick fix to add support for custom x server #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions BSCP/ConfigurableShell/ConfigurableShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,23 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
DWORD cbXming = 0;
DWORD ccXming = 0;
WCHAR* xming_val = prov.pwszGetValueAt_sz(s_RegistryKey_Shell, TEXT("xming"), &cbXming, &ccXming);
//load xming full command
DWORD cbXmingCommand = 0;
DWORD ccXmingCommand = 0;
WCHAR* xming_command_val = prov.pwszGetValueAt_sz(s_RegistryKey_Shell, TEXT("xming_command"), &cbXmingCommand, &ccXmingCommand);
//execute shell command
if (_wcsicmp(xming_val, TEXT("true")) == 0) {
char* x = "\"C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl"; //first try with optimized Xming
result = WinExec(x, SW_SHOW);
// TODO - does this work?
if (wcslen(xming_command_val) == 0) {
char* x = "\"C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl"; //first try with optimized Xming
result = WinExec(x, SW_SHOW);
}
else {
char* convertedString = new char [ccXmingCommand];
wcstombs(convertedString, xming_command_val, wcslen(xming_command_val));
result = WinExec(convertedString, SW_SHOW);
}

if (result <= 31) { //Error state, try again
char* y = "\"C:\\Program Files (x86)\\Xming\\Xming.exe\" :0 -clipboard -fullscreen";
result = WinExec(y, SW_SHOW);
Expand Down
4 changes: 2 additions & 2 deletions BSCP/ConfigurableShell/ConfigurableShell.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand Down Expand Up @@ -115,7 +115,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand Down
26 changes: 25 additions & 1 deletion BSCP/Configurator/ConfigModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected void OnPropertyChanged(string name)
private String _name;
private String _command;
private String _console;
private string _xmingCommand;
private Boolean _usesXming;
public String Name
{
Expand Down Expand Up @@ -69,19 +70,32 @@ public String Console
}
}
}
public string XmingCommand
{
get => _xmingCommand;
set
{
if (value != _xmingCommand)
{
_xmingCommand = value;
OnPropertyChanged(nameof(XmingCommand));
}
}
}
public String DefaultCommand { get; set; }
public String DefaultConsole { get; set; }

public ConfigModel()
{
}

public ConfigModel(String name, String defaultCommand, String defaultConsole, Boolean uses_xming = true)
public ConfigModel(String name, String defaultCommand, String defaultConsole, Boolean uses_xming = true, String defaultXmingString = "C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl")
{
this.Name = name;
this.DefaultCommand = defaultCommand;
this.DefaultConsole = defaultConsole;
this._usesXming = uses_xming;
this._xmingCommand = defaultXmingString;
}

/// <summary>
Expand All @@ -93,6 +107,15 @@ public void readOrUpdateFromRegistry()
var console_key = Registry.GetValue(get_full_name(), "console", null);
var xming_key = Registry.GetValue(get_full_name(), "xming", null);
var name_key = Registry.GetValue(get_full_name(), "name", null);
var xming_command_key = Registry.GetValue(get_full_name(), "xming_command", null);

if (xming_command_key == null)
{
Registry.SetValue(get_full_name(), "xming_command", "C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl");
xming_command_key = Registry.GetValue(app_key_base + "\\" + Name, "xming_command", null);
}
this.XmingCommand = xming_command_key.ToString();

if (command_key == null)
{
//insert key & set value
Expand Down Expand Up @@ -128,6 +151,7 @@ public void pushToRegistry()
Registry.SetValue(get_full_name(), "name", this.Name);
Registry.SetValue(get_full_name(), "console", this.Console);
Registry.SetValue(get_full_name(), "xming", this._usesXming.ToString());
Registry.SetValue(get_full_name(), "xming_command", this._xmingCommand);
}

public void delete()
Expand Down
1 change: 1 addition & 0 deletions BSCP/Configurator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<TextBox Text="{Binding Name}" Width="150" />
<TextBox Text="{Binding Console}" Width="75" />
<TextBox Text="{Binding Command}" Width="150" />
<TextBox Text="{Binding XmingCommand}" Width="150" />
<Button Content="Reset to Default" Tag="{Binding Name}" Click="Reset_button_Click" />
<Button Content="Delete Forever" Tag="{Binding Name}" Click="Delete_button_Click" />
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion BSCP/Configurator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public MainWindow()
context.Add(new ConfigModel("KDE", "-c \"cd ~/ && DISPLAY=:0 startkde \"", "bash.exe"));
context.Add(new ConfigModel("XFCE", "-c \"cd ~/ && DISPLAY=:0 startxfce4\"", "bash.exe"));
context.Add(new ConfigModel("Mate", "-c \"cd ~/ && DISPLAY=:0 exec mate-session\"", "bash.exe"));
context.Add(new ConfigModel("Windows Explorer", "/C \"explorer.exe\"", "cmd.exe", false));
context.Add(new ConfigModel("Windows Explorer", "/C \"explorer.exe\"", "cmd.exe", false, ""));
}

foreach (var item in context)
Expand Down
Binary file modified BSCP/CredentialProvider/Release/resources.res
Binary file not shown.