Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Gtk primary #267

Merged
merged 3 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use wlroots_sys::{wlr_backend_destroy, wlr_backend_start,

use {backend::{self, UnsafeRenderSetupFunction, Backend, Session},
data_device,
extensions::{server_decoration, gamma_control, screencopy, screenshooter, idle},
extensions::{server_decoration, gamma_control, screencopy, screenshooter, idle, gtk_primary_selection},
surface::{self, Surface, InternalSurface},
input,
output,
Expand Down Expand Up @@ -117,6 +117,8 @@ pub struct Compositor {
pub gamma_control_manager: Option<gamma_control::Manager>,
/// Optional idle manager extension.
pub idle_manager: Option<idle::Manager>,
/// Optional GTK primary selection manager
pub gtk_primary_selection_manager: Option<gtk_primary_selection::Manager>,
/// Optional screencopy manager extension
pub screencopy_manager: Option<screencopy::ZManagerV1>,
/// Optional screenshooter manager extension
Expand Down Expand Up @@ -150,6 +152,7 @@ pub struct Builder {
server_decoration_manager: bool,
gamma_control_manager: bool,
idle_manager: bool,
gtk_primary_selection_manager: bool,
screencopy_manager: bool,
screenshooter: bool,
wayland_remote: Option<String>,
Expand Down Expand Up @@ -259,6 +262,13 @@ impl Builder {
self
}

/// Decide whether or not to enable the GTK primary selection manager protocol
/// extension.
pub fn gtk_primary_selection_manager(mut self, gtk_primary_selection_manager: bool) -> Self {
self.gtk_primary_selection_manager = gtk_primary_selection_manager;
self
}

/// Decide whether or not to enable the screencopy protocol
/// extension.
pub fn screencopy_manager(mut self, screencopy_manager: bool) -> Self {
Expand Down Expand Up @@ -439,6 +449,11 @@ impl Builder {
} else {
None
};
let gtk_primary_selection_manager = if self.gtk_primary_selection_manager {
gtk_primary_selection::Manager::new(display)
} else {
None
};
let screencopy_manager = if self.screencopy_manager {
screencopy::ZManagerV1::new(display)
} else {
Expand Down Expand Up @@ -552,6 +567,7 @@ impl Builder {
server_decoration_manager,
gamma_control_manager,
idle_manager,
gtk_primary_selection_manager,
screencopy_manager,
screenshooter,
renderer,
Expand Down
30 changes: 30 additions & 0 deletions src/extensions/gtk_primary_selection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! Support for the GTK Primary Selection Protocol

use wayland_sys::server::wl_display as wl_server_display;
use wlroots_sys::{wl_display, wlr_gtk_primary_selection_device_manager, wlr_gtk_primary_selection_device_manager_create,
wlr_gtk_primary_selection_device_manager_destroy};

#[derive(Debug)]
/// Manager that implements GTK primary selection
pub struct Manager {
manager: *mut wlr_gtk_primary_selection_device_manager
}

impl Manager {
pub(crate) unsafe fn new(display: *mut wl_server_display) -> Option<Self> {
let manager_raw = wlr_gtk_primary_selection_device_manager_create(display as *mut wl_display);

if !manager_raw.is_null() {
Some(Manager { manager: manager_raw })
} else {
None
}
}

}

impl Drop for Manager {
fn drop(&mut self) {
unsafe { wlr_gtk_primary_selection_device_manager_destroy(self.manager) }
}
}
1 change: 1 addition & 0 deletions src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pub mod gamma_control;
pub mod screenshooter;
pub mod screencopy;
pub mod idle;
pub mod gtk_primary_selection;
1 change: 1 addition & 0 deletions wlroots-sys/src/wlroots.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_input_device.h>
Expand Down