mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
2023 kickstarter fix to compile CtrlCore and run upp apps with X11 flag (#128)
This commit is contained in:
parent
e69b3caacc
commit
f6fd99f4b0
6 changed files with 137 additions and 154 deletions
|
|
@ -92,36 +92,6 @@ void GuiPlatformAfterMenuPopUp()
|
|||
Ctrl::ProcessEvents();
|
||||
}
|
||||
|
||||
void Ctrl::PaintCaret(SystemDraw& w)
|
||||
{
|
||||
GuiLock __;
|
||||
if(this == caretCtrl && WndCaretVisible)
|
||||
w.DrawRect(caretx, carety, caretcx, caretcy, InvertColor);
|
||||
}
|
||||
|
||||
void Ctrl::SetCaret(int x, int y, int cx, int cy)
|
||||
{
|
||||
GuiLock __;
|
||||
if(this == caretCtrl)
|
||||
RefreshCaret();
|
||||
caretx = x;
|
||||
carety = y;
|
||||
caretcx = cx;
|
||||
caretcy = cy;
|
||||
WndCaretTime = msecs();
|
||||
if(this == caretCtrl)
|
||||
RefreshCaret();
|
||||
}
|
||||
|
||||
void Ctrl::SyncCaret() {
|
||||
GuiLock __;
|
||||
if(focusCtrl != caretCtrl) {
|
||||
RefreshCaret();
|
||||
caretCtrl = focusCtrl;
|
||||
RefreshCaret();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ protected:
|
|||
|
||||
private:
|
||||
static ArrayMap<Window, XWindow>& Xwindow();
|
||||
static int WndCaretTime;
|
||||
static bool WndCaretVisible;
|
||||
static int Xbuttons;
|
||||
static int Xbuttontime;
|
||||
static Point Xbuttonpos;
|
||||
|
|
@ -26,7 +24,6 @@ private:
|
|||
static void TimerAndPaint();
|
||||
static void ProcessEvent(XEvent& event);
|
||||
void Invalidate(XWindow& xw, const Rect& r);
|
||||
static void AnimateCaret();
|
||||
void DoPaint(const Vector<Rect>& invalid);
|
||||
void SetLastActive(XWindow *w, Ctrl *la);
|
||||
XWindow *GetXWindow();
|
||||
|
|
@ -94,7 +91,8 @@ public:
|
|||
|
||||
virtual void EventProc(XWindow& w, XEvent *event);
|
||||
virtual bool HookProc(XEvent *event);
|
||||
Window GetWindow() const { return top ? top->window : None; }
|
||||
Window GetWindow() const { return utop ? utop->window : None; }
|
||||
static int GetCaretBlinkTime() { return 500; }
|
||||
static Ctrl *CtrlFromWindow(Window w);
|
||||
static bool TrapX11Errors();
|
||||
static void UntrapX11Errors(bool b);
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ void DHCtrl::MapWindow(bool map)
|
|||
return;
|
||||
|
||||
if(map && !isMapped)
|
||||
XMapWindow(Xdisplay, top->window);
|
||||
XMapWindow(Xdisplay, GetWindow());
|
||||
else if(!map && isMapped)
|
||||
XUnmapWindow(Xdisplay, top->window);
|
||||
XUnmapWindow(Xdisplay, GetWindow());
|
||||
|
||||
isMapped = map;
|
||||
|
||||
|
|
@ -197,8 +197,9 @@ bool DHCtrl::Init()
|
|||
)
|
||||
: NULL;
|
||||
|
||||
top = new Top;
|
||||
Top* top = new Top;
|
||||
top->window = hwnd;
|
||||
SetTop(top);
|
||||
|
||||
long im_event_mask = 0;
|
||||
if(cw->xic)
|
||||
|
|
@ -274,28 +275,29 @@ void DHCtrl::Terminate(void)
|
|||
|
||||
// Unmaps the window
|
||||
MapWindow(false);
|
||||
|
||||
Window xwin = GetWindow();
|
||||
if(xwin) {
|
||||
// gathers data from XWindow (needs Input Context...)
|
||||
XWindow *cw = XWindowFromWindow(top->window);
|
||||
|
||||
// Frees input context as needed
|
||||
if(cw->xic)
|
||||
{
|
||||
XDestroyIC(cw->xic);
|
||||
cw->xic = NULL;
|
||||
XWindow *cw = XWindowFromWindow(xwin);
|
||||
|
||||
// Frees input context as needed
|
||||
if(cw && cw->xic)
|
||||
{
|
||||
XDestroyIC(cw->xic);
|
||||
cw->xic = NULL;
|
||||
}
|
||||
|
||||
// Removes XWindow from Upp list
|
||||
RemoveXWindow(xwin);
|
||||
|
||||
// Destroys the window
|
||||
// Not to do, it's done destroying the parent window by X11 system
|
||||
// XDestroyWindow(Xdisplay, top->window);
|
||||
|
||||
// Destroys created Top struct
|
||||
DeleteTop();
|
||||
}
|
||||
|
||||
// Removes XWindow from Upp list
|
||||
RemoveXWindow(top->window);
|
||||
|
||||
// Destroys the window
|
||||
// Not to do, it's done destroying the parent window by X11 system
|
||||
// XDestroyWindow(Xdisplay, top->window);
|
||||
|
||||
// Destroys created Top struct
|
||||
delete top;
|
||||
top = NULL;
|
||||
|
||||
|
||||
// Resets initialization and error flags
|
||||
isInitialized = false;
|
||||
isError = false;
|
||||
|
|
|
|||
|
|
@ -94,15 +94,16 @@ void Ctrl::EventProc(XWindow& w, XEvent *event)
|
|||
// added support for windowed controls
|
||||
// if(top)
|
||||
// XTranslateCoordinates(Xdisplay, top->window, Xroot, 0, 0, &x, &y, &dummy);
|
||||
if(top) {
|
||||
Window DestW = (parent ? GetParentWindow() : Xroot);
|
||||
XTranslateCoordinates(Xdisplay, top->window, DestW, 0, 0, &x, &y, &dummy);
|
||||
Window xwin = GetWindow();
|
||||
if(xwin) {
|
||||
Window DestW = (GetParent() ? GetParentWindow() : Xroot);
|
||||
XTranslateCoordinates(Xdisplay, xwin, DestW, 0, 0, &x, &y, &dummy);
|
||||
Rect rect = RectC(x, y, e.width, e.height);
|
||||
LLOG("CongigureNotify " << rect);
|
||||
if(GetRect() != rect)
|
||||
SetWndRect(rect);
|
||||
// Synchronizes native windows (NOT the main one)
|
||||
}
|
||||
// Synchronizes native windows (NOT the main one)
|
||||
SyncNativeWindows();
|
||||
// 01/12/2007 - END
|
||||
|
||||
|
|
@ -418,16 +419,19 @@ void Ctrl::EventProc(XWindow& w, XEvent *event)
|
|||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
while(XCheckWindowEvent(Xdisplay, top->window, PointerMotionMask, event));
|
||||
EndIgnore();
|
||||
mousePos = Point(event->xmotion.x_root, event->xmotion.y_root);
|
||||
Xeventtime = event->xmotion.time;
|
||||
Point p = mousePos - Xbuttonpos;
|
||||
if(max(abs(p.x), abs(p.y)) > 4)
|
||||
Xbuttontime = Xeventtime - 0x80000000;
|
||||
sModState = event->xmotion.state;
|
||||
DispatchMouse(MOUSEMOVE, Point(event->xmotion.x, event->xmotion.y));
|
||||
DoCursorShape();
|
||||
Window xwin = GetWindow();
|
||||
if(xwin) {
|
||||
while(XCheckWindowEvent(Xdisplay, xwin, PointerMotionMask, event));
|
||||
EndIgnore();
|
||||
mousePos = Point(event->xmotion.x_root, event->xmotion.y_root);
|
||||
Xeventtime = event->xmotion.time;
|
||||
Point p = mousePos - Xbuttonpos;
|
||||
if(max(abs(p.x), abs(p.y)) > 4)
|
||||
Xbuttontime = Xeventtime - 0x80000000;
|
||||
sModState = event->xmotion.state;
|
||||
DispatchMouse(MOUSEMOVE, Point(event->xmotion.x, event->xmotion.y));
|
||||
DoCursorShape();
|
||||
}
|
||||
break;
|
||||
}
|
||||
DropEvent(w, event);
|
||||
|
|
|
|||
|
|
@ -321,10 +321,11 @@ void TopWindow::Open(Ctrl *owner)
|
|||
XSetClassHint(Xdisplay, GetWindow(), class_hint);
|
||||
LLOG("WndShow(" << visible << ")");
|
||||
WndShow(visible);
|
||||
if(visible) {
|
||||
Window xwin = GetWindow();
|
||||
if(xwin && visible) {
|
||||
XEvent e;
|
||||
LLOG("XWindowEvent");
|
||||
XWindowEvent(Xdisplay, top->window, VisibilityChangeMask, &e);
|
||||
XWindowEvent(Xdisplay, xwin, VisibilityChangeMask, &e);
|
||||
ignoretakefocus = true;
|
||||
SetTimeCallback(500, THISBACK(EndIgnoreTakeFocus));
|
||||
LLOG("SetWndFocus");
|
||||
|
|
@ -334,13 +335,13 @@ void TopWindow::Open(Ctrl *owner)
|
|||
// and move the window into position after FocusIn - but not if we want WM to
|
||||
// place the window
|
||||
if(weplace)
|
||||
while(XCheckTypedWindowEvent(Xdisplay, top->window, ConfigureNotify, &e)) {
|
||||
if(e.xconfigure.window != top->window)
|
||||
while(XCheckTypedWindowEvent(Xdisplay, xwin, ConfigureNotify, &e)) {
|
||||
if(e.xconfigure.window != xwin)
|
||||
ProcessEvent(&e);
|
||||
}
|
||||
if(XCheckTypedWindowEvent(Xdisplay, top->window, FocusIn, &e)) {
|
||||
if(XCheckTypedWindowEvent(Xdisplay, xwin, FocusIn, &e)) {
|
||||
ProcessEvent(&e);
|
||||
if(e.xfocus.window == top->window)
|
||||
if(e.xfocus.window == xwin)
|
||||
break;
|
||||
}
|
||||
Sleep(10);
|
||||
|
|
@ -355,7 +356,7 @@ void TopWindow::Open(Ctrl *owner)
|
|||
LLOG(">OPENED " << Name());
|
||||
PlaceFocus();
|
||||
StateH(OPEN);
|
||||
Vector<int> fe = GetPropertyInts(top->window, XAtom("_NET_FRAME_EXTENTS"));
|
||||
Vector<int> fe = GetPropertyInts(xwin, XAtom("_NET_FRAME_EXTENTS"));
|
||||
if(fe.GetCount() >= 4 &&
|
||||
fe[0] >= 0 && fe[0] <= 16 && fe[1] >= 0 && fe[1] <= 16 && //fluxbox returns wrong numbers - quick&dirty workaround
|
||||
fe[2] >= 0 && fe[2] <= 64 && fe[3] >= 0 && fe[3] <= 48)
|
||||
|
|
@ -366,6 +367,7 @@ void TopWindow::Open(Ctrl *owner)
|
|||
windowFrameMargin.top = max(windowFrameMargin.top, fe[2]);
|
||||
windowFrameMargin.bottom = max(windowFrameMargin.bottom, fe[3]);
|
||||
}
|
||||
Top *top = GetTop();
|
||||
if(IsOpen() && top)
|
||||
top->owner = owner;
|
||||
|
||||
|
|
@ -380,14 +382,13 @@ void TopWindow::Open(Ctrl *owner)
|
|||
PropModeReplace, (byte *) &curr_pid, 1);
|
||||
}
|
||||
|
||||
Window win = GetWindow();
|
||||
XChangeProperty(Xdisplay, win, XAtom("_NET_WM_PID"), XA_CARDINAL, 32,
|
||||
XChangeProperty(Xdisplay, xwin, XAtom("_NET_WM_PID"), XA_CARDINAL, 32,
|
||||
PropModeReplace, (byte *) &curr_pid, 1);
|
||||
XChangeProperty(Xdisplay, win, XAtom("WM_CLIENT_LEADER"),
|
||||
XChangeProperty(Xdisplay, xwin, XAtom("WM_CLIENT_LEADER"),
|
||||
XA_WINDOW, 32, PropModeReplace, (byte *)&wm_client_leader, 1);
|
||||
|
||||
int version = 5;
|
||||
XChangeProperty(Xdisplay, win, XAtom("XdndAware"), XA_ATOM, 32,
|
||||
XChangeProperty(Xdisplay, xwin, XAtom("XdndAware"), XA_ATOM, 32,
|
||||
0, (byte *)&version, 1);
|
||||
|
||||
SyncState();
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@ ArrayMap<Window, Ctrl::XWindow>& Ctrl::Xwindow()
|
|||
return Single< ArrayMap<Window, XWindow> >();
|
||||
}
|
||||
|
||||
int Ctrl::WndCaretTime;
|
||||
bool Ctrl::WndCaretVisible;
|
||||
int Ctrl::Xbuttons;
|
||||
Window Ctrl::grabWindow, Ctrl::focusWindow;
|
||||
int Ctrl::Xeventtime;
|
||||
|
|
@ -55,14 +53,15 @@ static int s_starttime;
|
|||
void Ctrl::DoPaint(const Vector<Rect>& invalid)
|
||||
{
|
||||
GuiLock __;
|
||||
if(IsVisible()) {
|
||||
Window xwin = GetWindow();
|
||||
if(utop && IsVisible()) {
|
||||
LTIMING("DoPaint");
|
||||
fullrefresh = false;
|
||||
// if(GLX) return;
|
||||
GC gc = XCreateGC(Xdisplay, (Drawable)top->window, 0, 0);
|
||||
XftDraw *xftdraw = XftDrawCreate(Xdisplay, (Drawable) top->window,
|
||||
GC gc = XCreateGC(Xdisplay, (Drawable)xwin, 0, 0);
|
||||
XftDraw *xftdraw = XftDrawCreate(Xdisplay, (Drawable)xwin,
|
||||
DefaultVisual(Xdisplay, Xscreenno), Xcolormap);
|
||||
SystemDraw draw(top->window, gc, xftdraw, invalid);
|
||||
SystemDraw draw(xwin, gc, xftdraw, invalid);
|
||||
painting = true;
|
||||
UpdateArea(draw, draw.GetClip());
|
||||
painting = false;
|
||||
|
|
@ -109,8 +108,9 @@ Ctrl *Ctrl::CtrlFromWindow(Window w)
|
|||
Ctrl::XWindow *Ctrl::GetXWindow()
|
||||
{
|
||||
GuiLock __;
|
||||
if(!top) return NULL;
|
||||
int q = Xwindow().Find(top->window);
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin) return NULL;
|
||||
int q = Xwindow().Find(xwin);
|
||||
return q >= 0 ? &Xwindow()[q] : NULL;
|
||||
}
|
||||
// 01/12/2007 - mdelfede
|
||||
|
|
@ -121,8 +121,10 @@ Window Ctrl::GetParentWindow(void) const
|
|||
{
|
||||
GuiLock __;
|
||||
Ctrl const *q = GetParentWindowCtrl();
|
||||
if(q)
|
||||
return q->top->window;
|
||||
if(q && utop)
|
||||
{
|
||||
return q->utop->window;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
|
|
@ -132,9 +134,9 @@ Window Ctrl::GetParentWindow(void) const
|
|||
Ctrl *Ctrl::GetParentWindowCtrl(void) const
|
||||
{
|
||||
GuiLock __;
|
||||
Ctrl *q = parent;
|
||||
while(q && !q->top)
|
||||
q = q->parent;
|
||||
Ctrl *q = uparent;
|
||||
while(q && !q->utop)
|
||||
q = q->uparent;
|
||||
return q;
|
||||
|
||||
} // END Ctrl::GetParentWindowCtrl()
|
||||
|
|
@ -144,9 +146,9 @@ Rect Ctrl::GetRectInParentWindow(void) const
|
|||
{
|
||||
GuiLock __;
|
||||
Rect r = GetScreenRect();
|
||||
Ctrl *q = parent;
|
||||
while(q && !q->top)
|
||||
q = q->parent;
|
||||
Ctrl *q = uparent;
|
||||
while(q && !q->utop)
|
||||
q = q->uparent;
|
||||
if(q)
|
||||
{
|
||||
Rect pr = q->GetScreenRect();
|
||||
|
|
@ -457,11 +459,12 @@ void Ctrl::EventLoop(Ctrl *ctrl)
|
|||
void Ctrl::SyncExpose()
|
||||
{
|
||||
GuiLock __;
|
||||
if(!top) return;
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin) return;
|
||||
XEvent event;
|
||||
while(top && XCheckTypedWindowEvent(Xdisplay, top->window, Expose, &event))
|
||||
while(top && XCheckTypedWindowEvent(Xdisplay, xwin, Expose, &event))
|
||||
ProcessEvent(&event);
|
||||
while(top && XCheckTypedWindowEvent(Xdisplay, top->window, GraphicsExpose, &event))
|
||||
while(top && XCheckTypedWindowEvent(Xdisplay, xwin, GraphicsExpose, &event))
|
||||
ProcessEvent(&event);
|
||||
}
|
||||
|
||||
|
|
@ -503,8 +506,9 @@ void Ctrl::Create(Ctrl *owner, bool redirect, bool savebits)
|
|||
XNClientWindow, w,
|
||||
NULL);
|
||||
}
|
||||
top = new Top;
|
||||
Top *top = new Top;
|
||||
top->window = w;
|
||||
SetTop(top);
|
||||
long im_event_mask = 0;
|
||||
if(cw.xic)
|
||||
XGetICValues(cw.xic, XNFilterEvents, &im_event_mask, NULL);
|
||||
|
|
@ -534,7 +538,8 @@ void Ctrl::WndDestroy()
|
|||
{
|
||||
GuiLock __;
|
||||
LLOG("WndDestroy " << Name());
|
||||
if(!top || !isopen) return;
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin || !isopen) return;
|
||||
AddGlobalRepaint();
|
||||
bool revertfocus = HasWndFocus() || !GetFocusCtrl();
|
||||
for(int i = 0; i < Xwindow().GetCount(); i++) {
|
||||
|
|
@ -545,7 +550,7 @@ void Ctrl::WndDestroy()
|
|||
LOGEND();
|
||||
}
|
||||
Ptr<Ctrl> owner;
|
||||
int i = Xwindow().Find(top->window);
|
||||
int i = Xwindow().Find(xwin);
|
||||
if(i >= 0) {
|
||||
XWindow& w = Xwindow()[i];
|
||||
owner = w.owner;
|
||||
|
|
@ -554,14 +559,14 @@ void Ctrl::WndDestroy()
|
|||
XDestroyIC(w.xic);
|
||||
}
|
||||
isopen = false;
|
||||
if(focusWindow == top->window)
|
||||
if(focusWindow == xwin)
|
||||
focusWindow = None;
|
||||
if(grabWindow == top->window)
|
||||
if(grabWindow == xwin)
|
||||
grabWindow = None;
|
||||
XDestroyWindow(Xdisplay, top->window);
|
||||
XDestroyWindow(Xdisplay, xwin);
|
||||
if(i >= 0) {
|
||||
Xwindow().SetKey(i, None);
|
||||
top->window = None;
|
||||
xwin = None;
|
||||
Xwindow()[i].ctrl = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -579,8 +584,7 @@ void Ctrl::WndDestroy()
|
|||
}
|
||||
}
|
||||
|
||||
delete top;
|
||||
top = NULL;
|
||||
DeleteTop();
|
||||
FocusSync();
|
||||
}
|
||||
|
||||
|
|
@ -590,7 +594,7 @@ Vector<Ctrl *> Ctrl::GetTopCtrls()
|
|||
Vector<Ctrl *> v;
|
||||
const ArrayMap<Window, Ctrl::XWindow>& w = Xwindow();
|
||||
for(int i = 0; i < w.GetCount(); i++)
|
||||
if(w.GetKey(i) && w[i].ctrl && !w[i].ctrl->parent)
|
||||
if(w.GetKey(i) && w[i].ctrl && !w[i].ctrl->uparent) //aris002 might be owner here?
|
||||
v.Add(w[i].ctrl);
|
||||
return v;
|
||||
}
|
||||
|
|
@ -599,9 +603,10 @@ void Ctrl::StartPopupGrab()
|
|||
{
|
||||
GuiLock __;
|
||||
if(PopupGrab == 0) {
|
||||
if(!top) return;
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin) return;
|
||||
if(XGrabPointer(
|
||||
Xdisplay, top->window, true,
|
||||
Xdisplay, xwin, true,
|
||||
ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask,
|
||||
GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess) {
|
||||
PopupGrab++;
|
||||
|
|
@ -641,7 +646,7 @@ void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool, bool)
|
|||
WndShow(visible);
|
||||
if(activate && IsEnabled())
|
||||
SetFocus();
|
||||
if(top) top->owner = owner;
|
||||
if(utop) utop->owner = owner;
|
||||
StateH(OPEN);
|
||||
}
|
||||
|
||||
|
|
@ -660,7 +665,7 @@ void Ctrl::SetAlpha(byte alpha)
|
|||
{
|
||||
GuiLock __;
|
||||
Window hwnd = GetWindow();
|
||||
if (!IsAlphaSupported() || parent || !top || !hwnd)
|
||||
if (!IsAlphaSupported() || GetParent() || !GetTop() || !hwnd)
|
||||
return;
|
||||
unsigned int opacity = (unsigned int) 16843009 * alpha;
|
||||
Atom aw_opacity = XInternAtom(Xdisplay, "_NET_WM_WINDOW_OPACITY", XFalse);
|
||||
|
|
@ -687,15 +692,16 @@ void Ctrl::WndShow(bool b)
|
|||
{
|
||||
GuiLock __;
|
||||
LLOG("WndShow " << b);
|
||||
if(top) {
|
||||
Window xwin = GetWindow();
|
||||
if(xwin) {
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(Xdisplay, top->window, &xwa);
|
||||
XGetWindowAttributes(Xdisplay, xwin, &xwa);
|
||||
bool v = xwa.map_state == IsViewable;
|
||||
if(b == v) return;
|
||||
if(b)
|
||||
XMapWindow(Xdisplay, top->window);
|
||||
XMapWindow(Xdisplay, xwin);
|
||||
else
|
||||
XUnmapWindow(Xdisplay, top->window);
|
||||
XUnmapWindow(Xdisplay, xwin);
|
||||
visible = b;
|
||||
StateH(SHOW);
|
||||
}
|
||||
|
|
@ -706,10 +712,11 @@ void Ctrl::WndUpdate()
|
|||
GuiLock __;
|
||||
LTIMING("WndUpdate");
|
||||
LLOG("WNDUPDATE");
|
||||
if(!top) return;
|
||||
if(!top) return; //aris002 when to update there is a question of (is)top concept
|
||||
SyncExpose();
|
||||
if(!top) return;
|
||||
XWindow& xw = Xwindow().Get(top->window);
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin) return;
|
||||
XWindow& xw = Xwindow().Get(xwin);
|
||||
if(xw.exposed && xw.invalid.GetCount()) {
|
||||
SyncScroll();
|
||||
DoPaint(xw.invalid);
|
||||
|
|
@ -726,7 +733,9 @@ void Ctrl::WndUpdate(const Rect& r)
|
|||
LLOG("WNDUPDATE " << r);
|
||||
if(!top) return;
|
||||
SyncExpose();
|
||||
XWindow& xw = Xwindow().Get(top->window);
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin) return;
|
||||
XWindow& xw = Xwindow().Get(xwin);
|
||||
bool dummy;
|
||||
SyncScroll();
|
||||
DoPaint(Intersect(xw.invalid, r, dummy));
|
||||
|
|
@ -738,10 +747,11 @@ void Ctrl::WndUpdate(const Rect& r)
|
|||
void Ctrl::WndSetPos(const Rect& r)
|
||||
{
|
||||
GuiLock __;
|
||||
if(!top) return;
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin) return;
|
||||
LLOG("WndSetPos0 " << Name() << r);
|
||||
AddGlobalRepaint();
|
||||
XMoveResizeWindow(Xdisplay, top->window, r.left, r.top, r.Width(), r.Height());
|
||||
XMoveResizeWindow(Xdisplay, xwin, r.left, r.top, r.Width(), r.Height());
|
||||
rect = r;
|
||||
SetWndRect(r);
|
||||
}
|
||||
|
|
@ -754,10 +764,11 @@ bool Ctrl::IsWndOpen() const
|
|||
bool Ctrl::SetWndCapture()
|
||||
{
|
||||
GuiLock __;
|
||||
if(!IsEnabled() || !top || !IsVisible()) return false;
|
||||
if(top->window == grabWindow) return true;
|
||||
Window xwin = GetWindow();
|
||||
if(!IsEnabled() || !xwin || !IsVisible()) return false;
|
||||
if(xwin == grabWindow) return true;
|
||||
int status = XGrabPointer(
|
||||
Xdisplay, top->window, false,
|
||||
Xdisplay, xwin, false,
|
||||
ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask,
|
||||
GrabModeAsync, GrabModeAsync, None, None, CurrentTime
|
||||
);
|
||||
|
|
@ -766,14 +777,15 @@ bool Ctrl::SetWndCapture()
|
|||
__X11_Grabbing = true;
|
||||
#endif
|
||||
LLOG("Capture set ok");
|
||||
grabWindow = top->window;
|
||||
grabWindow = xwin;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ctrl::HasWndCapture() const
|
||||
{
|
||||
GuiLock __;
|
||||
return top && top->window == grabWindow;
|
||||
Window xwin = GetWindow();
|
||||
return top && xwin == grabWindow;
|
||||
}
|
||||
|
||||
void Ctrl::ReleaseGrab()
|
||||
|
|
@ -794,7 +806,8 @@ bool Ctrl::ReleaseWndCapture()
|
|||
{
|
||||
GuiLock __;
|
||||
LLOG("Releasing capture");
|
||||
if(top && top->window == grabWindow) {
|
||||
Window xwin = GetWindow();
|
||||
if(top && xwin == grabWindow) {
|
||||
LLOG("Ungrab3");
|
||||
ReleaseGrab();
|
||||
return true;
|
||||
|
|
@ -836,9 +849,10 @@ void Ctrl::TakeFocus()
|
|||
XWindow *w = GetXWindow();
|
||||
if(!w)
|
||||
return;
|
||||
Window xwin = GetWindow();
|
||||
if(ignoretakefocus) {
|
||||
LLOG("IGNORED TAKE_FOCUS (caused by CreateWindow)");
|
||||
if(focusWindow != top->window && focusWindow != None)
|
||||
if(focusWindow != xwin && focusWindow != None)
|
||||
XSetInputFocus(Xdisplay, focusWindow, RevertToParent, CurrentTime);
|
||||
return;
|
||||
}
|
||||
|
|
@ -847,7 +861,7 @@ void Ctrl::TakeFocus()
|
|||
return;
|
||||
}
|
||||
LLOG("TAKE_FOCUS " << Name());
|
||||
if(IsEnabled() && IsVisible() && top->window != GetXServerFocusWindow()) {
|
||||
if(IsEnabled() && IsVisible() && xwin != GetXServerFocusWindow()) {
|
||||
ClearKbdState_();
|
||||
SetWndFocus();
|
||||
}
|
||||
|
|
@ -887,14 +901,15 @@ bool Ctrl::SetWndFocus()
|
|||
{
|
||||
GuiLock __;
|
||||
LLOG("SetWndFocus " << Name());
|
||||
if(top && top->window != focusWindow && IsEnabled() && IsVisible()) {
|
||||
Window xwin = GetWindow();
|
||||
if(top && xwin != focusWindow && IsEnabled() && IsVisible()) {
|
||||
LLOG("Setting focus... ");
|
||||
LTIMING("XSetInfputFocus");
|
||||
Ptr<Ctrl> _this = this;
|
||||
KillFocus(focusWindow);
|
||||
if(_this && top) {
|
||||
XSetInputFocus(Xdisplay, top->window, RevertToParent, CurrentTime);
|
||||
focusWindow = top->window;
|
||||
if(_this && xwin) {
|
||||
XSetInputFocus(Xdisplay, xwin, RevertToParent, CurrentTime);
|
||||
focusWindow = xwin;
|
||||
SetFocusWnd();
|
||||
}
|
||||
return true;
|
||||
|
|
@ -905,7 +920,8 @@ bool Ctrl::SetWndFocus()
|
|||
bool Ctrl::HasWndFocus() const
|
||||
{
|
||||
GuiLock __;
|
||||
return top && top->window == focusWindow;
|
||||
Window xwin = GetWindow();
|
||||
return top && xwin == focusWindow;
|
||||
}
|
||||
|
||||
Window Ctrl::GetXServerFocusWindow()
|
||||
|
|
@ -971,16 +987,6 @@ void Ctrl::SyncIMPosition()
|
|||
*/
|
||||
}
|
||||
|
||||
void Ctrl::AnimateCaret()
|
||||
{
|
||||
GuiLock __;
|
||||
int v = !(((msecs() - WndCaretTime) / 500) & 1);
|
||||
if(v != WndCaretVisible) {
|
||||
RefreshCaret();
|
||||
WndCaretVisible = v;
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::Invalidate(XWindow& xw, const Rect& _r)
|
||||
{
|
||||
GuiLock __;
|
||||
|
|
@ -1006,16 +1012,18 @@ void Ctrl::AddGlobalRepaint()
|
|||
void Ctrl::WndInvalidateRect(const Rect& r)
|
||||
{
|
||||
GuiLock __;
|
||||
if(!top) return;
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin) return;
|
||||
LLOG("WndInvalidateRect0 " << r);
|
||||
Invalidate(Xwindow().Get(top->window), r);
|
||||
Invalidate(Xwindow().Get(xwin), r);
|
||||
}
|
||||
|
||||
void Ctrl::SetWndForeground()
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("SetWndForeground " << Name());
|
||||
if(!top || !IsVisible()) return;
|
||||
Window xwin = GetWindow();
|
||||
if(!xwin || !IsVisible()) return;
|
||||
if(!IsEnabled()) {
|
||||
LLOG("Not enabled");
|
||||
XWindow *w = GetXWindow();
|
||||
|
|
@ -1026,8 +1034,8 @@ void Ctrl::SetWndForeground()
|
|||
else {
|
||||
Ptr<Ctrl> _this = this;
|
||||
SetWndFocus();
|
||||
if(_this && top)
|
||||
XRaiseWindow(Xdisplay, top->window);
|
||||
if(_this && xwin)
|
||||
XRaiseWindow(Xdisplay, xwin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1095,7 +1103,7 @@ void Ctrl::SyncNativeWindows(void)
|
|||
{
|
||||
XWindow &xw = xwindows[i];
|
||||
Window w = xwindows.GetKey(i);
|
||||
if(xw.ctrl && xw.ctrl->parent && w)
|
||||
if(xw.ctrl && xw.ctrl->uparent && w)
|
||||
{
|
||||
Window dummy;
|
||||
int x, y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue