GUI Window movement

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Kamal123
Member
Member
Posts: 99
Joined: Fri Nov 01, 2019 1:17 am

GUI Window movement

Post by Kamal123 »

Hi,
I use compositing window manager, so for now, when I move an window the server sends messages to clients to redraw itself in new position then clients redraw every widgets in new position which becomes slower when many widgets are present and sometimes the entire system crashes!! Is my method is correct?.. what method do you apply for window movement in compositor?...
What happens actually, when window is moved in compositing window manager?

Thanks in advance!!
vhaudiquet
Member
Member
Posts: 43
Joined: Sun Aug 20, 2017 10:59 am

Re: GUI Window movement

Post by vhaudiquet »

the server sends messages to clients to redraw itself in new position then clients redraw every widgets in new position
Why would you need to redraw every widget ?
From my understanding there isn't a widget update needed, and as the display server must know the framebuffer, moving a window is just moving an array of pixels.
You don't need to update anything when moving a window (if you are not changing it's size)
You can just memcpy the pixel array of that window and clear/redraw background on the old position.
You don't even have to know which widgets/library is used by the client.
thewrongchristian
Member
Member
Posts: 426
Joined: Tue Apr 03, 2018 2:44 am

Re: GUI Window movement

Post by thewrongchristian »

Kamal123 wrote:Hi,
I use compositing window manager, so for now, when I move an window the server sends messages to clients to redraw itself in new position then clients redraw every widgets in new position which becomes slower when many widgets are present and sometimes the entire system crashes!! Is my method is correct?.. what method do you apply for window movement in compositor?...
What happens actually, when window is moved in compositing window manager?

Thanks in advance!!
A compositing window manager should provide each top level window with its own pixmap buffer, into which the application renders its widgets. The compositing window manager then blits that buffer to its final position on the screen. So moving a window on the screen should just be a blit of an already rendered buffer, no client redrawing necessary.

Expose events are a throwback to when the screen framebuffer was the only place widgets were rendered, and made sense when video cards had 256KB RAM and machines didn't have enough main memory space or bandwidth to maintain an off screen pixmap for each top level window.
Kamal123
Member
Member
Posts: 99
Joined: Fri Nov 01, 2019 1:17 am

Re: GUI Window movement

Post by Kamal123 »

Thanks, now my confusions are cleared. I fixed it...I have another question, I have pop-up menus, so if a popup menu is visible and after any menu item is clicked the popup menu disappears. If the popup menu disappears, how do I restore the contents behind it?..I am totally new to graphical widgets programing. I want to know the methods implemented in pop-up menus!!

Thanks in advance
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: GUI Window movement

Post by nullplan »

Kamal123 wrote:Thanks, now my confusions are cleared. I fixed it...I have another question, I have pop-up menus, so if a popup menu is visible and after any menu item is clicked the popup menu disappears. If the popup menu disappears, how do I restore the contents behind it?..I am totally new to graphical widgets programing. I want to know the methods implemented in pop-up menus!!
In most windowing environments, a pop-up menu is just another window (only without decoration), so it obscuring parts of other windows is just business as usual. When it goes away, either you saved the content of the obscured window and can restore it, or you send a message to the now visible window saying to redraw the damaged parts. In Windows, this is a WM_PAINT message, in X11 it is an XExposeEvent. The former method is not easy to do right, so a simple implementation probably just ought to go with the latter one.
Carpe diem!
Kamal123
Member
Member
Posts: 99
Joined: Fri Nov 01, 2019 1:17 am

Re: GUI Window movement

Post by Kamal123 »

nullplan wrote:
Kamal123 wrote:Thanks, now my confusions are cleared. I fixed it...I have another question, I have pop-up menus, so if a popup menu is visible and after any menu item is clicked the popup menu disappears. If the popup menu disappears, how do I restore the contents behind it?..I am totally new to graphical widgets programing. I want to know the methods implemented in pop-up menus!!
In most windowing environments, a pop-up menu is just another window (only without decoration), so it obscuring parts of other windows is just business as usual. When it goes away, either you saved the content of the obscured window and can restore it, or you send a message to the now visible window saying to redraw the damaged parts. In Windows, this is a WM_PAINT message, in X11 it is an XExposeEvent. The former method is not easy to do right, so a simple implementation probably just ought to go with the latter one.
Thank you so much, for your reply. I'll try to implement.
Post Reply