Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to get clientrect position or the rect size of titlebar?  (Read 3629 times)

0 Members and 1 Guest are viewing this topic.

zwcloud

  • Newbie
  • *
  • Posts: 4
    • View Profile
How to get clientrect position or the rect size of titlebar?
« on: November 01, 2015, 02:46:00 pm »
I want to show a borderless window located precisely at a certain position of another window which has a titlebar. But without the ClientRect Position or the rect size, I think, there is no way to do that.

By the way, The search system of SFML forum is awful. @Laurent I think you'd better place a google search box instead.

Using SFML.Net 2.2.
« Last Edit: November 01, 2015, 02:54:55 pm by zwcloud »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: How to get clientrect position or the rect size of titlebar?
« Reply #1 on: November 01, 2015, 04:07:59 pm »
You can call an OS-specific function on your window with window.getSystemHandle().

Quote
By the way, The search system of SFML forum is awful. @Laurent I think you'd better place a google search box instead.
Why is it awful?
Laurent Gomila - SFML developer

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: How to get clientrect position or the rect size of titlebar?
« Reply #2 on: November 01, 2015, 08:37:14 pm »
Quote
By the way, The search system of SFML forum is awful. @Laurent I think you'd better place a google search box instead.
Why is it awful?

Because it shows cut pieces of texts, it looks just like garbage

zwcloud

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to get clientrect position or the rect size of titlebar?
« Reply #3 on: November 02, 2015, 02:13:01 am »
Quote
You can call an OS-specific function on your window with window.getSystemHandle().
OK, I get it.

Quote
Because it shows cut pieces of texts, it looks just like garbage
Yes, exactly.
« Last Edit: November 02, 2015, 02:15:44 am by zwcloud »

zwcloud

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to get clientrect position or the rect size of titlebar?
« Reply #4 on: December 30, 2015, 05:11:19 pm »
You can call an OS-specific function on your window with window.getSystemHandle().

Hi Laurent, It works when using Win32 API on Window. But when porting my project to linux, I find it may be impossible to get the client rect of the window under linux/X11.

Because the Window.getSystemHandle() function calls sfWindow_getSystemHandle in CSFML.
public virtual IntPtr SystemHandle
{
    get {return sfWindow_getSystemHandle(CPointer);}
}
 
https://github.com/SFML/SFML.Net/blob/master/src/Window/Window.cs#L325

And sfWindow_getSystemHandle returns a sfWindowHandle.
sfWindowHandle sfWindow_getSystemHandle(const sfWindow* window)
{
    CSFML_CHECK_RETURN(window, 0);

    return (sfWindowHandle)window->This.getSystemHandle();
}
 
https://github.com/SFML/CSFML/blob/3e767dec4f812116f29edbbf58803f5e40833a4a/src/SFML/Window/Window.cpp#L326
https://github.com/SFML/SFML/blob/2d1fab374f3d7e9765fe1e83b23dfb5b7f80f012/src/SFML/Window/Window.cpp#L374
https://github.com/SFML/CSFML/blob/3e767dec4f812116f29edbbf58803f5e40833a4a/include/SFML/Window/WindowHandle.h#L47

Which refers to a xcb_window_t.
https://github.com/SFML/SFML/blob/2d1fab374f3d7e9765fe1e83b23dfb5b7f80f012/src/SFML/Window/Unix/WindowImplX11.cpp#L585
https://github.com/SFML/SFML/blob/2d1fab374f3d7e9765fe1e83b23dfb5b7f80f012/src/SFML/Window/Unix/WindowImplX11.cpp#L388


But I can't get the client rect when only a xcb_window_t is provided under linux/X11. The X Display is need to retrive the client rect info.

If the X Display is provided, I can use XGetGeometry to get the client area info.

Anyway, I cannot make it when only xcb_window_t is available. :(

I'm not familiar with linux/X11, Xlib and XCB and was just beginning to dig into these problem. Yet not a native English speaker. Ask me if any can not be understood. :)

PS.
I have looked into the Window.CPointer in SFML.NET, but it is just a opaque struct used internally. Am I right?
https://github.com/SFML/CSFML/blob/3e767dec4f812116f29edbbf58803f5e40833a4a/include/SFML/Window/Types.h#L30
« Last Edit: December 30, 2015, 05:22:42 pm by zwcloud »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: How to get clientrect position or the rect size of titlebar?
« Reply #5 on: December 30, 2015, 06:05:02 pm »
You might be able to use your own Display, no need to get the one that SFML has internally.
Laurent Gomila - SFML developer

 

anything