Skip to content

Commit

Permalink
Merge pull request #428 from go-vgo/bitmap-pr
Browse files Browse the repository at this point in the history
optimize x11 display code
  • Loading branch information
vcaesar authored Jan 2, 2022
2 parents b270210 + 6c249c1 commit 108c639
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions base/xdisplay_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

static Display *mainDisplay = NULL;
static int registered = 0;

static char *displayName = NULL;
static int hasDisplayNameChanged = 0;

Display *XGetMainDisplay(void)
{
Display *XGetMainDisplay(void) {
/* Close the display if displayName has changed */
if (hasDisplayNameChanged) {
XCloseMainDisplay();
Expand All @@ -20,7 +20,7 @@ Display *XGetMainDisplay(void)
mainDisplay = XOpenDisplay(displayName);

/* Then try using environment variable DISPLAY */
if (mainDisplay == NULL) {
if (mainDisplay == NULL && displayName != NULL) {
mainDisplay = XOpenDisplay(NULL);
}

Expand All @@ -40,22 +40,19 @@ Display *XGetMainDisplay(void)
return mainDisplay;
}

void XCloseMainDisplay(void)
{
void XCloseMainDisplay(void) {
if (mainDisplay != NULL) {
XCloseDisplay(mainDisplay);
mainDisplay = NULL;
}
}

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

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

File renamed without changes.
File renamed without changes.

0 comments on commit 108c639

Please sign in to comment.