XSetWindowAttributes attr;
attr.override_redirect = options.fullscreen;
- attr.event_mask = ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask|ExposureMask;
+ attr.event_mask = ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask|ExposureMask|FocusChangeMask;
+
+ // User position is set when the window is mapped
+ int x = 0;
+ int y = 0;
+ if(options.fullscreen && !options.fullscreen_exclusive)
+ {
+ const Monitor::Settings &ms = options.fullscreen_monitor->current_settings;
+ x = ms.x;
+ y = ms.y;
+ }
priv->window = XCreateWindow(dpy,
display.get_private().root_window,
- 0, 0,
+ x, y,
options.width, options.height,
0,
CopyFromParent,
{
XSizeHints hints;
hints.flags = PMinSize|PMaxSize;
- hints.min_width=hints.max_width = options.width;
- hints.min_height=hints.max_height = options.height;
+ hints.min_width = hints.max_width = options.width;
+ hints.min_height = hints.max_height = options.height;
XSetWMNormalHints(dpy, priv->window, &hints);
}
}
XSetWMNormalHints(dpy, priv->window, &hints);
if(options.fullscreen)
- XMoveResizeWindow(dpy, priv->window, 0, 0, options.width, options.height);
+ {
+ if(options.fullscreen_exclusive)
+ XMoveResizeWindow(dpy, priv->window, 0, 0, options.width, options.height);
+ else
+ {
+ const Monitor::Settings &ms = options.fullscreen_monitor->current_settings;
+ XMoveResizeWindow(dpy, priv->window, ms.x, ms.y, options.width, options.height);
+ }
+ }
+ else if(options.user_position)
+ XMoveResizeWindow(dpy, priv->window, options.x, options.y, options.width, options.height);
else
XResizeWindow(dpy, priv->window, options.width, options.height);
void Window::platform_show()
{
- XMapRaised(display.get_private().display, priv->window);
+ DisplayHandle dpy = display.get_private().display;
+ XMapRaised(dpy, priv->window);
+ if(options.user_position && !options.fullscreen)
+ XMoveWindow(dpy, priv->window, options.x, options.y);
}
void Window::platform_hide()
y -= priv->rel_y;
}
- if(x!=options.x || y!=options.y)
+ if((x==options.x && y==options.y) == moving)
{
options.x = x;
options.y = y;
+ moving = false;
signal_move.emit(options.x, options.y);
}
}
XSetInputFocus(display.get_private().display, priv->window, RevertToParent, CurrentTime);
break;
case MapNotify:
- if(options.fullscreen)
+ if(options.fullscreen && options.fullscreen_exclusive)
XGrabPointer(display.get_private().display, priv->window, true, None, GrabModeAsync, GrabModeAsync, priv->window, None, CurrentTime);
break;
case Expose:
signal_expose.emit(ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, evnt);
break;
+ case FocusIn:
+ signal_got_focus.emit();
+ break;
+ case FocusOut:
+ signal_lost_focus.emit();
+ break;
default:
return false;
}