mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
time: consolidate the different sleep functions into time.wait(Duration) (#8853)
This commit is contained in:
@@ -239,7 +239,7 @@ pub fn (mut cb Clipboard) set_text(text string) bool {
|
||||
C.XFlush(cb.display)
|
||||
cb.mutex.unlock()
|
||||
// sleep a little bit
|
||||
time.sleep(1)
|
||||
time.wait(1 * time.millisecond)
|
||||
return cb.is_owner
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ fn (mut cb Clipboard) get_text() string {
|
||||
if cb.got_text || retries == 0 {
|
||||
break
|
||||
}
|
||||
time.usleep(50000)
|
||||
time.wait(50 * time.millisecond)
|
||||
retries--
|
||||
}
|
||||
return cb.text
|
||||
@@ -306,8 +306,7 @@ fn (mut cb Clipboard) start_listener() {
|
||||
C.SelectionClear {
|
||||
if unsafe { event.xselectionclear.window == cb.window } && unsafe {
|
||||
event.xselectionclear.selection == cb.selection
|
||||
}
|
||||
{
|
||||
} {
|
||||
cb.mutex.@lock()
|
||||
cb.is_owner = false
|
||||
cb.text = ''
|
||||
@@ -339,9 +338,9 @@ fn (mut cb Clipboard) start_listener() {
|
||||
}
|
||||
C.SelectionNotify {
|
||||
if unsafe {
|
||||
event.xselection.selection == cb.selection && event.xselection.property != C.Atom(C.None)
|
||||
}
|
||||
{
|
||||
event.xselection.selection == cb.selection
|
||||
&& event.xselection.property != C.Atom(C.None)
|
||||
} {
|
||||
if unsafe { event.xselection.target == cb.get_atom(.targets) && !sent_request } {
|
||||
sent_request = true
|
||||
prop := read_property(cb.display, cb.window, cb.selection)
|
||||
@@ -385,7 +384,7 @@ fn (mut cb Clipboard) start_listener() {
|
||||
fn (mut cb Clipboard) intern_atoms() {
|
||||
cb.atoms << C.Atom(4) // XA_ATOM
|
||||
cb.atoms << C.Atom(31) // XA_STRING
|
||||
for i, name in atom_names {
|
||||
for i, name in x11.atom_names {
|
||||
only_if_exists := if i == int(AtomType.utf8_string) { 1 } else { 0 }
|
||||
cb.atoms << C.XInternAtom(cb.display, name.str, only_if_exists)
|
||||
if i == int(AtomType.utf8_string) && cb.atoms[i] == C.Atom(C.None) {
|
||||
@@ -419,10 +418,8 @@ fn read_property(d &C.Display, w C.Window, p C.Atom) Property {
|
||||
fn (cb &Clipboard) pick_target(prop Property) C.Atom {
|
||||
// The list of targets is a list of atoms, so it should have type XA_ATOM
|
||||
// but it may have the type TARGETS instead.
|
||||
if (prop.actual_type != cb.get_atom(.xa_atom) &&
|
||||
prop.actual_type != cb.get_atom(.targets)) ||
|
||||
prop.actual_format != 32
|
||||
{
|
||||
if (prop.actual_type != cb.get_atom(.xa_atom) && prop.actual_type != cb.get_atom(.targets))
|
||||
|| prop.actual_format != 32 {
|
||||
// This would be really broken. Targets have to be an atom list
|
||||
// and applications should support this. Nevertheless, some
|
||||
// seem broken (MATLAB 7, for instance), so ask for STRING
|
||||
|
||||
Reference in New Issue
Block a user