-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
182 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use { | ||
crate::{ | ||
it::{ | ||
test_error::TestError, test_ifs::test_xdg_toplevel::TestXdgToplevel, | ||
test_object::TestObject, test_transport::TestTransport, | ||
}, | ||
wire::{xdg_toplevel_drag_v1::*, XdgToplevelDragV1Id}, | ||
}, | ||
std::{cell::Cell, rc::Rc}, | ||
}; | ||
|
||
pub struct TestToplevelDrag { | ||
pub id: XdgToplevelDragV1Id, | ||
pub tran: Rc<TestTransport>, | ||
pub destroyed: Cell<bool>, | ||
} | ||
|
||
impl TestToplevelDrag { | ||
pub fn destroy(&self) -> Result<(), TestError> { | ||
if !self.destroyed.replace(true) { | ||
self.tran.send(Destroy { self_id: self.id })?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub fn attach( | ||
&self, | ||
toplevel: &TestXdgToplevel, | ||
x_offset: i32, | ||
y_offset: i32, | ||
) -> Result<(), TestError> { | ||
self.tran.send(Attach { | ||
self_id: self.id, | ||
toplevel: toplevel.core.id, | ||
x_offset, | ||
y_offset, | ||
})?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl Drop for TestToplevelDrag { | ||
fn drop(&mut self) { | ||
let _ = self.destroy(); | ||
} | ||
} | ||
|
||
test_object! { | ||
TestToplevelDrag, XdgToplevelDragV1; | ||
} | ||
|
||
impl TestObject for TestToplevelDrag {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use { | ||
crate::{ | ||
it::{ | ||
test_error::{TestError, TestResult}, | ||
test_ifs::{test_data_source::TestDataSource, test_toplevel_drag::TestToplevelDrag}, | ||
test_object::TestObject, | ||
test_transport::TestTransport, | ||
}, | ||
wire::{xdg_toplevel_drag_manager_v1::*, XdgToplevelDragManagerV1Id}, | ||
}, | ||
std::{cell::Cell, rc::Rc}, | ||
}; | ||
|
||
pub struct TestToplevelDragManager { | ||
pub id: XdgToplevelDragManagerV1Id, | ||
pub tran: Rc<TestTransport>, | ||
pub destroyed: Cell<bool>, | ||
} | ||
|
||
impl TestToplevelDragManager { | ||
pub fn new(tran: &Rc<TestTransport>) -> Self { | ||
Self { | ||
id: tran.id(), | ||
tran: tran.clone(), | ||
destroyed: Cell::new(false), | ||
} | ||
} | ||
|
||
pub fn destroy(&self) -> Result<(), TestError> { | ||
if !self.destroyed.replace(true) { | ||
self.tran.send(Destroy { self_id: self.id })?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub fn get_xdg_toplevel_drag( | ||
&self, | ||
data_source: &TestDataSource, | ||
) -> TestResult<Rc<TestToplevelDrag>> { | ||
let obj = Rc::new(TestToplevelDrag { | ||
id: self.tran.id(), | ||
tran: self.tran.clone(), | ||
destroyed: Cell::new(false), | ||
}); | ||
self.tran.add_obj(obj.clone())?; | ||
self.tran.send(GetXdgToplevelDrag { | ||
self_id: self.id, | ||
id: obj.id, | ||
data_source: data_source.id, | ||
})?; | ||
Ok(obj) | ||
} | ||
} | ||
|
||
impl Drop for TestToplevelDragManager { | ||
fn drop(&mut self) { | ||
let _ = self.destroy(); | ||
} | ||
} | ||
|
||
test_object! { | ||
TestToplevelDragManager, XdgToplevelDragManagerV1; | ||
} | ||
|
||
impl TestObject for TestToplevelDragManager {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use { | ||
crate::{ | ||
ifs::wl_seat::BTN_LEFT, | ||
it::{ | ||
test_error::{TestErrorExt, TestResult}, | ||
testrun::TestRun, | ||
}, | ||
}, | ||
std::rc::Rc, | ||
}; | ||
|
||
testcase!(); | ||
|
||
async fn test(run: Rc<TestRun>) -> TestResult { | ||
let ds = run.create_default_setup().await?; | ||
|
||
let client = run.create_client().await?; | ||
let drag_manager = client.registry.get_drag_manager().await?; | ||
let seat = client.get_default_seat().await?; | ||
let source = client.data_device_manager.create_data_source()?; | ||
let dev = client.data_device_manager.get_data_device(&seat.seat)?; | ||
let drag = drag_manager.get_xdg_toplevel_drag(&source)?; | ||
let win = client.create_window().await?; | ||
win.set_color(255, 255, 0, 255); | ||
win.map2().await?; | ||
|
||
let button = seat.pointer.button.expect()?; | ||
let click = ds.mouse.click(BTN_LEFT); | ||
|
||
client.sync().await; | ||
let serial = button.next().with_context(|| "button")?.serial; | ||
seat.pointer.set_cursor(serial, None, 0, 0)?; | ||
drag.attach(&win.tl, 100, 100)?; | ||
source.set_actions(1)?; | ||
dev.start_drag(&source, &win.surface, None, serial)?; | ||
|
||
client.sync().await; | ||
client.compare_screenshot("1", true).await?; | ||
drop(click); | ||
client.sync().await; | ||
client.compare_screenshot("2", true).await?; | ||
|
||
Ok(()) | ||
} |
Binary file not shown.
Binary file not shown.