如何获得Gnome Wayland上的活动窗口? [英] How do I get the active window on Gnome Wayland?

查看:284
本文介绍了如何获得Gnome Wayland上的活动窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我正在开发一个名为 ActivityWatch 的软件.记录您在计算机上所做的事情.基本上是尝试解决以下问题:RescueTime,selfspy,arbtt等.

我们要做的核心事情之一是记录有关活动窗口的信息(类和标题).过去,这是在Linux上使用xprop以及现在使用python-xlib来完成的.

但是现在我们有一个问题: Wayland正在兴起,据我所知Wayland没有活动窗口的概念.因此,我担心我们将必须为Wayland可用的每个桌面环境实现支持(假设它们将提供获取有关活动窗口的信息的功能).

希望他们最终会融合在一起,并具有一些通用的界面来完成此操作,但是我并没有屏息...

我一直意识到了这一问题.但是今天,我们收到了一个实际Wayland用户的第一个用户对Wayland支持的请求.随着更大的发行版将Wayland用作默认显示服务器协议(Fedora 25已经在使用它,Ubuntu将在即将推出的17.10中进行切换),随着时间的流逝,情况将变得越来越重要.

ActivityWatch的相关问题:

像ActivityWatch这样的其他应用程序也需要相同的功能(RescueTime,arbtt,selfspy等),它们似乎暂时不支持Wayland,并且我找不到计划这样做的任何详细信息.

我现在有兴趣实施对Gnome的支持,以便从此开始,并随着路径的发展变得更加清晰.

有关韦斯顿的类似问题已在此处提出: 15:20:44 ErikBjare Hello everybody. I'm working on a piece of self-tracking software called ActivityWatch (https://github.com/ActivityWatch/activitywatch). I know this isn't exactly the right place to ask, but I was wondering if anyone knew anything about getting the active window in any Wayland-using DE. 15:20:57 ErikBjare Created a question on SO: https://stackoverflow.com/questions/45465016/how-do-i-get-the-active-window-on-gnome-wayland 15:21:25 ErikBjare Here's the issue in my repo for it: https://github.com/ActivityWatch/activitywatch/issues/92 15:22:54 ErikBjare There are a bunch of other applications that depend on it (RescueTime, selfspy, arbtt, ulogme, etc.) so they'd need it as well 15:24:23 blocage ErikBjare, in the core protocol you cannot know which windnow has the keyboard or cursor focus 15:24:39 blocage ErikBjare, in the wayland core protocol * 15:25:10 blocage ErikBjare, you can just know if your window has the focus or not, it a design choise 15:25:23 blocage avoid client spying each other 15:25:25 ErikBjare blocage: I'm aware, that's my reason for concern. I'm not saying it should be included or anything, but as it looks now every DE would need to implement it themselves if these kind of applications are to be supported 15:25:46 ErikBjare So wondering if anyone knew the teams working with Wayland on Gnome for example 15:26:11 ErikBjare But thanks for confirming 15:26:29 blocage ErikBjare, DE should create a custom extension, or use D-bus or other IPC 15:27:31 blocage ErikBjare, I guess some compositor are around here, but I do not know myself if there is such extension already 15:27:44 blocage compositor developers * 15:28:36 ErikBjare I don't think there is (I've done quite a bit of searching), so I guess I need to catch the attention of some DE developers 15:29:16 ErikBjare Thanks a lot though 15:29:42 ErikBjare blocage: Would you mind if I shared logs of our conversation in the issue? 15:30:05 blocage just use it :) it's public 15:30:19 ErikBjare ty :)

在Gnome Bugtracker中提出了增强问题.

tl;博士::使用Wayland时如何在Gnome上获得活动窗口?

解决方案

在我看来,您最好的选择不是Wayland或任何可用的库(没有一个库).实际上,在gnome-wayland中知道活动窗口的人是Mutter,因此您需要找到一种方法来询问活动窗口. Gnome可以开发一个API,以在内部要求更改活动窗口并恢复功能.但实际上,您没有地方可以提出要求. Mutter不会开发API来访问其内部表示,因为这将仅针对Mutter而并非针对所有Wayland Windows Manager都是非常特定的.因此,需要将其添加到外部库中,该库可能会与当前的窗口管理器联系,该窗口管理器正在使用该库以一般方式解决您的请求.

另一种可能性是添加Wayland插件,所有Windows管理器都将具有共享当前活动窗口的方式,并以某种方式直接与Wayland进行通信以恢复功能的库.

因此,您的应用程序存在很大的问题.您最多可以做的是在Mutter上请求此操作(知道活动的窗口),但是我认为这无法在Mutter中解决.

我希望这会对您有所帮助,并且您可以找到一种方法.祝你好运.

Background: I'm working on a piece of software called ActivityWatch that logs what you do on your computer. Basically an attempt at addressing some of the issues with: RescueTime, selfspy, arbtt, etc.

One of the core things we do is log information about the active window (class and title). In the past, this has been done using on Linux using xprop and now python-xlib without issue.

But now we have a problem: Wayland is on the rise, and as far as I can see Wayland has no notion of an active window. So my fear is that we will have to implement support for each and every desktop environment available for Wayland (assuming they'll provide the capability to get information about the active window at all).

Hopefully they'll eventually converge and have some common interface to get this done, but I'm not holding my breath...

I've been anticipating this issue. But today we got our first user request for Wayland support by an actual Wayland user. As larger distros are adopting Wayland as the default display server protocol (Fedora 25 is already using it, Ubuntu will switch in 17.10 which is coming soon) the situation is going to get more critical over time.

Relevant issues for ActivityWatch:

There are other applications like ActivityWatch that would require the same functionality (RescueTime, arbtt, selfspy, etc.), they don't seem to support Wayland right now and I can't find any details about them planning to do so.

I'm now interested in implementing support for Gnome to start off with and follow up with others as the path becomes more clear.

A similar question concerning Weston has been asked here: get the list of active windows in wayland weston

Edit: I asked in #wayland on Freenode, got the following reply:

15:20:44  ErikBjare    Hello everybody. I'm working on a piece of self-tracking software called ActivityWatch (https://github.com/ActivityWatch/activitywatch). I know this isn't exactly the right place to ask, but I was wondering if anyone knew anything about getting the active window in any Wayland-using DE.
15:20:57  ErikBjare    Created a question on SO: https://stackoverflow.com/questions/45465016/how-do-i-get-the-active-window-on-gnome-wayland
15:21:25  ErikBjare    Here's the issue in my repo for it: https://github.com/ActivityWatch/activitywatch/issues/92
15:22:54  ErikBjare    There are a bunch of other applications that depend on it (RescueTime, selfspy, arbtt, ulogme, etc.) so they'd need it as well
15:24:23  blocage      ErikBjare, in the core protocol you cannot know which windnow has the keyboard or cursor focus
15:24:39  blocage      ErikBjare, in the wayland core protocol *
15:25:10  blocage      ErikBjare, you can just know if your window has the focus or not, it a design choise
15:25:23  blocage      avoid client spying each other
15:25:25  ErikBjare    blocage: I'm aware, that's my reason for concern. I'm not saying it should be included or anything, but as it looks now every DE would need to implement it themselves if these kind of applications are to be supported
15:25:46  ErikBjare    So wondering if anyone knew the teams working with Wayland on Gnome for example
15:26:11  ErikBjare    But thanks for confirming
15:26:29  blocage      ErikBjare, DE should create a custom extension, or use D-bus or other IPC
15:27:31  blocage      ErikBjare, I guess some compositor are around here, but I do not know myself if there is such extension already
15:27:44  blocage      compositor developers *
15:28:36  ErikBjare    I don't think there is (I've done quite a bit of searching), so I guess I need to catch the attention of some DE developers
15:29:16  ErikBjare    Thanks a lot though
15:29:42  ErikBjare    blocage: Would you mind if I shared logs of our conversation in the issue?                                     
15:30:05  blocage      just use it :) it's public                                                                                               
15:30:19  ErikBjare    ty :)

Edit 2: Filed an enhancement issue in the Gnome bugtracker.

tl;dr: How do I get the active window on Gnome when using Wayland?

解决方案

In my opinion the best choice you have is not Wayland or any available library (there are not one). Actually who know in gnome-wayland about the active windows is Mutter, so you need to find a way to ask to Mutter the active windows. Gnome can develop an API to internally ask to mutter the active window and restore the functionality. But really, you don't have a place to ask for it. Mutter will not develop an API to access to his internal representation, because this will be pretty specific of Mutter only and not to all Wayland windows manager. So this need to be added to an external library, where this library could talk probably with the current window manager that it's in use to resolve your request in a general way.

Another possibility is add a Wayland plugin where all windows manager will have a way to share the current active windows and in some way a library to talk directly with wayland to restore the functionality.

So, your app is in a big problem. Most you can do is request this on mutter (where is know the active windows), but in my opinion it can not be resolved in Mutter.

I hope this will help you and you can find a way. Good luck.

这篇关于如何获得Gnome Wayland上的活动窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆