Recent

Author Topic: LINUX: My program stops when dragging one of it's window  (Read 2514 times)

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 479
  • Programming is FUN only when it works :)
    • Cool Technology
LINUX: My program stops when dragging one of it's window
« on: July 09, 2025, 08:48:15 pm »
I am running Lazarus 3.8 or the latest on Linux operating system.

I've compiled my project files and ran my program. My program seems to be behaving strangely now. Anytime I drag only the opened window on the screen, my whole program simply stops running even though it is responsive like it's serial communication comes to complete stop while I click my mouse button and keep dragging the window. When I do release the mouse button, my program is still responsive but everything else is PAUSED like the serial communication UNTIL I click on something else or the desktop background.

I've been reading about similar behavior on other posts on this forum. Is this something that can't be fixed? or Is it a bug in Lazarus complier?


n7800

  • Hero Member
  • *****
  • Posts: 672
  • Lazarus IDE contributor
    • GitLab profile
Re: LINUX: My program stops when dragging one of it's window
« Reply #1 on: July 09, 2025, 11:23:20 pm »
By the way, I noticed it a long time ago. The same behavior is on Windows.

As a simple example - call the Find in Files in the IDE itself. While it is running (and you see the file names flashing in the window), start dragging the window (any of the IDE). Until you release it, the search will freeze on one file.

Moreover, you can hold it as long as you like, and the search will continue from this file. That is, this is not a problem of stopped rendering, but a "pause". In the Task Manager, you can even see that the CPU load becomes zero.

When I do release the mouse button, my program is still responsive but everything else is PAUSED like the serial communication UNTIL I click on something else or the desktop background.

Although I did not understand this part, and perhaps this is a different problem. I do not need to click on anything else, it is enough to release the mouse. What do you mean by "serial communication"?

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 479
  • Programming is FUN only when it works :)
    • Cool Technology
Re: LINUX: My program stops when dragging one of it's window
« Reply #2 on: July 10, 2025, 03:00:43 pm »
When I do release the mouse button, my program is still responsive but everything else is PAUSED like the serial communication UNTIL I click on something else or the desktop background.

What did I mean by that? The program simply stops running even after releasing the mouse until you click again on the same window or right on the desktop. For instance, my program talks to hardware through serial communication or serial port non-stop every 100 milliseconds. This communication completely stops when dragging the windows and it only reactivates after clicking on the same window again after releasing the mouse or right on the desktop. If I do nothing, the whole program is PAUSED or stops processing. My program didn't use to do that before.

I am not so worried about the fact that this is happening, but I don't like the fact that I have to take extra steps to get my program running again by clicking around the desktop or anywhere. I was wondering if there is a way to "TICKLE" the program into running again AUTOMATICALLY right after releasing the mouse pointer.

Thaddy

  • Hero Member
  • *****
  • Posts: 18911
  • Glad to be alive.
Re: LINUX: My program stops when dragging one of it's window
« Reply #3 on: July 10, 2025, 03:06:35 pm »
All I can say is that this is maybe a threading issue, but I can't help you if you do not show code that you expect to compile. It is not a bug.
You mention serial communications: what component or library do you use?

BTW It is nothing to be ashamed about in posting bad code. I do that myself sometimes.
« Last Edit: July 10, 2025, 03:09:00 pm by Thaddy »
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 479
  • Programming is FUN only when it works :)
    • Cool Technology
Re: LINUX: My program stops when dragging one of it's window
« Reply #4 on: July 10, 2025, 03:50:53 pm »
BTW It is nothing to be ashamed about in posting bad code. I do that myself sometimes.
:D :D :D :D :D :D :D :D :D lol

No no ... It is nothing like that. This is not happening in one section or part of my program or code. This is happening for the whole program. I could open any windows in my program and drag the window to pause the program. So, it wouldn't really help to post a snippet of a code from one part of my project. Since this is known to happen for a very long time, I thought maybe someone came up with a solution or workaround for this issue.

I've tried OnMouseUp and OnDragDrop events and calling focus or refresh for the window to help my program running again automatically, but it hasn't worked so far.

Thaddy

  • Hero Member
  • *****
  • Posts: 18911
  • Glad to be alive.
Re: LINUX: My program stops when dragging one of it's window
« Reply #5 on: July 10, 2025, 03:53:32 pm »
Well, no code, no help.. because in this case that is impossible.
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

n7800

  • Hero Member
  • *****
  • Posts: 672
  • Lazarus IDE contributor
    • GitLab profile
Re: LINUX: My program stops when dragging one of it's window
« Reply #6 on: July 10, 2025, 05:58:49 pm »
You mention serial communications: what component or library do you use?

Good question, maybe it's a component. Without it (or when it's not used) the error appears?

Perhaps you can make the smallest program that reproduces the error?

n7800

  • Hero Member
  • *****
  • Posts: 672
  • Lazarus IDE contributor
    • GitLab profile
Re: LINUX: My program stops when dragging one of it's window
« Reply #7 on: July 10, 2025, 05:59:53 pm »
I've been reading about similar behavior on other posts on this forum.

Perhaps you can provide links so that we can better understand what we are talking about?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4709
  • I like bugs.
Re: LINUX: My program stops when dragging one of it's window
« Reply #8 on: July 10, 2025, 08:44:19 pm »
The OS and its window manager should take care of dragging a window. LCL should have no reason to interfere. Or does it? I don't know LCL very deeply.
What in LCL could even theoretically stop all other activities then? A misplaced critical section maybe.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12288
  • Debugger - SynEdit - and more
    • wiki
Re: LINUX: My program stops when dragging one of it's window
« Reply #9 on: July 10, 2025, 08:59:09 pm »
First of all, are you running single threaded?
Or are you saying that all of your custom threads are "paused" while the window is dragged?


2nd "serial comm"? Is that on a timer?
I.e. if your app has a single thread then you either are
- on a timer
- in a loop with Application.ProcessMessages (not recommended)
- ????
I don't know all the different Linux distros (and likely its something related to some WindowManager)...
I don't know, but it isn't impossible that a Windows Manager takes full time of the main-thread (either in ProcessMessages, just prevents the PeekMessage from returning // or temp pauses timers). Again, don't know...


Quote
When I do release the mouse button, my program is still responsive but everything else is PAUSED like the serial communication UNTIL I click on something else or the desktop background.

Weird... very weird.

If you do ProcessMessages => maybe you are stuck inside that (i.e. it never returns). You app would then run inside that, but the caller (running your other work) would wait forever.
I have no idea why it wouldn't return. There would have to be a constant flow of messages. Your CPU should be real busy... (1 core fully loaded).

 

TinyPortal © 2005-2018