Skip to content
Snippets Groups Projects
Commit b16131e6 authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Andreas Traczyk
Browse files

windows sharing: use windows id instead of name

Change-Id: Ie1708ae4be049206fb8337db1211b7844e45726f
parent 86b84ea1
No related branches found
No related tags found
No related merge requests found
daemon @ 5e35e71d
Subproject commit 33f089ef50deb19c15b094dde10f87814b7c48b0 Subproject commit 5e35e71d0959923ee3a0180b988ea7175f1530fb
...@@ -284,6 +284,7 @@ Window { ...@@ -284,6 +284,7 @@ Window {
border.color: selectedScreenNumber === index ? JamiTheme.screenSelectionBorderColor : JamiTheme.tabbarBorderColor border.color: selectedScreenNumber === index ? JamiTheme.screenSelectionBorderColor : JamiTheme.tabbarBorderColor
visible: root.window && JamiStrings.selectScreen !== screens[index] && index >= Qt.application.screens.length visible: root.window && JamiStrings.selectScreen !== screens[index] && index >= Qt.application.screens.length
&& screenName2.text != JamiStrings.selectWindow
Text { Text {
id: screenName2 id: screenName2
......
...@@ -564,10 +564,13 @@ AVModel::stopPreview(const QString& resource) ...@@ -564,10 +564,13 @@ AVModel::stopPreview(const QString& resource)
BOOL BOOL
IsAltTabWindow(HWND hwnd) IsAltTabWindow(HWND hwnd)
{ {
LONG style = GetWindowLong(hwnd, GWL_STYLE); auto styles = (DWORD) GetWindowLongPtr(hwnd, GWL_STYLE);
if (!((style & WS_DISABLED) != WS_DISABLED)) { auto ex_styles = (DWORD) GetWindowLongPtr(hwnd, GWL_EXSTYLE);
if (ex_styles & WS_EX_TOOLWINDOW)
return false;
if (styles & WS_CHILD)
return false; return false;
}
DWORD cloaked = FALSE; DWORD cloaked = FALSE;
HRESULT hrTemp = DwmGetWindowAttribute(hwnd, DWMWA_CLOAKED, &cloaked, sizeof(cloaked)); HRESULT hrTemp = DwmGetWindowAttribute(hwnd, DWMWA_CLOAKED, &cloaked, sizeof(cloaked));
...@@ -591,6 +594,17 @@ IsAltTabWindow(HWND hwnd) ...@@ -591,6 +594,17 @@ IsAltTabWindow(HWND hwnd)
BOOL CALLBACK BOOL CALLBACK
CbEnumAltTab(HWND hwnd, LPARAM lParam) CbEnumAltTab(HWND hwnd, LPARAM lParam)
{ {
const size_t MAX_WINDOW_NAME = 256;
TCHAR windowName[MAX_WINDOW_NAME];
GetWindowText(hwnd, windowName, MAX_WINDOW_NAME);
// Do not show windows that has no caption
if (0 == windowName[0])
return TRUE;
std::wstring msg = std::wstring(windowName);
auto name = QString::fromStdWString(msg);
// Do not show invisible windows // Do not show invisible windows
if (!IsWindowVisible(hwnd)) if (!IsWindowVisible(hwnd))
return TRUE; return TRUE;
...@@ -599,28 +613,19 @@ CbEnumAltTab(HWND hwnd, LPARAM lParam) ...@@ -599,28 +613,19 @@ CbEnumAltTab(HWND hwnd, LPARAM lParam)
if (!IsAltTabWindow(hwnd)) if (!IsAltTabWindow(hwnd))
return TRUE; return TRUE;
const size_t MAX_WINDOW_NAME = 256; auto isShellWindow = hwnd == GetShellWindow();
TCHAR windowName[MAX_WINDOW_NAME];
if (hwnd == GetShellWindow())
return TRUE;
else
GetWindowText(hwnd, windowName, MAX_WINDOW_NAME);
// Do not show windows that has no caption if (isShellWindow)
if (0 == windowName[0])
return TRUE; return TRUE;
std::wstring msg = std::wstring(windowName);
auto name = QString::fromStdWString(msg);
QMap<QString, QVariant>* windowList = reinterpret_cast<QMap<QString, QVariant>*>(lParam); QMap<QString, QVariant>* windowList = reinterpret_cast<QMap<QString, QVariant>*>(lParam);
auto keys = windowList->keys(); auto keys = windowList->keys();
if (keys.indexOf(name) > 0) { if (keys.indexOf(name) > 0) {
return FALSE; return FALSE;
} else { } else {
DWORD processId; std::stringstream ss;
GetWindowThreadProcessId(hwnd, &processId); ss << hwnd;
windowList->insert(name, QVariant::fromValue(processId)); windowList->insert(name, QString::fromStdString(ss.str()));
} }
return TRUE; return TRUE;
......
...@@ -949,30 +949,6 @@ CallModel::getDisplay(int idx, int x, int y, int w, int h) ...@@ -949,30 +949,6 @@ CallModel::getDisplay(int idx, int x, int y, int w, int h)
.arg(h); .arg(h);
} }
#ifdef WIN32
BOOL CALLBACK
EnumWindowsProcMy(HWND hwnd, LPARAM lParam)
{
std::pair<DWORD, QString>* dataPair = reinterpret_cast<std::pair<DWORD, QString>*>(lParam);
DWORD lpdwProcessId;
if (auto parent = GetWindow(hwnd, GW_OWNER))
GetWindowThreadProcessId(parent, &lpdwProcessId);
else
GetWindowThreadProcessId(hwnd, &lpdwProcessId);
int len = GetWindowTextLength(hwnd) + 1;
std::vector<wchar_t> buf(len);
GetWindowText(hwnd, &buf[0], len);
if (lpdwProcessId == dataPair->first) {
if (!IsWindowVisible(hwnd))
return TRUE;
dataPair->second = QString::fromStdWString(&buf[0]);
return FALSE;
}
return TRUE;
}
#endif
QString QString
CallModel::getDisplay(const QString& windowProcessId, const QString& windowId) CallModel::getDisplay(const QString& windowProcessId, const QString& windowId)
{ {
...@@ -986,22 +962,10 @@ CallModel::getDisplay(const QString& windowProcessId, const QString& windowId) ...@@ -986,22 +962,10 @@ CallModel::getDisplay(const QString& windowProcessId, const QString& windowId)
.arg(windowProcessId); .arg(windowProcessId);
#endif #endif
#ifdef WIN32 #ifdef WIN32
// If window changed the name we must look for the parent process window ret = QString("%1%2:+0,0 window-id:hwnd=%3")
QString newWindowId = windowId; .arg(libjami::Media::VideoProtocolPrefix::DISPLAY)
auto hwnd = FindWindow(NULL, windowId.toStdWString().c_str()); .arg(sep)
if (!hwnd) { .arg(windowProcessId);
std::pair<DWORD, QString> idName(windowProcessId.toInt(), {});
LPARAM lParam = reinterpret_cast<LPARAM>(&idName);
EnumWindows(EnumWindowsProcMy, lParam);
if (!idName.second.isEmpty()) {
newWindowId = idName.second;
}
}
ret = QString("%1%2:+0,0 window-id:title=%3")
.arg(libjami::Media::VideoProtocolPrefix::DISPLAY)
.arg(sep)
.arg(newWindowId);
#endif #endif
return ret; return ret;
} }
......
...@@ -30,16 +30,16 @@ VideoManagerInterface::VideoManagerInterface() ...@@ -30,16 +30,16 @@ VideoManagerInterface::VideoManagerInterface()
int width, int width,
int height, int height,
bool isMixer) { bool isMixer) {
Q_EMIT decodingStarted(QString::fromLatin1(QByteArray::fromStdString(id)), Q_EMIT decodingStarted(QString(id.c_str()),
QString::fromLatin1(QByteArray::fromStdString(shmPath)), QString(shmPath.c_str()),
width, width,
height, height,
isMixer); isMixer);
}), }),
exportable_callback<VideoSignal::DecodingStopped>( exportable_callback<VideoSignal::DecodingStopped>(
[this](const std::string& id, const std::string& shmPath, bool isMixer) { [this](const std::string& id, const std::string& shmPath, bool isMixer) {
Q_EMIT decodingStopped(QString::fromLatin1(QByteArray::fromStdString(id)), Q_EMIT decodingStopped(QString(id.c_str()),
QString::fromLatin1(QByteArray::fromStdString(shmPath)), QString(shmPath.c_str()),
isMixer); isMixer);
})}; })};
#endif #endif
......
...@@ -126,7 +126,7 @@ public Q_SLOTS: // METHODS ...@@ -126,7 +126,7 @@ public Q_SLOTS: // METHODS
QString openVideoInput(const QString& resource) QString openVideoInput(const QString& resource)
{ {
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
return QString::fromLatin1(QByteArray::fromStdString(libjami::openVideoInput(resource.toStdString()))); return libjami::openVideoInput(resource.toLatin1().toStdString()).c_str();
#endif #endif
} }
...@@ -150,7 +150,7 @@ public Q_SLOTS: // METHODS ...@@ -150,7 +150,7 @@ public Q_SLOTS: // METHODS
bool registerSinkTarget(const QString& sinkID, const libjami::SinkTarget& target) bool registerSinkTarget(const QString& sinkID, const libjami::SinkTarget& target)
{ {
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
return libjami::registerSinkTarget(sinkID.toLatin1().toStdString(), target); return libjami::registerSinkTarget(sinkID.toStdString(), target);
#else #else
Q_UNUSED(sinkID) Q_UNUSED(sinkID)
Q_UNUSED(target) Q_UNUSED(target)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment