View Single Post
Old 04-02-2020, 04:14 AM   #998
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,682
Default

Quote:
Originally Posted by juliansader View Post
I checked the WDL/swell code, and it seems that swell usually regards the foreground window and the focused window as the same thing. On OSX and Linux, therefore, the focused *child* window will also be the foreground window.

I therefore suggest that you check whether the arrange view is focused, rather than whether the main window is in the foreground.

On Windows, AFAIK, the foreground window should be the parent toplevel window of the focused child window. Am I correct?

Perhaps I can add some code to JS_Window_GetForeground on Linux/OSX to return the parent toplevel window.
It would be nice if it can check that internally, right now I'm using workaround but not sure how good it is.

Code:
function Get_window_under_mouse()
   if mouse.l_down then
      local windowUnderMouse = reaper.JS_Window_FromPoint(mouse.x, mouse.y)
      local old_windowUnderMouse = reaper.JS_Window_FromPoint(mouse.ox, mouse.oy)
      if windowUnderMouse then
         if windowUnderMouse ~= track_window then
            return true
         elseif old_windowUnderMouse then
            if old_windowUnderMouse ~= track_window then
               return true
            end
         end
      end
   end
   return false
end
It returns true if some window is at top, but it needed additional checking (old_window) because it would crash on OSX if dragging from one window to another (which does not happen on Windows)
Sexan is offline   Reply With Quote