void TopWindow::Open(HWND hwnd) { GuiLock __; if(dokeys && (!GUI_AKD_Conservative() || GetAccessKeysDeep() <= 1)) DistributeAccessKeys(); UsrLogT(3, "OPEN " + Desc(this)); LLOG("TopWindow::Open, owner HWND = " << FormatIntHex((int)hwnd, 8) << ", Active = " << FormatIntHex((int)::GetActiveWindow(), 8)); IgnoreMouseUp(); SyncCaption(); #ifdef PLATFORM_WINCE if(!GetRect().IsEmpty()) #endif if(fullscreen) { SetRect(GetScreenSize()); Create(hwnd, WS_POPUP, 0, false, SW_SHOWMAXIMIZED, false); } else { CenterRect(hwnd, hwnd && hwnd == GetTrayHWND__() ? center ? 2 : 0 : center); Create(hwnd, style, exstyle, false, state == OVERLAPPED ? SW_SHOWNORMAL : state == MINIMIZED ? SW_MINIMIZE : SW_MAXIMIZE, false); } PlaceFocus(); SyncCaption(); FixIcons(); }
TopWindow& TopWindow::Icon(const Image& smallicon, const Image& _largeicon) { if(!icon.IsSame(smallicon) || !largeicon.IsSame(_largeicon)) { icon = smallicon; largeicon = _largeicon; SyncCaption(); } SyncCaption(); return *this; }
void TopWindow::FixIcons() { TopWindow *q = GetMainWindow(); if(q) { if(IsNull(icon)) { icon = q->GetIcon(); SyncCaption(); } if(IsNull(largeicon)) { largeicon = q->GetIcon(); SyncCaption(); } } }
TopWindow& TopWindow::FrameLess(bool b) { GuiLock __; frameless = b; SyncCaption(); return *this; }
TopWindow& TopWindow::Urgent(bool b) { GuiLock __; urgent = b; SyncCaption(); return *this; }
TopWindow& TopWindow::MaximizeBox(bool b) { maximizebox = b; SyncCaption(); SyncSizeHints(); return *this; }
TopWindow& TopWindow::Sizeable(bool b) { sizeable = b; SyncCaption(); SyncSizeHints(); return *this; }
TopWindow& TopWindow::LargeIcon(const Image& m) { if(!largeicon.IsSame(m)) { largeicon = m; SyncCaption(); } return *this; }
TopWindow& TopWindow::Icon(const Image& m) { if(!icon.IsSame(m)) { icon = m; SyncCaption(); } return *this; }
TopWindow& TopWindow::Style(dword _style) { GuiLock __; style = _style; if(GetHWND()) ::SetWindowLong(GetHWND(), GWL_STYLE, style); SyncCaption(); return *this; }
void TopWindow::Maximize(bool effect) { LLOG("TopWindow::Maximize " << UPP::Name(this)); state = MAXIMIZED; if(IsOpen()) { ::ShowWindow(GetHWND(), effect ? SW_MAXIMIZE : SW_SHOWMAXIMIZED); SyncCaption(); } }
TopWindow& TopWindow::ExStyle(dword _exstyle) { GuiLock __; exstyle = _exstyle; if(GetHWND()) ::SetWindowLong(GetHWND(), GWL_EXSTYLE, exstyle); SyncCaption(); return *this; }
void TopWindow::Overlap(bool effect) { GuiLock __; LLOG("TopWindow::Overlap " << UPP::Name(this)); state = OVERLAPPED; if(IsOpen()) { ::ShowWindow(GetHWND(), effect ? SW_SHOWNORMAL : SW_RESTORE); SyncCaption(); } }
TopWindow& TopWindow::Style(dword _style) { GuiLock __; LLOG("TopWindow::Style " << UPP::Name(this)); style = _style; if(GetHWND()) ::SetWindowLong(GetHWND(), GWL_STYLE, style); SyncCaption(); return *this; }
void TopWindow::Activate() { LLOG("Activate " << Name() << " activefocus = " << UPP::Name(activefocus)); USRLOG(" ACTIVATE " + Desc(this)); if(activefocus && (HasFocus() || !GetFocusChildDeep()) && IsEnabled()) { LLOG("activefocus->SetWantFocus()"); activefocus->SetWantFocus(); } if(urgent) SyncCaption(); LLOG("Activate End"); }
void TopWindow::SyncState() { GuiLock __; LLOG("SyncState"); SyncCaption(); if(IsOpen() && GetWindow()) { Window w = GetWindow(); WmState(w, topmost, XAtom("_NET_WM_STATE_ABOVE")); WmState(w, state == MAXIMIZED, XAtom("_NET_WM_STATE_MAXIMIZED_HORZ"), XAtom("_NET_WM_STATE_MAXIMIZED_VERT")); if(state == MINIMIZED) XIconifyWindow(Xdisplay, GetWindow(), Xscreenno); else XMapWindow(Xdisplay, GetWindow()); WmState(w, state == MINIMIZED, XAtom("_NET_WM_STATE_HIDDEN")); WmState(w, fullscreen, XAtom("_NET_WM_STATE_FULLSCREEN")); } }
void TopWindow::Open(Ctrl *owner) { GuiLock __; Rect r = GetRect(); if(r.IsEmpty()) SetRect(GetDefaultWindowRect()); else if(r.left == 0 && r.top == 0) if(owner && center == 1) SetRect(owner->GetRect().CenterRect(r.GetSize())); else if(center) SetRect(GetWorkArea().CenterRect(r.GetSize())); frame->SetClient(GetRect()); frame->window = this; frame->PopUp(owner, false, true); PopUp(frame, false, true); popup = false; SetRect(frame->GetClient()); SyncCaption(); if(state == MAXIMIZED) frame->Maximize(); }
void TopWindow::SyncSizeHints() { SyncCaption(); }
TopWindow& TopWindow::ToolWindow(bool b) { tool = b; SyncCaption(); return *this; }
void TopWindow::State(int reason) { SyncCaption(); }
void TopWindow::SyncTitle() { SyncCaption(); }
void TopWindow::Open(Ctrl *owner) { LLOG("TopWindow::Open"); GuiLock __; if(dokeys && (!GUI_AKD_Conservative() || GetAccessKeysDeep() <= 1)) DistributeAccessKeys(); USRLOG(" OPEN " + Desc(this)); LLOG("OPEN " << Name() << " owner: " << UPP::Name(owner)); IgnoreMouseUp(); bool weplace = owner && center == 1 || center == 2 || !GetRect().IsEmpty(); if(fullscreen) SetRect(0, 0, Xwidth, Xheight); else CenterRect(owner); LLOG("Open NextRequest " << NextRequest(Xdisplay)); Create(owner, false, false); XSetWMProperties (Xdisplay, GetWindow(), NULL, NULL, NULL, 0, NULL, NULL, NULL); xminsize.cx = xmaxsize.cx = Null; title2.Clear(); if(!weplace) { LLOG("SyncCaption"); SyncCaption(); } LLOG("SyncSizeHints"); size_hints->flags = 0; SyncSizeHints(); Rect r = GetRect(); size_hints->x = r.left; size_hints->y = r.top; size_hints->width = r.Width(); size_hints->height = r.Height(); size_hints->win_gravity = StaticGravity; size_hints->flags |= PPosition|PSize|PWinGravity; if(owner) { ASSERT(owner->IsOpen()); LLOG("XSetTransientForHint"); XSetTransientForHint(Xdisplay, GetWindow(), owner->GetWindow()); } LLOG("XSetWMNormalHints"); XSetWMNormalHints(Xdisplay, GetWindow(), size_hints); Atom protocols[3]; protocols[0] = XAtom("WM_DELETE_WINDOW"); protocols[1] = XAtom("WM_TAKE_FOCUS"); protocols[2] = XAtom("_NET_WM_PING"); LLOG("XSetWMProtocols"); XSetWMProtocols(Xdisplay, GetWindow(), protocols, 3); String x = GetExeTitle().ToString(); const char *progname = ~x; class_hint->res_name = (char *)progname; class_hint->res_class = (char *)progname; XSetClassHint(Xdisplay, GetWindow(), class_hint); LLOG("WndShow(" << visible << ")"); WndShow(visible); if(visible) { XEvent e; LLOG("XWindowEvent"); XWindowEvent(Xdisplay, top->window, VisibilityChangeMask, &e); ignoretakefocus = true; SetTimeCallback(500, THISBACK(EndIgnoreTakeFocus)); LLOG("SetWndFocus"); SetWndFocus(); for(int i = 0; i < 50; i++) { // X11 tries to move our window, so ignore the first set of ConfigureNotify // 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) ProcessEvent(&e); } if(XCheckTypedWindowEvent(Xdisplay, top->window, FocusIn, &e)) { ProcessEvent(&e); if(e.xfocus.window == top->window) break; } Sleep(10); } } if(weplace) { WndSetPos(GetRect()); LLOG("SyncCaption"); SyncCaption(); } LLOG(">Open NextRequest " << NextRequest(Xdisplay)); LLOG(">OPENED " << Name()); PlaceFocus(); StateH(OPEN); Vector<int> fe = GetPropertyInts(top->window, 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) { GuiLock __; windowFrameMargin.left = max(windowFrameMargin.left, fe[0]); windowFrameMargin.right = max(windowFrameMargin.right, fe[1]); windowFrameMargin.top = max(windowFrameMargin.top, fe[2]); windowFrameMargin.bottom = max(windowFrameMargin.bottom, fe[3]); } if(IsOpen() && top) top->owner = owner; long curr_pid = getpid(); static Window wm_client_leader; ONCELOCK { wm_client_leader = XCreateSimpleWindow(Xdisplay, Xroot, 0, 0, 1, 1, 0, 0, 0); XChangeProperty(Xdisplay, wm_client_leader, XAtom("WM_CLIENT_LEADER"), XA_WINDOW, 32, PropModeReplace, (byte *)&wm_client_leader, 1); XChangeProperty(Xdisplay, wm_client_leader, XAtom("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, (byte *) &curr_pid, 1); } Window win = GetWindow(); XChangeProperty(Xdisplay, win, XAtom("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, (byte *) &curr_pid, 1); XChangeProperty(Xdisplay, win, XAtom("WM_CLIENT_LEADER"), XA_WINDOW, 32, PropModeReplace, (byte *)&wm_client_leader, 1); int version = 5; XChangeProperty(Xdisplay, win, XAtom("XdndAware"), XA_ATOM, 32, 0, (byte *)&version, 1); SyncState(); FixIcons(); }