implement API::window_outline_size for X11
This commit is contained in:
parent
e91d3446eb
commit
6ab867072d
@ -36,6 +36,14 @@ namespace detail
|
||||
unsigned extra_height; //extra border size, it is useful in Windows, ignore in X11 always 0
|
||||
};
|
||||
|
||||
struct frame_extents
|
||||
{
|
||||
int left;
|
||||
int right;
|
||||
int top;
|
||||
int bottom;
|
||||
};
|
||||
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
|
||||
//Execute a function in a thread which is associated with the specified native window.
|
||||
@ -70,6 +78,7 @@ namespace detail
|
||||
static void bring_top(native_window_type, bool activated);
|
||||
static void set_window_z_order(native_window_type, native_window_type wd_after, z_order_action action_if_no_wd_after);
|
||||
|
||||
static frame_extents window_frame_extents(native_window_type);
|
||||
static bool window_size(native_window_type, const size&);
|
||||
static void get_window_rect(native_window_type, rectangle&);
|
||||
static void window_caption(native_window_type, const native_string_type&);
|
||||
|
@ -130,39 +130,6 @@ namespace nana{
|
||||
nana::detail::platform_spec & spec = nana::detail::platform_spec::instance();
|
||||
}
|
||||
|
||||
struct frame_extents
|
||||
{
|
||||
long left;
|
||||
long right;
|
||||
long top;
|
||||
long bottom;
|
||||
};
|
||||
|
||||
frame_extents x11_frame_extents(Window wd)
|
||||
{
|
||||
frame_extents fm_extents;
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long len, bytes_left = 0;
|
||||
unsigned char *data;
|
||||
|
||||
if(Success == ::XGetWindowProperty(restrict::spec.open_display(), wd,
|
||||
restrict::spec.atombase().net_frame_extents, 0, 16, 0,
|
||||
XA_CARDINAL, &type, &format,
|
||||
&len, &bytes_left, &data))
|
||||
{
|
||||
if(type != None && len == 4)
|
||||
{
|
||||
fm_extents.left = ((long*)data)[0];
|
||||
fm_extents.right = ((long*)data)[1];
|
||||
fm_extents.top = ((long*)data)[2];
|
||||
fm_extents.bottom = ((long*)data)[3];
|
||||
}
|
||||
::XFree(data);
|
||||
}
|
||||
|
||||
return fm_extents;
|
||||
}
|
||||
|
||||
//The XMoveWindow and XMoveResizeWindow don't take effect if the specified window is
|
||||
//unmapped, and the members x and y of XSetSizeHints is obsoluted. So the position that
|
||||
@ -1186,6 +1153,46 @@ namespace nana{
|
||||
#endif
|
||||
}
|
||||
|
||||
native_interface::frame_extents native_interface::window_frame_extents(native_window_type wd)
|
||||
{
|
||||
frame_extents fm_extents{0, 0, 0, 0};
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
::RECT client;
|
||||
::GetClientRect(reinterpret_cast<HWND>(wd), &client); //The right and bottom of client by GetClientRect indicate the width and height of the area
|
||||
::RECT wd_area;
|
||||
::GetWindowRect(reinterpret_cast<HWND>(wd), &wd_area);
|
||||
|
||||
fm_extents.left = client.left - wd_area.left;
|
||||
fm_extents.right = wd_area.right - client.right;
|
||||
fm_extents.top = client.top - wd_area.top;
|
||||
fm_extents.bottom = wd_area.bottom - client.bottom;
|
||||
#elif defined(NANA_X11)
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long len, bytes_left = 0;
|
||||
unsigned char *data;
|
||||
|
||||
nana::detail::platform_scope_guard lock;
|
||||
if(Success == ::XGetWindowProperty(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
|
||||
restrict::spec.atombase().net_frame_extents, 0, 16, 0,
|
||||
XA_CARDINAL, &type, &format,
|
||||
&len, &bytes_left, &data))
|
||||
{
|
||||
if(type != None && len == 4)
|
||||
{
|
||||
fm_extents.left = ((long*)data)[0];
|
||||
fm_extents.right = ((long*)data)[1];
|
||||
fm_extents.top = ((long*)data)[2];
|
||||
fm_extents.bottom = ((long*)data)[3];
|
||||
}
|
||||
::XFree(data);
|
||||
}
|
||||
#endif
|
||||
|
||||
return fm_extents;
|
||||
}
|
||||
|
||||
bool native_interface::window_size(native_window_type wd, const size& sz)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user