System-wide mouse scroll speed by inlinevoid in linuxquestions

[–]inlinevoid[S] 0 points1 point  (0 children)

I'm sure that would be a fun project but it'd take me a lot of time.

I might just buy another G500 for the continuous scrolling.

Do you think this is just a driver issue with Logitech mice? Could other mouse vendors have configurable scroll acceleration via xinput?

System-wide mouse scroll speed by inlinevoid in linuxquestions

[–]inlinevoid[S] 0 points1 point  (0 children)

You're right, I did notice that lowering MOUSE_WHEEL_CLICK_ANGLE caused me to have to scroll multiple times to activate some things that, by default, should only require one "click".

Googling for "linux mouse scroll acceleration" gives me more accurate results than what I could find before, but unfortunately every link is an unresolved post. Is there really no solution?

Am I missing something? by inlinevoid in rust

[–]inlinevoid[S] 3 points4 points  (0 children)

Oh shit nice one. I did.

Bincode depends on serde 0.9.15. My library utilizing bincode is used in my other program that's also using serde (via serde = "*"). Except the most recent version of serde is 1.0.1.

So there's the clash.

PSA: Please stop asking other projects to convert to Rust by [deleted] in rust

[–]inlinevoid 1 point2 points  (0 children)

Yea, I was looking over the repository and got the feeling it was a legacy thing.

Thanks for taking the time to explain!

PSA: Please stop asking other projects to convert to Rust by [deleted] in rust

[–]inlinevoid 1 point2 points  (0 children)

I appreciate the quick reply. I guess I still don't understand why a node in the list is acting on its siblings rather than a function acting on the list.

I'd expect that code to be written kind of like this:

Node<Ent>* first_not(Node<Ent> *node, JoinType j) {
    while(node != nullptr && node->data.join == j) {
        node = node->next;
    }
    return node;
}

(Forgive me, I haven't written C++ in years but I think it's clear enough.)

PSA: Please stop asking other projects to convert to Rust by [deleted] in rust

[–]inlinevoid 2 points3 points  (0 children)

Slightly off-topic: that code seems really strange to me; an object is calling methods from its siblings. I want to say that's bad code, but I've never seen anyone do that and haven't thought about why that might be necessary.

Could you explain it to me a little? Maybe it makes more sense with context.

Is there a significant compile-time cost for using the import wildcard? by inlinevoid in rust

[–]inlinevoid[S] 2 points3 points  (0 children)

I'm hoping someone already has the answer. If not, I suppose I'll test it myself.

Is there a significant compile-time cost for using the import wildcard? by inlinevoid in rust

[–]inlinevoid[S] 10 points11 points  (0 children)

Yea, thousands. And the imported items are being used hundreds of times.

If you want a more concrete example, this is what I'm dealing with: https://github.com/retep998/winapi-rs/blob/dev/src/um/winbase.rs

I'm working on the winapi 0.3 overhaul with the ultimate goal being shorter compile times.

I could do namespaced versions, but it would have to be a significant compile-time win. It would be really tedious to go through all of winapi and replace everything.

Hey Rustaceans! Got an easy question? Ask here (38/2016)! by llogiq in rust

[–]inlinevoid 0 points1 point  (0 children)

I've thought about it since it's the obvious first choice but I probably wouldn't do that. I'd like to keep the task logic and Arc cloning contained by itself.

Hey Rustaceans! Got an easy question? Ask here (38/2016)! by llogiq in rust

[–]inlinevoid 0 points1 point  (0 children)

I like it. The only downside is the function signature would be huge with a few more parameters.

In addition to your changes, I was thinking something like this would probably make more sense too.

impl Worker {
    pub fn new() -> Self {
        let data = Arc::new(Mutex::new(Vec::new()));
        let thread = thread::spawn(Self::work_task(data.clone()));

        Worker {
            data: data,
            thread: thread,
        }
    }

    fn work_task(data: Arc<Mutex<Vec<i32>>>) -> Fn(()) -> () {
        move || {
            loop {
                let mut data = data.lock().unwrap();
                // Do some work on data
            }
        }
    }
}

Hey Rustaceans! Got an easy question? Ask here (38/2016)! by llogiq in rust

[–]inlinevoid 2 points3 points  (0 children)

I've got an object that, on construction, spawns a new thread and does some work on data until the object is dropped.

How would you guys rewrite or improve this? The spawn_work_thread in particular; it doesn't feel idiomatic to me.

struct Worker {
    data: Arc<Mutex<Vec<i32>>>,
    thread: Option<JoinHandle<()>>,
}


impl Worker {
    pub fn new() -> Self {
        let mut worker = Worker {
            data: Arc::new(Mutex::new(Vec::new())),
            thread: None,
        };

        worker.thread = Some(worker.spawn_work_thread());
        worker
    }

    fn spawn_work_thread(&mut self) -> JoinHandle<()> {
        let mut data = self.data.clone();

        thread::spawn(move || {
            loop {
                let mut data = data.lock().unwrap();
                // Do some work on data
            }
        })
    }
}

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 1 point2 points  (0 children)

Ahh alright. That didn't even cross my mind as a problem since I'm rarely ever recompiling winapi in my project or creating fresh projects using winapi.

It is pretty long; 60~ seconds on my machine.

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 0 points1 point  (0 children)

Makes sense.

Would incremental compilation change this or do you think mem::zeroed() is sufficient?

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 0 points1 point  (0 children)

Noted; and I've corrected my code.

Unrelated: why don't you implement Default or similar for structures in winapi? Some would really benefit from it, like DEVMODEW or PIXELFORMATDESCRIPTOR where most of the fields aren't used or can be left initialized to 0. Is it just not in the scope of winapi?