From b598cf5cc45ebbc92a981f10637e62f176af55ef Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Thu, 4 Jul 2024 17:10:35 +0200 Subject: [PATCH 1/7] Add connector_id to DrmDisplayHandle --- src/unix.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/unix.rs b/src/unix.rs index e1d5023..87a654f 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -213,6 +213,7 @@ pub struct DrmDisplayHandle { /// The drm file descriptor. // TODO: Use `std::os::fd::RawFd`? pub fd: i32, + pub connector_id: u32, } impl DrmDisplayHandle { @@ -228,8 +229,8 @@ impl DrmDisplayHandle { /// # fd = 0; /// let handle = DrmDisplayHandle::new(fd); /// ``` - pub fn new(fd: i32) -> Self { - Self { fd } + pub fn new(fd: i32, connector_id: u32) -> Self { + Self { fd, connector_id } } } From 332ee8508fe9c26295eea3b1b6ab021700fe4858 Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Fri, 5 Jul 2024 21:29:12 +0200 Subject: [PATCH 2/7] Fix DrmDisplayHandle::new doc-test --- src/unix.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix.rs b/src/unix.rs index 87a654f..7a84e72 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -226,8 +226,10 @@ impl DrmDisplayHandle { /// # use raw_window_handle::DrmDisplayHandle; /// # /// let fd: i32; + /// let connector_id: u32; /// # fd = 0; - /// let handle = DrmDisplayHandle::new(fd); + /// # connector_id = 0; + /// let handle = DrmDisplayHandle::new(fd, connector_id); /// ``` pub fn new(fd: i32, connector_id: u32) -> Self { Self { fd, connector_id } From 2c43a166aafee940563a9924b9ea3028875a09d7 Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Fri, 5 Jul 2024 22:14:56 +0200 Subject: [PATCH 3/7] Move connector_id to DrmWindowHandle --- src/unix.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/unix.rs b/src/unix.rs index 7a84e72..5990c9b 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -213,7 +213,6 @@ pub struct DrmDisplayHandle { /// The drm file descriptor. // TODO: Use `std::os::fd::RawFd`? pub fd: i32, - pub connector_id: u32, } impl DrmDisplayHandle { @@ -226,13 +225,11 @@ impl DrmDisplayHandle { /// # use raw_window_handle::DrmDisplayHandle; /// # /// let fd: i32; - /// let connector_id: u32; /// # fd = 0; - /// # connector_id = 0; - /// let handle = DrmDisplayHandle::new(fd, connector_id); + /// let handle = DrmDisplayHandle::new(fd); /// ``` - pub fn new(fd: i32, connector_id: u32) -> Self { - Self { fd, connector_id } + pub fn new(fd: i32) -> Self { + Self { fd } } } @@ -242,6 +239,7 @@ impl DrmDisplayHandle { pub struct DrmWindowHandle { /// The primary drm plane handle. pub plane: u32, + pub connector_id: Option, } impl DrmWindowHandle { @@ -258,7 +256,10 @@ impl DrmWindowHandle { /// let handle = DrmWindowHandle::new(plane); /// ``` pub fn new(plane: u32) -> Self { - Self { plane } + Self { + plane, + connector_id: None, + } } } From 017263b1efc077cb55f9bbd48c409b74a03c5e4b Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Fri, 5 Jul 2024 22:28:43 +0200 Subject: [PATCH 4/7] Add doc comment for connector_id --- src/unix.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix.rs b/src/unix.rs index 5990c9b..08b2f1b 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -239,6 +239,7 @@ impl DrmDisplayHandle { pub struct DrmWindowHandle { /// The primary drm plane handle. pub plane: u32, + /// An optional handle to chosen drm connector pub connector_id: Option, } From 1eb46ade20d6de4b37c2c9de9ceca81b75d625a5 Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Fri, 5 Jul 2024 22:32:33 +0200 Subject: [PATCH 5/7] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8affffb..d8ad28e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +* Add optional connector_id field to DrmWindowHandle (#170) + ## 0.6.2 (2024-05-17) * Add OpenHarmony OS support (#164) From e51370ee51d38081916593ac8d962eaf237029f3 Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Sat, 13 Jul 2024 21:33:10 +0200 Subject: [PATCH 6/7] Add new_with_connector_id constructor to DrmWindowHandle --- src/unix.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/unix.rs b/src/unix.rs index 08b2f1b..4bdcd79 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -262,6 +262,28 @@ impl DrmWindowHandle { connector_id: None, } } + + /// Create a new handle to a plane and associated connector_id. + /// + /// + /// # Example + /// + /// ``` + /// # use raw_window_handle::DrmWindowHandle; + /// # use core::num::NonZeroU32; + /// # + /// let plane: u32; + /// # plane = 0; + /// let connector_id: NonZeroU32; + /// # connect_id = unsafe { NonZeroU32::new_unchecked(1) }; + /// let handle = DrmWindowHandle::new_with_connector_id(plane, connector_id); + /// ``` + pub fn new_with_connector_id(plane: u32, connector_id: NonZeroU32) -> Self { + Self { + plane, + connector_id: Some(connector_id), + } + } } /// Raw display handle for the Linux Generic Buffer Manager. From 10eb23b1558ff972f39fdda258711b52665e9b7d Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Sat, 13 Jul 2024 21:35:36 +0200 Subject: [PATCH 7/7] Fix type in new_with_connector_id doctest --- src/unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix.rs b/src/unix.rs index 4bdcd79..c7d97ff 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -275,7 +275,7 @@ impl DrmWindowHandle { /// let plane: u32; /// # plane = 0; /// let connector_id: NonZeroU32; - /// # connect_id = unsafe { NonZeroU32::new_unchecked(1) }; + /// # connector_id = unsafe { NonZeroU32::new_unchecked(1) }; /// let handle = DrmWindowHandle::new_with_connector_id(plane, connector_id); /// ``` pub fn new_with_connector_id(plane: u32, connector_id: NonZeroU32) -> Self {