aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2024-07-16 05:06:14 +0200
committerRobert Tari <robert@tari.in>2024-07-16 05:06:14 +0200
commit362422cad3f13f270f1c50d7c6d2010c5ad2f542 (patch)
tree1558c68f4bf69efc1d924753be23df0b119daee5
parent43843508581060f6c0c83a2f21ca6610b800c015 (diff)
downloadayatana-indicator-display-362422cad3f13f270f1c50d7c6d2010c5ad2f542.tar.gz
ayatana-indicator-display-362422cad3f13f270f1c50d7c6d2010c5ad2f542.tar.bz2
ayatana-indicator-display-362422cad3f13f270f1c50d7c6d2010c5ad2f542.zip
src/service.cpp: Disable Xsct for Wayland
-rw-r--r--src/service.cpp94
1 files changed, 51 insertions, 43 deletions
diff --git a/src/service.cpp b/src/service.cpp
index 47d7291..43bf9d6 100644
--- a/src/service.cpp
+++ b/src/service.cpp
@@ -77,66 +77,74 @@ public:
if (!this->bTest)
{
- // Check if we are in a virtual environment
- Display *pDisplay = XOpenDisplay (NULL);
+ // Check if we are on Wayland
+ const gchar *sWayland = g_getenv ("WAYLAND_DISPLAY");
+ this->bXsctUnsupported = (sWayland != NULL);
+ //~Check if we are on Wayland
- if (!pDisplay)
- {
- g_warning ("Panic: Failed to open X display while checking for virtual environment");
- }
- else
+ // Check if we are in a virtual environment
+ if (!this->bXsctUnsupported)
{
- guint nScreen = DefaultScreen (pDisplay);
- Window pWindow = RootWindow (pDisplay, nScreen);
- XRRScreenResources *pResources = XRRGetScreenResources (pDisplay, pWindow);
+ Display *pDisplay = XOpenDisplay (NULL);
- if (!pResources)
+ if (!pDisplay)
{
- g_warning ("Panic: Failed to get screen resources while checking for virtual environment");
- XCloseDisplay (pDisplay);
+ g_warning ("Panic: Failed to open X display while checking for virtual environment");
}
else
{
- RROutput nOutputPrimary = XRRGetOutputPrimary (pDisplay, pWindow);
- XRROutputInfo *pOutputInfo = XRRGetOutputInfo (pDisplay, pResources, nOutputPrimary);
- GRegex *pRegex = NULL;
- GError *pError = NULL;
+ guint nScreen = DefaultScreen (pDisplay);
+ Window pWindow = RootWindow (pDisplay, nScreen);
+ XRRScreenResources *pResources = XRRGetScreenResources (pDisplay, pWindow);
- #if GLIB_CHECK_VERSION(2, 73, 0)
- pRegex = g_regex_new (".*virtual.*", G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT, &pError);
- #else
- pRegex = g_regex_new (".*virtual.*", G_REGEX_CASELESS, (GRegexMatchFlags) 0, &pError);
- #endif
-
- if (!pError)
+ if (!pResources)
{
+ g_warning ("Panic: Failed to get screen resources while checking for virtual environment");
+ XCloseDisplay (pDisplay);
+ }
+ else
+ {
+ RROutput nOutputPrimary = XRRGetOutputPrimary (pDisplay, pWindow);
+ XRROutputInfo *pOutputInfo = XRRGetOutputInfo (pDisplay, pResources, nOutputPrimary);
+ GRegex *pRegex = NULL;
+ GError *pError = NULL;
+
#if GLIB_CHECK_VERSION(2, 73, 0)
- gboolean bMatch = g_regex_match (pRegex, pOutputInfo->name, G_REGEX_MATCH_DEFAULT, NULL);
+ pRegex = g_regex_new (".*virtual.*", G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT, &pError);
#else
- gboolean bMatch = g_regex_match (pRegex, pOutputInfo->name, (GRegexMatchFlags) 0, NULL);
+ pRegex = g_regex_new (".*virtual.*", G_REGEX_CASELESS, (GRegexMatchFlags) 0, &pError);
#endif
- if (bMatch)
+ if (!pError)
{
- this->bXsctUnsupported = TRUE;
- }
+ #if GLIB_CHECK_VERSION(2, 73, 0)
+ gboolean bMatch = g_regex_match (pRegex, pOutputInfo->name, G_REGEX_MATCH_DEFAULT, NULL);
+ #else
+ gboolean bMatch = g_regex_match (pRegex, pOutputInfo->name, (GRegexMatchFlags) 0, NULL);
+ #endif
- g_regex_unref (pRegex);
- }
- else
- {
- g_warning ("PANIC: Failed to compile regex: %s", pError->message);
- g_error_free (pError);
- }
+ if (bMatch)
+ {
+ this->bXsctUnsupported = TRUE;
+ }
- XRRFreeOutputInfo (pOutputInfo);
- XRRFreeScreenResources (pResources);
- XCloseDisplay (pDisplay);
+ g_regex_unref (pRegex);
+ }
+ else
+ {
+ g_warning ("PANIC: Failed to compile regex: %s", pError->message);
+ g_error_free (pError);
+ }
+
+ XRRFreeOutputInfo (pOutputInfo);
+ XRRFreeScreenResources (pResources);
+ XCloseDisplay (pDisplay);
- #ifdef RDA_ENABLED
- gboolean bRemote = rda_session_is_remote ();
- this->bXsctUnsupported = this->bXsctUnsupported || bRemote;
- #endif
+ #ifdef RDA_ENABLED
+ gboolean bRemote = rda_session_is_remote ();
+ this->bXsctUnsupported = this->bXsctUnsupported || bRemote;
+ #endif
+ }
}
}
//~Check if we are in a virtual environment