Browse Source

More work for parent Ids, find those with non-utf8 window names

tags/1.9.4
falkTX 12 years ago
parent
commit
751621870c
3 changed files with 38 additions and 5 deletions
  1. +30
    -5
      source/backend/plugin/CarlaPluginUi.cpp
  2. +2
    -0
      source/backend/plugin/NativePlugin.cpp
  3. +6
    -0
      source/modules/dgl/src/Window.cpp

+ 30
- 5
source/backend/plugin/CarlaPluginUi.cpp View File

@@ -196,8 +196,12 @@ bool CarlaPluginUi::tryTransientWinIdMatch(const uintptr_t pid, const char* cons
~ScopedDisplay() { if (display!=nullptr) XCloseDisplay(display); }
};
struct ScopedFreeData {
uchar* data;
ScopedFreeData(uchar* d) : data(d) {}
union {
char* data;
uchar* udata;
};
ScopedFreeData(char* d) : data(d) {}
ScopedFreeData(uchar* d) : udata(d) {}
~ScopedFreeData() { XFree(data); }
};

@@ -259,7 +263,7 @@ bool CarlaPluginUi::tryTransientWinIdMatch(const uintptr_t pid, const char* cons
}

// ------------------------------------------------
// try using name
// try using name (UTF-8)

unsigned long nameSize;
unsigned char* nameData = nullptr;
@@ -277,7 +281,28 @@ bool CarlaPluginUi::tryTransientWinIdMatch(const uintptr_t pid, const char* cons
{
CARLA_SAFE_ASSERT_RETURN(lastGoodWindow == window || lastGoodWindow == 0, true);
lastGoodWindow = window;
carla_stdout("Match found using name");
carla_stdout("Match found using UTF-8 name");
}
}

// ------------------------------------------------
// try using name (simple)

char* wmName = nullptr;

status = XFetchName(sd.display, window, &wmName);

if (wmName != nullptr)
{
const ScopedFreeData sfd2(wmName);

CARLA_SAFE_ASSERT_CONTINUE(status != 0);

if (std::strstr(wmName, uiTitle) != nullptr)
{
CARLA_SAFE_ASSERT_RETURN(lastGoodWindow == window || lastGoodWindow == 0, true);
lastGoodWindow = window;
carla_stdout("Match found using simple name");
}
}
}
@@ -290,7 +315,7 @@ bool CarlaPluginUi::tryTransientWinIdMatch(const uintptr_t pid, const char* cons
_nws[0] = XInternAtom(sd.display, "_NET_WM_STATE_SKIP_TASKBAR", True);
_nws[1] = XInternAtom(sd.display, "_NET_WM_STATE_SKIP_PAGER", True);

XChangeProperty(sd.display, lastGoodWindow, _nwt, XA_ATOM, 32, PropModeAppend, (uchar*)_nws, 2);
XChangeProperty(sd.display, lastGoodWindow, _nwt, XA_ATOM, 32, PropModeAppend, (const uchar*)_nws, 2);
XSetTransientForHint(sd.display, lastGoodWindow, (Window)winId);
XFlush(sd.display);
return true;


+ 2
- 0
source/backend/plugin/NativePlugin.cpp View File

@@ -179,6 +179,8 @@ public:
{
if (fIsUiVisible && fDescriptor != nullptr && fDescriptor->ui_show != nullptr && fHandle != nullptr)
fDescriptor->ui_show(fHandle, false);

pData->transientTryCounter = 0;
}

pData->singleMutex.lock();


+ 6
- 0
source/modules/dgl/src/Window.cpp View File

@@ -34,6 +34,8 @@ struct PuglViewImpl {
int height;
};}
#elif defined(DGL_OS_LINUX)
# include <sys/types.h>
# include <unistd.h>
extern "C" {
# include "pugl/pugl_x11.c"
}
@@ -185,6 +187,10 @@ public:
xDisplay = impl->display;
xWindow = impl->win;
assert(xWindow != 0);

pid_t pid = getpid();
Atom _nwp = XInternAtom(xDisplay, "_NET_WM_PID", True);
XChangeProperty(xDisplay, xWindow, _nwp, XA_CARDINAL, 32, PropModeReplace, (const unsigned char*)&pid, 1);
#endif

DBG("Success!\n");


Loading…
Cancel
Save