Commit Graph

15 Commits

Author SHA1 Message Date
miruku b10c1f427b fix(qwlroots): allow server side destruction of qw_session_lock_v1
This commit exposes wlr_session_lock_v1_destroy as
qw_session_lock_v1::destroy(), which allows the compositor
to send finished() event on an ext_session_lock_v1 object.

qw_session_lock_v1 objects are not the owner of their handles,
thus cannot be properly destroyed via operator delete. Exposing
the destroy() method as public is necessary.

According to wayland protocol, compositor should have the ability
to deny a session lock request.
2025-09-26 10:23:25 +08:00
JiDe Zhang b0601f90d1 fix: Ensure proper object destruction before app exit
This commit addresses an issue where the application would fail with
an assertion failure related to `qw_buffer` objects not being properly
released upon exiting the application. The previous implementation
directly called `QCoreApplication::exit` or `QCoreApplication::quit`,
which would trigger the destruction of various `QObject` instances
(such as `Helper` and `QmlEngine`) *after* the Qt event loop had already
exited.

Since many of these objects relied on `deleteLater` for their
destruction, and `deleteLater` calls are ineffective once the event loop
has terminated, these objects were not being fully destructed, leading
to resource leaks and the aforementioned assertion failure.

The solution involves ensuring that all necessary objects are
explicitly destroyed *before* calling `QCoreApplication::exit` or
`QCoreApplication::quit`.  Specifically:

1.  A `quit()` method has been added to the `Treeland` class, which
disconnects the object from all signals and slots, and then resets the
`d_ptr` (unique pointer to the private implementation) to ensure all
Treeland related objects are properly deleted. This cleanup happens
before calling `qApp->quit()`.
2.  The signal connection between `QQmlEngine::quit` and
`QCoreApplication::quit` is changed to a `Qt::QueuedConnection` to avoid
potential issues when the quit call originates from within an event
handler (e.g., a cursor button press/release event).
3.  A new signal `requestQuit()` is introduced in `Helper` and emitted
instead of directly calling `qApp->quit()`.  This signal is then
connected to the `Treeland::quit()` method using `Qt::QueuedConnection`.
4.  In the `tinywl` example, the `QmlEngine` object is now
dynamically allocated and explicitly deleted before `app.exit()`
is called. The `Helper::requestQuit` signal is also connected to
`QmlEngine::deleteLater`.

These changes ensure that all relevant objects have been properly
cleaned up before the application terminates, resolving the assertion
failure and preventing potential resource leaks.

Influence:
1. Verify that the application exits cleanly without any assertion
failures related to `qw_buffer` or other resources.
2. Test exiting the application using various methods (e.g., the window
close button, a menu item, or a keyboard shortcut).
3. Ensure that all application data is saved correctly before exiting.
4. Test that the `LockScreen` object is properly destroyed by manually
creating and destroying a LockScreen object with the setLockScreenImpl
call in Helper.

修复程序退出前对象未正确销毁的问题

此提交修复了应用程序退出时,由于 `qw_buffer` 对象未正确释放而导
致的断言失败问题。 之前的实现直接调用 `QCoreApplication::exit` 或
`QCoreApplication::quit`,导致各种 `QObject` 实例(例如 `Helper` 和
`QmlEngine`)在 Qt 事件循环结束后才被销毁。

由于许多这些对象依赖于 `deleteLater` 进行销毁,并且一旦事件循环终止,
`deleteLater` 调用将无效,因此这些对象没有被完全销毁,从而导致资源泄漏和
前面提到的断言失败。

解决方案包括确保在调用 `QCoreApplication::exit` 或
`QCoreApplication::quit` 之前显式销毁所有必要的对象。 具体来说:

1.  在 `Treeland` 类中添加了一个 `quit()` 方法,该方法断开对象与所有
信号和槽的连接,然后重置 `d_ptr`(指向私有实现的唯一指针),以确保与
Treeland 相关的所有对象都得到正确删除。 此清理发生在调用 `qApp->quit()`
之前。
2.  `QQmlEngine::quit` 和 `QCoreApplication::quit` 之间的信号连接已更改
为 `Qt::QueuedConnection`,以避免在退出调用源自事件处理程序内(例如,光
标按钮按下/释放事件)时出现潜在问题。
3.  在 `Helper` 中引入了一个新的信号 `requestQuit()`,并发出该信号而不是
直接调用 `qApp->quit()`。 然后使用 `Qt::QueuedConnection` 将此信号连接到
`Treeland::quit()` 方法。
4. 在`tinywl`示例中,`QmlEngine` 对象现在是动态分配的,并在调
用 `app.exit()` 之前显式删除。 `Helper::requestQuit` 信号也连接到
`QmlEngine::deleteLater`。

这些更改确保在应用程序终止之前已正确清理所有相关对象,从而解决了断言失败
并防止了潜在的资源泄漏。

Influence:
1. 验证应用程序是否干净地退出,而不会出现与 `qw_buffer` 或其他资源相关的
任何断言失败。
2. 使用各种方法(例如,窗口关闭按钮、菜单项或键盘快捷键)测试退出应用
程序。
3. 确保在退出之前正确保存所有应用程序数据。
4. 通过使用 Helper 中的 setLockScreenImpl 调用手动创建和销毁 LockScreen
对象来测试 LockScreen 对象是否已正确销毁。
2025-09-24 11:38:46 +08:00
JiDe Zhang 9556ef8950 fix: Fix client crash when created via security context
1. Fixed a crash issue where clients created through the security
context could not obtain the corresponding WClient object.
2. Clients created via security context use a new socket connection,
which is not managed by WSocket by default.
3. The wlroots protocol provides limited information for monitoring
such wl_clients.
4. This commit adapts the wlroots implementation: in
`security_context_handle_commit`, a new WSocket object is created for
the listening socket, and the new wl_client object created from this
socket is added to WClient for management.

Influence:
1. Test the creation of clients using the security context.
2. Verify that the created clients can correctly obtain the WClient
object.
3. Ensure that newly created sockets are correctly managed.

修复:修复通过安全上下文创建的客户端崩溃问题

1. 修复了通过安全上下文创建的客户端无法获取对应的 WClient 对象导致崩溃的
问题。
2. 通过安全上下文创建的客户端使用新的套接字连接,默认情况下不由 WSocket
管理。
3. wlroots 协议为监控此类 wl_clients 提供的相关信息有限。
4. 本次提交采纳了 wlroots 的实现:在 `security_context_handle_commit`
中,为监听的套接字创建一个新的 WSocket 对象,并将由此套接字创建的新
wl_client 对象添加到 WClient 中进行管理。

Influence:
1. 测试使用安全上下文创建客户端的过程。
2. 验证创建的客户端能否正确获取 WClient 对象。
3. 确保新创建的套接字能够得到正确的管理。
2025-09-15 14:48:34 +08:00
rewine cf91ae1312 refactor: use unified CI build preset with Werror
1. Replace manual CMake configuration with --preset ci in all ArchLinux
workflows
2. Add new CI build preset in CMakePresets.json with -Werror enabled
3. Remove redundant per-project CMake configuration steps
4. Simplify workflow steps by combining configure and build phases
5. Maintain compatibility with existing build requirements while
standardizing

The changes standardize build configuration across projects using a
centralized CMake preset. This ensures consistent build behavior while
maintaining the strict -Werror flag for CI builds. The update simplifies
workflow maintenance and improves build reliability by using CMake's
modern preset system.
2025-08-18 16:01:51 +08:00
rewine 6c921b8ed4 fix: resolve multiple compiler warnings
1. Fix multiple compiler warning issues across various header files
2. Corrected template typedef naming in qobject.h for better clarity
3. Removed semicolons after QW_FUNC_MEMBER macros in several header
files
4. Added missing compiler warning disables for -Wreorder in
qtwaylandscanner.cpp
5. Fixed Q_DECLARE_FLAGS macro usage in surfacewrapper.h
6. Fixed W_DECLARE_PUBLIC macro usage in winputdevice.cpp

These changes eliminate compiler warnings during the build process while
maintaining full functionality and improving code consistency across
the codebase.

修复: 解决多个编译器警告

1. 修复多个头文件中的编译器警告问题
2. 在 qobject.h 中修正了模板类型定义名称以提高清晰度
3. 在多个头文件中移除了 QW_FUNC_MEMBER 宏后的分号
4. 在 qtwaylandscanner.cpp 中添加了缺失的 -Wreorder 警告禁用指令
5. 修正了 surfacewrapper.h 中的 Q_DECLARE_FLAGS 宏使用
6. 修正了 winputdevice.cpp 中的 W_DECLARE_PUBLIC 宏使用

这些修改在保持完整功能的同时消除了构建过程中的编译器警告
2025-08-08 10:03:45 +08:00
rewine 3a013bcf5a fix: replace Q_EMIT and Q_SLOTS with signals/slots
Replace all instances of Q_EMIT with the modern signal
emission syntax
and replace Q_SLOTS with the modern slots syntax. Also add
[[maybe_unused]] attributes to parameters that are intentionally unused.

fix: 替换 Q_EMIT 和 Q_SLOTS 为 Qt5 风格的信号/槽

替换所有 Q_EMIT 为现代风格的信号发射语法,并将 Q_SLOTS 替换为现代风格的槽语法。
同时为故意未使用的参数添加 [[maybe_unused]] 属性。
2025-08-07 19:08:26 +08:00
rewine 4cb0da6d21 fix: resolve compilation warnings and improve code structure
1. Fix order of member variable initialization in qw_interface
constructor
2. Move add_compile_options after ASAN flags to ensure proper priority
3. Fix member variable order in TreelandConfig to match declaration
4. Add [[maybe_unused]] attribute to unused function parameters
5. Fix surface wrapper bitfield member ordering
6. Fix cursor image index comparison type mismatch
7. Fix various minor code style and structure issues

fix: 解决编译警告并改进代码结构

1. 修复 qw_interface 构造函数中成员变量的初始化顺序
2. 将 add_compile_options 移至 ASAN 标志之后以确保优先级
3. 修复 TreelandConfig 中成员变量顺序以匹配声明
4. 为未使用的函数参数添加 [[maybe_unused]] 属性
5. 修复 surface wrapper 位域成员顺序
6. 修复光标图像索引比较的类型不匹配问题
7. 解决其他次要的代码风格和结构问题
2025-08-07 19:08:26 +08:00
rewine 5cee95f2aa fix: improve image capture error handling and code structure
1. Replace Q_ASSERT with proper error handling in image capture code
2. Add comprehensive validation checks for null pointers and invalid
states
3. Replace manual memory management with RAII-style helper classes
4. Move constraint building logic to dedicated helper struct
5. Add proper copyright headers to source files
6. Update CMakeLists.txt with consistent TODO markers
7. Implement WPixmanRegion class for automatic region management
8. Add detailed debug logging for capture operations

The changes enhance code reliability by properly handling error
conditions instead of relying on assertions, improve memory safety
through better resource management, and make the code more maintainable

with clearer structure and documentation.

fix: 改进图像捕获错误处理和代码结构

1. 在图像捕获代码中替换 Q_ASSERT 为适当的错误处理
2. 添加全面的空指针和无效状态验证检查
3. 使用 RAII 风格的辅助类替代手动内存管理
4. 将约束构建逻辑移至专用辅助结构体
5. 为源文件添加正确的版权标头
6. 在 CMakeLists.txt 中使用一致的 TODO 标记
7. 实现 WPixmanRegion
2025-07-31 20:37:24 +08:00
rewine a503276e46 feat: add foreign toplevel image capture support
1. Added support for Wayland foreign toplevel image capture protocol
2. Implemented capture source creation and handling in Helper class
3. Added new protocol files for ext-image-capture-source and ext-
foreign-toplevel-list
4. Created WExtImageCaptureSourceV1Impl for handling actual image
capture logic
5. Added findSurfaceByHandle method to support reverse lookup from
protocol handles
6. Implemented frame scheduling and buffer copying with format
constraints handling

feat: 添加外部顶层窗口图像捕获支持

1. 添加对 Wayland 外部顶层窗口图像捕获协议的支持
2. 在 Helper 类中实现捕获源创建和处理逻辑
3. 添加了 ext-image-capture-source 和 ext-foreign-toplevel-list 的新协议
文件
4. 创建 WExtImageCaptureSourceV1Impl 类来处理实际的图像捕获逻辑
5. 添加 findSurfaceByHandle 方法以支持从协议句柄进行反向查找
6. 实现帧调度和缓冲区复制,并处理格式约束条件
2025-07-31 20:37:24 +08:00
rewine 72f4ff54a6 feat: add image capture source support
1. Add new header files for ext_image_capture_source_v1
2. Implement QW_CLASS_OBJECT for ext_image_capture_source_v1 with
signals and methods
3. Add interface header for ext_image_capture_source_v1
4. Improve ext_image_copy_capture_frame_v1 with proper object model
and methods

feat: 添加图像捕获源支持

1. 为 ext_image_capture_source_v1 添加新头文件
2. 使用信号和方法实现 ext_image_capture_source_v1 的 QW_CLASS_OBJECT
3. 添加 ext_image_capture_source_v1 的接口头文件
4. 通过正确的对象模型和方法改进 ext_image_copy_capture_frame_v1
2025-07-31 20:37:24 +08:00
April & May 5a8e15f1c7 feat: Add qwlroots interface for wl_session object
Add qwlroots interface for wl_session object, which can serve for VT
switching.
2025-07-31 19:29:34 +08:00
immortalrover a6134c2e40 feat: create ext-data-control manager
support ext-data-control-v1 protocol
2025-07-29 20:33:01 +08:00
renovate[bot] c4aba6382e chore(deps): update fsfe/reuse-action action to v5 2025-07-23 15:35:30 +08:00
JiDe Zhang 54e8ed840b chore: Force Ninja build during deb packaging
This commit enforces the use of Ninja as the build system during the
debian package creation process for treeland, qwlroots, and waylib.
This change was made to significantly improve build times, as Ninja
generally offers faster and more efficient builds compared to the
default make system. The changes involve adding `ninja-build` as a
build dependency in the `debian/control` files and adding `-GNinja` to
the `dh_auto_configure` commands in the `debian/rules` files for all
three packages. This ensures that CMake uses Ninja to generate the build
files.

chore: 在 deb 打包过程中强制使用 Ninja 构建

此提交强制在 treeland、qwlroots 和 waylib 的 debian 包创建过程中使用
Ninja 作为构建系统。 此更改旨在显着缩短构建时间,因为与默认的 make 系统
相比,Ninja 通常提供更快、更高效的构建。 更改包括在 `debian/control` 文
件中添加 `ninja-build` 作为构建依赖项,并在所有三个包的 `debian/rules`
文件中的 `dh_auto_configure` 命令中添加 `-GNinja`。 这确保 CMake 使用
Ninja 来生成构建文件。
2025-07-23 15:27:52 +08:00
JiDe Zhang 2a0093ad46 refactor: merge qwlroots and waylib source code into treeland
Removed qwlroots and waylib from git submodules, and merged their
source code directly into the treeland repository. This change
reduces development overhead during the rapid iteration phase of
treeland, as frequent coordinated changes are required across
treeland, qwlroots, and waylib. By merging them now, we simplify
development and maintenance. In the future, when the project
stabilizes, we may consider splitting them back into independent
repositories.

To prepare for this possible future split, the original directory
structures and all files from qwlroots and waylib are preserved and
placed under separate subdirectories in treeland.

Original project commits at the time of merge:
- qwlroots: https://github.com/vioken/qwlroots(00b09f9047ac0eaf26757e8af3d31f35d22bbce3)
- waylib: https://github.com/vioken/waylib(9564027cc6c89dc5262c03d183f743b71a0e621e)

重构:将 qwlroots 和 waylib 项目代码合并到 treeland

将 qwlroots 和 waylib 从 git 子模块中移除,直接把它们的代码合并
到 treeland 项目中。这样做是为了在 treeland 快速迭代期间减少开发
成本,因为经常需要同时修改 treeland、waylib 和 qwlroots,合并后
开发会更方便,待项目稳定后再考虑重新拆分为独立项目。

为方便将来拆分,保留了原项目的目录结构和全部文件,并使用独立子
目录维护代码。

合并时原项目的提交信息如下:
- qwlroots: https://github.com/vioken/qwlroots(00b09f9047ac0eaf26757e8af3d31f35d22bbce3)
- waylib: https://github.com/vioken/waylib(9564027cc6c89dc5262c03d183f743b71a0e621e)
2025-07-23 15:27:52 +08:00