internal override void SetWindowState(IntPtr handle, FormWindowState state) {
FormWindowState current_state;
Hwnd hwnd;
hwnd = Hwnd.ObjectFromHandle(handle);
current_state = GetWindowState(handle);
if (current_state == state) {
return;
}
switch(state) {
case FormWindowState.Normal: {
lock (XlibLock) {
if (current_state == FormWindowState.Minimized) {
MapWindow(hwnd, WindowType.Both);
} else if (current_state == FormWindowState.Maximized) {
SendNetWMMessage(hwnd.whole_window, _NET_WM_STATE, (IntPtr)2 /* toggle */, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT);
}
}
Activate(handle);
return;
}
case FormWindowState.Minimized: {
lock (XlibLock) {
if (current_state == FormWindowState.Maximized) {
SendNetWMMessage(hwnd.whole_window, _NET_WM_STATE, (IntPtr)2 /* toggle */, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT);
}
XIconifyWindow(DisplayHandle, hwnd.whole_window, ScreenNo);
}
return;
}
case FormWindowState.Maximized: {
lock (XlibLock) {
if (current_state == FormWindowState.Minimized) {
MapWindow(hwnd, WindowType.Both);
}
SendNetWMMessage(hwnd.whole_window, _NET_WM_STATE, (IntPtr)1 /* Add */, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT);
}
Activate(handle);
return;
}
}
}