star-tek-mb / zig-tray

Create tray applications with zig
12 stars 3 forks source link

feat: Add trigger of the left click and optimize the code logic #2

Closed jinzhongjia closed 1 week ago

jinzhongjia commented 1 week ago
jinzhongjia commented 1 week ago

Please don't merge this PR yet, I still have some work to do.

Now, everything is ok!

jinzhongjia commented 1 week ago

After this work is completed I will try to add linux support

jinzhongjia commented 1 week ago

add block and non-block mode, block-time is waiting time for nanoseconds

jinzhongjia commented 1 week ago

We cannot keep using PeekMessageA to retrieve whether there are messages, because this will cause high CPU usage. On this basis, a short sleep will effectively solve the problem.

Another better solution is to use blocking api, which is getMessageA

star-tek-mb commented 1 week ago

Hello! Thank you for your work! Please let me know, if you want merge.

jinzhongjia commented 1 week ago

I think the PR is ready to be merged

However, the behavior of the init function is slightly different from that of the init function in the zig standard library (in the standard library it will return a specific value of a certain type for initialization). I will try to see if I can make it more idiomatic.

jinzhongjia commented 1 week ago

However, for the init work, I plan to open another PR later. The current PR has made enough changes.

star-tek-mb commented 1 week ago

Looks good to me. But i think we need to change variable name in ConstMenu. Change enum text to content with fields text and separator. And also we should definitely change init function to return instance of Tray. We also need to specify default values for init function. For example nulls on event handlers for click, and default block time.

I will look into it in the weekends. Or I can wait for your PR if you want to do some coding.