Skip to content

Commit

Permalink
Revert "Move window to current workspace on focus"
Browse files Browse the repository at this point in the history
This reverts commit 03679eb.

See telegramdesktop/tdesktop#10441
  • Loading branch information
john-preston committed Mar 1, 2021
1 parent 5421b42 commit 9005da2
Showing 1 changed file with 0 additions and 73 deletions.
73 changes: 0 additions & 73 deletions base/platform/linux/base_process_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,77 +18,6 @@ namespace base::Platform {
namespace {

#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
void XCBMoveWindowToCurrentWorkspace(WId window) {
const auto connection = XCB::GetConnectionFromQt();
if (!connection) {
return;
}

const auto root = XCB::GetRootWindowFromQt();
if (!root.has_value()) {
return;
}

const auto currentDesktopAtom = XCB::GetAtom(
connection,
"_NET_CURRENT_DESKTOP");

const auto desktopAtom = XCB::GetAtom(
connection,
"_NET_WM_DESKTOP");

if (!currentDesktopAtom.has_value() || !desktopAtom.has_value()) {
return;
}
const auto cookie = xcb_get_property(
connection,
false,
*root,
*currentDesktopAtom,
XCB_ATOM_CARDINAL,
0,
1024);

auto reply = xcb_get_property_reply(
connection,
cookie,
nullptr);

if (!reply) {
return;
}

const auto currentDesktop = (reply->type == XCB_ATOM_CARDINAL)
? reinterpret_cast<ulong*>(xcb_get_property_value(reply))
: nullptr;

free(reply);

if (!currentDesktop) {
return;
}

xcb_client_message_event_t xev;
xev.response_type = XCB_CLIENT_MESSAGE;
xev.format = 32;
xev.sequence = 0;
xev.window = window;
xev.type = *desktopAtom;
xev.data.data32[0] = *currentDesktop;
xev.data.data32[1] = 0;
xev.data.data32[2] = 0;
xev.data.data32[3] = 0;
xev.data.data32[4] = 0;

xcb_send_event(
connection,
false,
*root,
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
reinterpret_cast<const char *>(&xev));
}

void XCBActivateWindow(WId window) {
const auto connection = XCB::GetConnectionFromQt();
if (!connection) {
Expand Down Expand Up @@ -156,7 +85,6 @@ void XCBActivateWindow(WId window) {
void ActivateProcessWindow(int64 pid, WId windowId) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
if (::Platform::IsX11()) {
XCBMoveWindowToCurrentWorkspace(windowId);
XCBActivateWindow(windowId);
}
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
Expand All @@ -165,7 +93,6 @@ void ActivateProcessWindow(int64 pid, WId windowId) {
void ActivateThisProcessWindow(WId windowId) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
if (::Platform::IsX11()) {
XCBMoveWindowToCurrentWorkspace(windowId);
XCBActivateWindow(windowId);
}
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
Expand Down

0 comments on commit 9005da2

Please sign in to comment.