Skip to content
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

add a way to specify the X11 display in Linux #206

Merged
merged 6 commits into from
Jun 19, 2016
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
improve variable names, move hasDisplayNameChanged reset
jub3i authored and illegalprime committed Jun 1, 2016
commit 0e457bae03189ee4c1fd17071e760f08b5c49b1c
20 changes: 10 additions & 10 deletions src/xdisplay.c
Original file line number Diff line number Diff line change
@@ -4,20 +4,20 @@

static Display *mainDisplay = NULL;
static int registered = 0;
static char *display_name = ":0.0";
static int display_name_changed = 0;
static char *displayName = ":0.0";
static int hasDisplayNameChanged = 0;

Display *XGetMainDisplay(void)
{
/* Close the display if display_name has changed */
if (display_name_changed) {
/* Close the display if displayName has changed */
if (hasDisplayNameChanged) {
XCloseMainDisplay();
hasDisplayNameChanged = 0;
}
display_name_changed = 0;

if (mainDisplay == NULL) {
/* First try the user set display_name */
mainDisplay = XOpenDisplay(display_name);
/* First try the user set displayName */
mainDisplay = XOpenDisplay(displayName);

/* Then try using environment variable DISPLAY */
if (mainDisplay == NULL) {
@@ -45,10 +45,10 @@ void XCloseMainDisplay(void)

char *getXDisplay(void)
{
return display_name;
return displayName;
}

void setXDisplay(char *name) {
display_name = name;
display_name_changed = 1;
displayName = name;
hasDisplayNameChanged = 1;
}