Jump to content

Check for window focus


TonyF
 Share

Recommended Posts

Is it possible to check if the window is focused or not eg tabbed out?

 

Some googling indicated in leadwerks 2 AppSuspended() was used however i cant seem to find a leadwerks 3 versions.

 

Im basically trying to stop moving the mouse when the window isnt active

Link to comment
Share on other sites

Thanks to this, something like this should work

 

EDIT: I installed XUbuntu 14.04 on dual-boot to test this, below is the working version

bool isActiveWindow(Leadwerks::Window* window)

{

if( window == nullptr )

return false;

 

#if defined(__linux__) && !defined(__ANDROID__)

::Window root = 0L;

::Window active = 0L;

Atom _NET_ACTIVE_WINDOW = XInternAtom(window->display, "_NET_ACTIVE_WINDOW", False);

Atom actual_type;

int actual_format;

unsigned long count, bytesAfter;

unsigned char* properties = NULL;

 

root = DefaultRootWindow(window->display);

if( XGetWindowProperty(window->display, root, _NET_ACTIVE_WINDOW, 0L, sizeof(::Window), False, XA_WINDOW, &actual_type, &actual_format, &count, &bytesAfter, &properties) == Success )

{

active = *reinterpret_cast<::Window*>(properties);

XFree(properties);

}

 

return (window->window == active);

#else

return window->Active();

#endif

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...