void MenuBar::CloseMenu() { LLOG("CloseMenu"); MenuBar *q = GetLastSubmenu(); while(q && q->IsPopUp()) { if(q->IsOpen()) { q->doeffect = true; q->Close(); if(q->parentmenu) q->parentmenu->WhenSubMenuClose(); } MenuBar *w = q; q = q->parentmenu; w->submenu = w->parentmenu = NULL; } if(q) q->submenu = NULL; while(q) { q->SyncState(); q->doeffect = true; q = q->parentmenu; } }
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions, const VectorMap<String, ClipData>& data) { GuiLock __; DnDLoop d; d.actions = (byte)actions; d.reject = actions & DND_EXACTIMAGE ? CtrlCoreImg::DndNone() : MakeDragImage(CtrlCoreImg::DndNone(), sample); if(actions & DND_COPY) d.copy = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndCopy(), sample); if(actions & DND_MOVE) d.move = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndMoveX11(), sample); d.SetMaster(*this); d.data = &data; d.action = DND_NONE; d.fmts = Split(fmts, ';'); dndloop = &d; sDnDSource = this; d.Run(); sDnDSource = NULL; SyncCaret(); LLOG("DoDragAndDrop finished"); return d.action; }
bool Pdb::SingleStep() { LLOG("SINGLE STEP 0"); #if CPU_64 if(win64) context.context64.EFlags |= 0x100; else #endif context.context32.EFlags |= 0x100; WriteContext(); running = true; ContinueDebugEvent(event.dwProcessId, event.dwThreadId, DBG_CONTINUE); if(!RunToException()) return false; #if CPU_64 if(win64) context.context64.EFlags &= ~0x100; else #endif context.context32.EFlags &= ~0x100; WriteContext(); return true; }
void Ctrl::SetMouseCursor(const Image& image) { LLOG("SetMouseCursor"); GuiLock __; int64 id = image.GetSerialId(); Ctrl *topctrl = NULL; Top *top = NULL; if(mouseCtrl) topctrl = mouseCtrl->GetTopCtrl(); else topctrl = GetActiveCtrl(); if(topctrl) top = topctrl->top; if(top && id != top->cursor_id) { top->cursor_id = id; int64 aux = image.GetAuxData(); GdkCursor *c = NULL; if(aux) c = gdk_cursor_new((GdkCursorType)(aux - 1)); else if(IsNull(image)) c = gdk_cursor_new(GDK_BLANK_CURSOR); else { Point p = image.GetHotSpot(); ImageGdk m; m.Set(image); GdkPixbuf *pb = m; if(pb) c = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pb, p.x, p.y); } if(c && topctrl->IsOpen()) { gdk_window_set_cursor(topctrl->gdk(), c); gdk_cursor_unref(c); gdk_flush(); // Make it visible immediately } } }
void BlockStream::_Put(const void *data, dword size) { if(IsError() || !IsOpen()) return; LLOG("Put " << size); if(!size) return; const byte *s = (const byte *)data; if(!SyncPos()) return; int64 pos0 = GetPos(); int64 pg0 = pos0 & pagemask; int64 pos1 = pos0 + size; int64 pg1 = pos1 & pagemask; wrlim = buffer + pagesize; pagedirty = true; if(pg0 == pg1) { memcpy(buffer + pos0 - pos, data, size); ptr = buffer + pos1 - pos; } else { int n = int(pos + pagesize - pos0); memcpy(buffer + pos0 - pos, s, n); s += n; n = dword(pg1 - pg0) - pagesize; streamsize = max(pos + pagesize + n, streamsize); int64 wpos = pos + pagesize; SetPos(pos0 + size); SyncPage(); if(n) Write(wpos, s, n); s += n; if(pos1 > pg1) { wrlim = buffer + pagesize; pagedirty = true; memcpy(buffer, s, int(pos1 - pg1)); } } }
bool Ctrl::SetFocus0(bool activate) { GuiLock __; USRLOG(" SETFOCUS " << Desc(this)); LLOG("Ctrl::SetFocus " << Desc(this)); LLOG("focusCtrlWnd " << UPP::Name(focusCtrlWnd)); LLOG("Ctrl::SetFocus0 -> deferredSetFocus = NULL; was: " << UPP::Name(defferedSetFocus)); defferedSetFocus = NULL; if(focusCtrl == this) return true; if(!IsOpen() || !IsEnabled() || !IsVisible()) return false; Ptr<Ctrl> pfocusCtrl = focusCtrl; Ptr<Ctrl> topwindow = GetTopWindow(); Ptr<Ctrl> topctrl = GetTopCtrl(); Ptr<Ctrl> _this = this; if(!topwindow) topwindow = topctrl; LLOG("SetFocus -> SetWndFocus: topwindow = " << UPP::Name(topwindow) << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd)); if(!topwindow->HasWndFocus() && !topwindow->SetWndFocus()) return false;// cxl 31.1.2004 #ifdef PLATFORM_OSX11 // ugly temporary hack - popups not behaving right in MacOS // before 2012-9-2 was #ifdef GUI_X11, but that caused issues in most linux distros (cxl) // as parent window of popup always manages focus/keyboard for popup in X11 if(activate) // Dolik/fudadmin 2011-5-1 topctrl->SetWndForeground(); #else topwindow->SetWndForeground(); // cxl 2007-4-27 #endif LLOG("SetFocus -> focusCtrl = this: " << FormatIntHex(this) << ", _this = " << FormatIntHex(~_this) << ", " << UPP::Name(_this)); focusCtrl = _this; focusCtrlWnd = topwindow; DoKillFocus(pfocusCtrl, _this); LLOG("SetFocus 2"); DoDeactivate(pfocusCtrl, _this); DoSetFocus(pfocusCtrl, _this, activate); if(topwindow) lastActiveWnd = topwindow; return true; }
dsEnqError list_start() { struct ds_search_arg search_arg; struct ds_search_result result; struct DSError error; dsEnqError return_error; return_error = Okay; if (get_default_service (&search_arg.sra_common) != 0) { return localdsaerror; } search_arg.sra_common.ca_servicecontrol.svc_options = SVC_OPT_PREFERCHAIN; search_arg.sra_baseobject = (*base_path != 'T'? str2dn (base_path): NULLDN); search_arg.sra_eis.eis_allattributes = FALSE; search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTETYPESONLY; search_arg.sra_eis.eis_select = 0; search_arg.sra_searchaliases = TRUE; search_arg.sra_subset = SRA_ONELEVEL; search_arg.sra_filter = filter_alloc(); search_arg.sra_filter->flt_type = FILTER_NOT; search_arg.sra_filter->flt_next = NULLFILTER; search_arg.sra_filter->flt_un.flt_un_filter = filter_alloc(); search_arg.sra_filter->flt_un.flt_un_filter->flt_type = FILTER_ITEM; search_arg.sra_filter->flt_un.flt_un_filter->flt_next = NULLFILTER; search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_type = FILTERITEM_EQUALITY; search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un. fi_un_ava.ava_type = AttrT_new("2.5.4.0"); search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un. fi_un_ava.ava_value = str2AttrV("dsa", search_arg.sra_filter->flt_un.flt_un_filter-> flt_un.flt_un_item.fi_un.fi_un_ava.ava_type-> oa_syntax); #ifndef NO_STATS LLOG (log_stat,LLOG_NOTICE,("search +%s,extent %d, val objectClass != dsa", base_path,search_arg.sra_subset)); #endif if (search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item. fi_un.fi_un_ava.ava_value == NULLAttrV) { return_error = localdsaerror; } else if (ds_search (&search_arg, &error, &result) != DS_OK) { free_seq(dnseq); dnseq = NULLDS; dn_number = 0; log_ds_error(&error); ds_error_free(&error); switch (error.dse_type) { case DSE_LOCALERROR: return_error = duaerror; break; case DSE_REMOTEERROR: return_error = localdsaerror; break; case DSE_ATTRIBUTEERROR: return_error = attributerror; break; case DSE_REFERRAL: case DSE_DSAREFERRAL: return_error = remotedsaerror; break; case DSE_SECURITYERROR: return_error = security; break; case DSE_NAMEERROR: return_error = namerror; break; case DSE_SERVICEERROR: return_error = serviceerror; break; default: return_error = localdsaerror; break; } } else { dn_number = 0; if (result.CSR_entries != NULLENTRYINFO) { register EntryInfo *ptr; free_seq(dnseq); dnseq = NULLDS; dn_number = 0; for (ptr = result.CSR_entries; ptr != NULLENTRYINFO; ptr = ptr->ent_next) { dn_number++; dn2buf ((caddr_t)ptr->ent_dn, goto_path); add_seq (&dnseq, goto_path); } if (dn_number) dnseq = SortList(dnseq); } else if (result.CSR_limitproblem == LSR_NOLIMITPROBLEM) { free_seq(dnseq); dnseq = NULLDS; dn_number = 0; return_error = nothingfound; } if (result.CSR_limitproblem != LSR_NOLIMITPROBLEM) { switch (result.CSR_limitproblem) { case LSR_TIMELIMITEXCEEDED: if (dn_number > 0) return_error = timelimit_w_partial; else { free_seq(dnseq); dnseq = NULLDS; return_error = timelimit; } break; case LSR_SIZELIMITEXCEEDED: return_error = listsizelimit; break; case LSR_ADMINSIZEEXCEEDED: if (dn_number > 0) return_error = adminlimit_w_partial; else { free_seq(dnseq); dnseq = NULLDS; return_error = adminlimit; } break; } } if (result.CSR_entries) entryinfo_free(result.CSR_entries, 0); } entry_number = dn_number; filter_free(search_arg.sra_filter); dn_free(search_arg.sra_baseobject); ds_error_free(&error); return return_error; }
void Ctrl::GtkDragDelete(GtkWidget *widget, GdkDragContext *context, gpointer user_data) { LLOG("GtkDragDelete"); }
void Ctrl::GtkDragLeave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer user_data) { LLOG("GtkDragLeave"); DnDLeave(); }
bool Ctrl::IsDragAvailable(const char *fmt) { LLOG("IsDragAvailable " << fmt << " " << (Ctrl::dnd_targets.Find(fmt) >= 0)); return dnd_targets.Find(fmt) >= 0; }
void StdDisplayClass::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword s) const { LLOG("StdDisplay::Paint: " << q << " ink:" << ink << " paper:" << paper); PaintBackground(w, r, q, ink, paper, s); Paint0(w, r, q, ink, paper, s); }
void Ctrl::RefreshFrame() { LLOG("RefreshFrame " << Name()); RefreshFrame(Rect(GetRect().Size()).Inflated(overpaint)); }
void Ctrl::ScrollView(const Rect& _r, int dx, int dy) { GuiLock __; if(IsFullRefresh() || !IsVisible()) return; Size vsz = GetSize(); dx = sgn(dx) * min(abs(dx), vsz.cx); dy = sgn(dy) * min(abs(dy), vsz.cy); Rect r = _r & vsz; Ctrl *w; for(w = this; w->parent; w = w->parent) if(w->InFrame()) { Refresh(); return; } if(!w || !w->top) return; Rect view = InFrame() ? GetView() : GetClippedView(); Rect sr = (r + view.TopLeft()) & view; sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft(); if(w->AddScroll(sr, dx, dy)) Refresh(); else { LTIMING("ScrollCtrls1"); Top *top = GetTopCtrl()->top; for(Ctrl *q = GetFirstChild(); q; q = q->GetNext()) if(q->InView()) { Rect cr = q->GetRect(); if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs Rect to = cr; GetTopRect(to, false); if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs Rect from = cr.Offseted(-dx, -dy); GetTopRect(from, false); MoveCtrl *m = FindMoveCtrlPtr(top->move, q); if(m && m->from == from && m->to == to) { LLOG("ScrollView Matched " << from << " -> " << to); m->ctrl = NULL; goto done; } } if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs Rect from = to; to = cr.Offseted(dx, dy); GetTopRect(to, false); MoveCtrl& m = top->scroll_move.Add(q); m.from = from; m.to = to; m.ctrl = q; LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to); goto done; } cr &= r; if(!cr.IsEmpty()) { Refresh(cr); Refresh(cr + Point(dx, dy)); } done:; } } } }
void LineEdit::Paint0(Draw& w) { int sell, selh; GetSelection(sell, selh); if(!IsEnabled()) sell = selh = 0; Size sz = GetSize(); Size fsz = GetFontSize(); Point sc = sb; int ll = min(line.GetCount(), sz.cy / fsz.cy + sc.y + 1); int y = 0; cpos = GetPos(sc.y); cline = sc.y; sell -= cpos; selh -= cpos; int pos = cpos; Vector<int> dx, dx2; int fascent = font.Info().GetAscent(); for(int i = sc.y; i < ll; i++) { WString tx = line[i]; int len = tx.GetLength(); if(w.IsPainting(0, y, sz.cx, fsz.cy)) { Highlight ih; ih.ink = color[IsShowEnabled() ? INK_NORMAL : INK_DISABLED]; ih.paper = color[IsReadOnly() || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL]; if(nobg) ih.paper = Null; ih.font = font; ih.chr = 0; Vector<Highlight> hl; hl.SetCount(len + 1, ih); for(int q = 0; q < tx.GetCount(); q++) hl[q].chr = tx[q]; HighlightLine(i, hl, pos); int ln = hl.GetCount() - 1; int l = max(sell, 0); int h = selh > len ? len : selh; if(l < h) for(int i = l; i < h; i++) { hl[i].paper = color[PAPER_SELECTED]; hl[i].ink = color[INK_SELECTED]; } if(sell <= len && selh > len) for(int i = len; i < hl.GetCount(); i++) { hl[i].paper = color[PAPER_SELECTED]; hl[i].ink = color[INK_SELECTED]; } Buffer<wchar> txt(ln); for(int i = 0; i < ln; i++) txt[i] = hl[i].chr; for(int pass = 0; pass < 2; pass++) { int gp = 0; int scx = fsz.cx * sc.x; if(ln >= 0) { int q = 0; while(q < ln) { Highlight& h = hl[q]; if(txt[q] == '\t') { int ngp = (gp + tabsize) / tabsize * tabsize; int l = ngp - gp; LLOG("Highlight -> tab[" << q << "] paper = " << h.paper); if(pass == 0) { w.DrawRect(gp * fsz.cx - scx, y, fsz.cx * l, fsz.cy, h.paper); if(showtabs && h.paper != SColorHighlight && q < tx.GetLength()) { Color c = Blend(SColorLight, SColorHighlight); w.DrawRect(gp * fsz.cx - scx + 2, y + fsz.cy / 2, l * fsz.cx - 4, 1, c); w.DrawRect(ngp * fsz.cx - scx - 3, y + 3, 1, fsz.cy - 6, c); } if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + l) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } q++; gp = ngp; } else if(txt[q] == ' ') { LLOG("Highlight -> space[" << q << "] paper = " << h.paper); if(pass == 0) { w.DrawRect(gp * fsz.cx - scx, y, fsz.cx, fsz.cy, h.paper); if(showspaces && h.paper != SColorHighlight && q < tx.GetLength()) { Color c = Blend(SColorLight, SColorHighlight); w.DrawRect(gp * fsz.cx - scx + fsz.cx / 2, y + fsz.cy / 2, 2, 2, c); } if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + 1) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } q++; gp++; } else { bool cjk = IsCJKIdeograph(txt[q]); int p = q + 1; while(p < len && h == hl[p] && txt[p] != '\t' && txt[p] != ' ' && IsCJKIdeograph(txt[p]) == cjk && p - q < 128) p++; int l = p - q; int ll = cjk ? 2 * l : l; LLOG("Highlight -> paper[" << q << "] = " << h.paper); int x = gp * fsz.cx - scx; int xx = x + (gp + ll) * fsz.cx; if(max(x, 0) < min(xx, sz.cx)) if(pass == 0) { w.DrawRect(x, y, fsz.cx * ll, fsz.cy, h.paper); if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + ll) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } else { if(cjk) dx2.At(l, 2 * fsz.cx); else dx.At(l, fsz.cx); w.DrawText(x, y + fascent - h.font.Info().GetAscent(), ~txt + q, h.font, h.ink, l, cjk ? dx2 : dx); } q = p; gp += ll; if(x > sz.cx) break; } } } if(pass == 0) { int gpx = gp * fsz.cx - scx; w.DrawRect(gpx, y, sz.cx - gpx, fsz.cy, hl.Top().paper); if(bordercolumn > 0 && bordercolumn >= gp) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } } } y += fsz.cy; sell -= len + 1; selh -= len + 1; pos += len + 1; } w.DrawRect(0, y, sz.cx, sz.cy - y, color[IsReadOnly() || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL]); DrawTiles(w, DropCaret(), CtrlImg::checkers()); }
void Ctrl::AddUpdate(const Rect& rect) { LLOG("@AddUpdate " << rect); AddRefreshRect(update, rect); }
void DnDLoop::MouseMove(Point p, dword) { GuiLock __; LLOG("DnDLoop::MouseMove"); Sync(); }
static int tsmf_ffmpeg_decode_audio(ITSMFDecoder * decoder, const uint8 * data, uint32 data_size, uint32 extensions) { TSMFFFmpegDecoder * mdecoder = (TSMFFFmpegDecoder *) decoder; int len; int frame_size; uint32 src_size; const uint8 * src; uint8 * dst; #if 0 LLOGLN(0, ("tsmf_ffmpeg_decode_audio: data_size %d", data_size)); int i; for (i = 0; i < data_size; i++) { LLOG(0, ("%02X ", data[i])); if (i % 16 == 15) LLOG(0, ("\n")); } LLOG(0, ("\n")); #endif if (mdecoder->decoded_size_max == 0) mdecoder->decoded_size_max = AVCODEC_MAX_AUDIO_FRAME_SIZE; mdecoder->decoded_data = malloc(mdecoder->decoded_size_max); dst = mdecoder->decoded_data; src = data; src_size = data_size; while (src_size > 0) { /* Ensure enough space for decoding */ if (mdecoder->decoded_size_max - mdecoder->decoded_size < AVCODEC_MAX_AUDIO_FRAME_SIZE) { mdecoder->decoded_size_max *= 2; mdecoder->decoded_data = realloc(mdecoder->decoded_data, mdecoder->decoded_size_max); dst = mdecoder->decoded_data + mdecoder->decoded_size; } frame_size = mdecoder->decoded_size_max - mdecoder->decoded_size; #if LIBAVCODEC_VERSION_MAJOR < 52 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR <= 20) len = avcodec_decode_audio2(mdecoder->codec_context, (int16_t *) dst, &frame_size, src, src_size); #else { AVPacket pkt; av_init_packet(&pkt); pkt.data = (uint8 *) src; pkt.size = src_size; len = avcodec_decode_audio3(mdecoder->codec_context, (int16_t *) dst, &frame_size, &pkt); } #endif if (len <= 0 || frame_size <= 0) { LLOGLN(0, ("tsmf_ffmpeg_decode_audio: erro decoding")); break; } src += len; src_size -= len; mdecoder->decoded_size += frame_size; dst += frame_size; } if (mdecoder->decoded_size == 0) { free(mdecoder->decoded_data); mdecoder->decoded_data = NULL; } LLOGLN(10, ("tsmf_ffmpeg_decode_audio: data_size %d decoded_size %d", data_size, mdecoder->decoded_size)); return 0; }
void Ctrl::AddInvalid(const Rect& rect) { LLOG("@AddInvalid " << rect); AddRefreshRect(invalid, rect); }
bool Pdb::RunToException() { DR_LOG("RunToException"); LLOG("RUN TO EXCEPTION"); TimeStop ts; bool disasfocus = disas.HasFocus(); bool locked = false; bool frestored = false; invalidpage.Clear(); mempage.Clear(); int opn = 0; for(;;) { if(terminated) { if(locked) Unlock(); return false; } opn++; DR_LOG("WaitForDebugEvent"); if(WaitForDebugEvent(&event, 0)) { DR_LOG("WaitForDebugEvent ended"); debug_threadid = event.dwThreadId; opn = 0; running = false; switch(event.dwDebugEventCode) { case EXCEPTION_DEBUG_EVENT: { DR_LOG("EXCEPTION_DEBUG_EVENT"); LLOG("Exception: " << FormatIntHex(event.u.Exception.ExceptionRecord.ExceptionCode) << " at: " << FormatIntHex(event.u.Exception.ExceptionRecord.ExceptionAddress) << " first: " << event.u.Exception.dwFirstChance); SaveForeground(); const EXCEPTION_RECORD& x = event.u.Exception.ExceptionRecord; if(findarg(x.ExceptionCode, EXCEPTION_BREAKPOINT, EXCEPTION_SINGLE_STEP, STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP) < 0) { LLOG("Non-debug EXCEPTION"); if(event.u.Exception.dwFirstChance) { LLOG("First chance " << FormatIntHex(x.ExceptionCode)); break; } String desc = Format("Exception: [* %lX] at [* %16llX]&", (int64)x.ExceptionCode, (int64)x.ExceptionAddress); for(int i = 0; i < __countof(ex_desc); i++) if(ex_desc[i].code == x.ExceptionCode) desc << "[* " << DeQtf(ex_desc[i].text) << "]&"; if(x.ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { desc << (x.ExceptionInformation[0] ? "[*@3 writing]" : "[*@4 reading]"); desc << Format(" at [* %08llX]", (int64)x.ExceptionInformation[1]); } ToForeground(); PromptOK(desc); } #ifdef CPU_64 if(!win64 && x.ExceptionCode == EXCEPTION_BREAKPOINT && !break_running) // Ignore x64 breakpoint in wow64 break; #endif if(break_running) debug_threadid = mainThreadId; break_running = false; ToForeground(); if(disasfocus) disas.SetFocus(); if(locked) Unlock(); if(refreshmodules) LoadModuleInfo(); LLOG("event.dwThreadId = " << event.dwThreadId); bool isbreakpoint = findarg(x.ExceptionCode, EXCEPTION_BREAKPOINT, STATUS_WX86_BREAKPOINT) >= 0; for(int i = 0; i < threads.GetCount(); i++) { Thread& t = threads[i]; (Context&)t = ReadContext(threads[i].hThread); if(event.dwThreadId == threads.GetKey(i)) { LLOG("Setting current context"); if(isbreakpoint #ifdef CPU_64 && bp_set.Find((win64 ? t.context64.Rip : t.context32.Eip) - 1) >= 0 #else && bp_set.Find(t.context32.Eip - 1) >= 0 #endif ) // We have stopped at breakpoint, need to move address back #ifdef CPU_64 if(win64) t.context64.Rip--; else #endif t.context32.Eip--; context = t; } } RemoveBp(); return true; } case CREATE_THREAD_DEBUG_EVENT: DR_LOG("CREATE_THREAD_DEBUG_EVENT"); LLOG("Create thread: " << event.dwThreadId); AddThread(event.dwThreadId, event.u.CreateThread.hThread); break; case EXIT_THREAD_DEBUG_EVENT: DR_LOG("EXIT_THREAD_DEBUG_EVENT"); LLOG("Exit thread: " << event.dwThreadId); RemoveThread(event.dwThreadId); break; case CREATE_PROCESS_DEBUG_EVENT: DR_LOG("CREATE_PROCESS_DEBUG_EVENT"); LLOG("Create process: " << event.dwProcessId); processid = event.dwProcessId; AddThread(event.dwThreadId, event.u.CreateProcessInfo.hThread); CloseHandle(event.u.CreateProcessInfo.hFile); CloseHandle(event.u.CreateProcessInfo.hProcess); break; case EXIT_PROCESS_DEBUG_EVENT: DR_LOG("EXIT_PROCESS_DEBUG_EVENT"); LLOG("Exit process: " << event.dwProcessId); if(locked) Unlock(); terminated = true; return false; case LOAD_DLL_DEBUG_EVENT: { DR_LOG("LOAD_DLL_DEBUG_EVENT"); LLOG("Load dll: " << event.u.LoadDll.lpBaseOfDll); CloseHandle(event.u.LoadDll.hFile); refreshmodules = true; break; } case UNLOAD_DLL_DEBUG_EVENT: DR_LOG("UNLOAD_DLL_DEBUG_EVENT"); LLOG("UnLoad dll: " << event.u.UnloadDll.lpBaseOfDll); refreshmodules = true; break; case RIP_EVENT: DR_LOG("RIP_EVENT"); LLOG("RIP!"); Exclamation("Process being debugged died unexpectedly!"); terminated = true; if(locked) Unlock(); return false; } DR_LOG("ContinueDebugEvent"); ContinueDebugEvent(event.dwProcessId, event.dwThreadId, DBG_EXCEPTION_NOT_HANDLED); running = true; } if(ts.Elapsed() > 200) { DR_LOG("ts.Elpsed() > 200"); if(!lock) { Lock(); locked = true; } if(!frestored) { RestoreForeground(); frestored = true; } } if(lock) { DR_LOG("GuiSleep"); GuiSleep(opn < 1000 ? 0 : 100); Ctrl::ProcessEvents(); } else { DR_LOG("Sleep"); Sleep(opn < 1000 ? 0 : 100); } } }
void FBInit(const String& fbdevice) { Ctrl::InitFB(); fbfd = open(fbdevice, O_RDWR); if (!fbfd) { fprintf(stderr, "Error: cannot open framebuffer device.\n"); exit(-1); } LLOG("The framebuffer device was opened successfully.\n"); if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { fprintf(stderr, "Error reading fixed information.\n"); exit(-2); } if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { fprintf(stderr, "Error reading variable information.\n"); exit(-3); } RLOG("Framebuffer opened: " << fbdevice << ": " << vinfo.xres << "x" << vinfo.yres << " @ " << vinfo.bits_per_pixel); screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; //bytes fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if((intptr_t)fbp == -1) { fprintf(stderr, "Error: failed to map framebuffer device to memory.\n"); exit(-4); } LLOG("The framebuffer device was mapped to memory successfully.\n"); Size fbsz(vinfo.xres, vinfo.yres); Ctrl::SetFramebufferSize(fbsz); //mouse //mousep = fbsz / 2; mousep.Clear(); static const char *mice[] = { "/dev/input/mice" , "/dev/usbmouse" , "/dev/psaux" , NULL }; for(int i=0; (mouse_fd < 0) && mice[i]; ++i) { mouse_fd = open(mice[i], O_RDWR, 0); if(mouse_fd < 0) mouse_fd = open(mice[i], O_RDONLY, 0); if(mouse_fd >= 0) { set_imps2(mouse_fd, 1); if(mouse_imps2 = has_imps2(mouse_fd)) { LLOG("IMPS2 mouse enabled: " << mice[i]); } else RLOG("no IMPS2 mouse present"); } else fprintf(stderr, "Error: failed to open %s.\n", mice[i]); } //keyb static const char* const tty0[] = { "/dev/tty0" , "/dev/vc/0" , NULL }; static const char* const vcs[] = { "/dev/vc/" , "/dev/tty" , NULL }; int tfd = -1; for(int i=0; tty0[i] && (tfd < 0); ++i) tfd = open(tty0[i], O_WRONLY, 0); if(tfd < 0) tfd = dup(0); ASSERT(tfd>=0); ioctl(tfd, VT_OPENQRY, &cvt); close(tfd); LLOG("probable new VT: " << cvt); if(geteuid() != 0) { fprintf(stderr, "Error: not running as ROOT, mouse handling pobably unavailable\n"); } else if(cvt > 0) { LLOG("try to open the NEW assigned VT: " << cvt); for(int i=0; vcs[i] && (keyb_fd < 0); ++i) { char path[32]; snprintf(path, 32, "%s%d", vcs[i], cvt); keyb_fd = open(path, O_RDWR, 0); if(keyb_fd < 0) continue; LLOG("TTY path opened: " << path); tfd = open("/dev/tty", O_RDWR, 0); if(tfd >= 0) { LLOG("detaching from local stdin/out/err"); ioctl(tfd, TIOCNOTTY, 0); close(tfd); } else fprintf(stderr, "Error: detaching from local stdin/out/err\n"); } } if(keyb_fd < 0) { LLOG("Using already assigned VT, must not detach"); struct vt_stat vtst; keyb_fd = open("/dev/tty", O_RDWR); if(ioctl(keyb_fd, VT_GETSTATE, &vtst) < 0) { cvt = 0; } else { cvt = vtst.v_active; } } if(cvt>0) fprintf(stdout, "started on VT %d\n", cvt); ASSERT(keyb_fd>=0); oldmode = -1; { int d; if(ioctl(keyb_fd, KDGKBMODE, &d) < 0) { close(keyb_fd); keyb_fd = -1; fprintf(stderr, "Error: opening a console terminal"); exit(5); } } LLOG("tty opened: " << keyb_fd); dupkmap(keyb_fd); entervt(); pend = 4; //fake video expose event to cause first paint }
int tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE * mediatype, const uint8 * pMediaType) { uint32 cbFormat; const uint8 * pFormat; int i; int ret = 0; memset(mediatype, 0, sizeof(TS_AM_MEDIA_TYPE)); LLOG(0, ("MajorType: ")); tsmf_print_guid(pMediaType); for (i = 0; tsmf_major_type_map[i].type != TSMF_MAJOR_TYPE_UNKNOWN; i++) { if (memcmp(tsmf_major_type_map[i].guid, pMediaType, 16) == 0) break; } mediatype->MajorType = tsmf_major_type_map[i].type; if (mediatype->MajorType == TSMF_MAJOR_TYPE_UNKNOWN) ret = 1; LLOGLN(0, (" (%s)", tsmf_major_type_map[i].name)); LLOG(0, ("SubType: ")); tsmf_print_guid(pMediaType + 16); for (i = 0; tsmf_sub_type_map[i].type != TSMF_SUB_TYPE_UNKNOWN; i++) { if (memcmp(tsmf_sub_type_map[i].guid, pMediaType + 16, 16) == 0) break; } mediatype->SubType = tsmf_sub_type_map[i].type; if (mediatype->SubType == TSMF_SUB_TYPE_UNKNOWN) ret = 1; LLOGLN(0, (" (%s)", tsmf_sub_type_map[i].name)); LLOG(0, ("FormatType: ")); tsmf_print_guid(pMediaType + 44); for (i = 0; tsmf_format_type_map[i].type != TSMF_FORMAT_TYPE_UNKNOWN; i++) { if (memcmp(tsmf_format_type_map[i].guid, pMediaType + 44, 16) == 0) break; } mediatype->FormatType = tsmf_format_type_map[i].type; if (mediatype->FormatType == TSMF_FORMAT_TYPE_UNKNOWN) ret = 1; LLOGLN(0, (" (%s)", tsmf_format_type_map[i].name)); cbFormat = GET_UINT32(pMediaType, 60); LLOGLN(0, ("tsmf_stream_set_format: cbFormat %d", cbFormat)); pFormat = pMediaType + 64; for (i = 0; i < cbFormat; i++) { LLOG(0, ("%02X ", pFormat[i])); if (i % 16 == 15) LLOG(0, ("\n")); } LLOG(0, ("\n")); switch (mediatype->FormatType) { case TSMF_FORMAT_TYPE_MFVIDEOFORMAT: /* http://msdn.microsoft.com/en-us/library/aa473808.aspx */ /* MFVIDEOFORMAT.videoInfo.dwWidth */ mediatype->Width = GET_UINT32(pFormat, 8); /* MFVIDEOFORMAT.videoInfo.dwHeight */ mediatype->Height = GET_UINT32(pFormat, 12); /* MFVIDEOFORMAT.compressedInfo.AvgBitrate */ mediatype->BitRate = GET_UINT32(pFormat, 136); /* MFVIDEOFORMAT.videoInfo.FramesPerSecond */ mediatype->SamplesPerSecond.Numerator = GET_UINT32(pFormat, 48); mediatype->SamplesPerSecond.Denominator = GET_UINT32(pFormat, 52); if (cbFormat > 176) { mediatype->ExtraDataSize = cbFormat - 176; mediatype->ExtraData = pFormat + 176; } break; case TSMF_FORMAT_TYPE_WAVEFORMATEX: /* http://msdn.microsoft.com/en-us/library/dd757720.aspx */ mediatype->Channels = GET_UINT16(pFormat, 2); mediatype->SamplesPerSecond.Numerator = GET_UINT32(pFormat, 4); mediatype->SamplesPerSecond.Denominator = 1; mediatype->BitRate = GET_UINT32(pFormat, 8) * 8; mediatype->BlockAlign = GET_UINT16(pFormat, 12); mediatype->BitsPerSample = GET_UINT16(pFormat, 14); mediatype->ExtraDataSize = GET_UINT16(pFormat, 16); if (mediatype->ExtraDataSize > 0) mediatype->ExtraData = pFormat + 18; break; case TSMF_FORMAT_TYPE_MPEG2VIDEOINFO: /* http://msdn.microsoft.com/en-us/library/dd390707.aspx */ i = tsmf_codec_parse_VIDEOINFOHEADER2(mediatype, pFormat); i += tsmf_codec_parse_BITMAPINFOHEADER(mediatype, pFormat + i); if (cbFormat > i) { mediatype->ExtraDataSize = cbFormat - i; mediatype->ExtraData = pFormat + i; } break; case TSMF_FORMAT_TYPE_VIDEOINFO2: i = tsmf_codec_parse_VIDEOINFOHEADER2(mediatype, pFormat); tsmf_codec_parse_BITMAPINFOHEADER(mediatype, pFormat + i); i += 40; /* Skip only BITMAPINFOHEADER */ if (cbFormat > i) { mediatype->ExtraDataSize = cbFormat - i; mediatype->ExtraData = pFormat + i; } break; default: break; } if (mediatype->SamplesPerSecond.Numerator == 0) mediatype->SamplesPerSecond.Numerator = 1; if (mediatype->SamplesPerSecond.Denominator == 0) mediatype->SamplesPerSecond.Denominator = 1; return ret; }
int dsa_control (Attr_Sequence as, struct DSError *error, DN dn) { char * str; DN dn2; Entry theentry; extern Entry database_root; SFD attempt_restart(); if ( ! manager(dn) ) { error->dse_type = DSE_SECURITYERROR; error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS; return (DS_ERROR_REMOTE); } str = (char *) as->attr_value->avseq_av.av_struct; #ifndef NO_STATS LLOG (log_stat,LLOG_NOTICE,("DSA control: %s",str)); #endif switch (*str) { case 'd': /* -dump <directory> */ str = SkipSpace (++str); /* directory_dump (str, database_root); */ return (DS_OK); case 't': /* -tailor <string> */ str = SkipSpace (++str); if (dsa_tai_string (str) == OK) { isodexport (NULLCP); return (DS_OK); } break; case 'a': /* -abort */ LLOG (log_dsap,LLOG_FATAL,("*** abort signal ***")); dsa_abort(-1); exit(0); case 'b': /* -restart */ LLOG (log_dsap,LLOG_FATAL,("*** restart signal ***")); attempt_restart (NOTOK); exit(0); /* should not be reached */ case 'r': /* -refresh <entry> */ str = SkipSpace (++str); if (lexequ (str,"root") == 0) dn2= NULLDN; else if ((dn2 = str2dn (str)) == NULLDN) break; if (refresh_from_disk (dn2) == OK) return (DS_OK); break; case 'f': /* -resync <entry> */ str = SkipSpace (++str); if (lexequ (str,"root") == 0) dn2= NULLDN; else if ((dn2 = str2dn (str)) == NULLDN) break; if ((theentry = local_find_entry (dn2,FALSE)) != NULLENTRY) #ifdef TURBO_DISK { Entry akid = (Entry) avl_getone(theentry->e_children); if (turbo_writeall (akid) == OK) return (DS_OK); } #else { Entry akid = (Entry) avl_getone(theentry->e_children); if (journal (akid) == OK) return (DS_OK); } #endif break; case 'l': /* -lock <entry> */ str = SkipSpace (++str); if (lexequ (str,"root") == 0) dn2 = NULLDN; else if ((dn2 = str2dn (str)) == NULLDN) break; if ((theentry = local_find_entry (dn2,FALSE)) != NULLENTRY) { theentry->e_lock = TRUE; return (DS_OK); } break; case 'u': /* -unlock <entry> */ str = SkipSpace (++str); if (lexequ (str,"root") == 0) dn2 = NULLDN; else if ((dn2 = str2dn (str)) == NULLDN) break; if ((theentry = local_find_entry (dn2,FALSE)) != NULLENTRY) { theentry->e_lock = FALSE; return (DS_OK); } break; case 's': /* -slave */ /* * When we go async return of OK will mean that a getedb * operation has been scheduled, NOT that it has succeeded. */ str = SkipSpace (++str); if (*str == NULL) { slave_update(); return DS_OK; } if (lexequ (str, "shadow") == 0) { shadow_update(); return DS_OK; } if (lexequ (str, "root") == 0) dn2 = NULLDN; else if ((dn2 = str2dn (str)) == NULLDN) break; if (update_aux (dn2, dn2 == NULLDN) == OK) return DS_OK; break; default: break; } error->dse_type = DSE_SERVICEERROR; error->ERR_SERVICE.DSE_sv_problem = DSE_SV_UNWILLINGTOPERFORM; return (DS_ERROR_REMOTE); }
void Ctrl::Refresh(const Rect& area) { GuiLock __; if(fullrefresh || !IsVisible() || !IsOpen()) return; LLOG("Refresh " << Name() << ' ' << area); RefreshFrame((area + GetView().TopLeft()) & GetView().Inflated(OverPaint())); }
LRESULT CALLBACK Ctrl::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { GuiLock __; if(sFinished) return DefWindowProc(hWnd, message, wParam, lParam); #ifdef PLATFORM_WINCE if(message == WM_CREATE) #else if(message == WM_NCCREATE) #endif { Ctrl *w = (Ctrl *)((LPCREATESTRUCT) lParam)->lpCreateParams; if(w) { w->NcCreate(hWnd); int i = Windows().Find(NULL); if(i >= 0) { Windows().SetKey(i, hWnd); Windows()[i] = w; } else Windows().Add(hWnd) = w; } } Ctrl *w = Windows().Get(hWnd, NULL); #ifdef PLATFORM_WINCE if(message == WM_DESTROY) #else if(message == WM_NCDESTROY) #endif { if(w) w->NcDestroy(); int i = Windows().Find(hWnd); if(i >= 0) Windows().SetKey(i, NULL); } #if LOGMESSAGES bool logblk = false; if(message != WM_SETCURSOR && message != WM_CTLCOLORBTN && message != WM_TIMER && #ifndef PLATFORM_WINCE message != WM_NCHITTEST && message != WM_ENTERIDLE && #endif message != WM_CTLCOLORDLG && message != WM_CTLCOLOREDIT && message != WM_CTLCOLORLISTBOX && message != WM_CTLCOLORMSGBOX && message != WM_CTLCOLORSCROLLBAR && message != WM_CTLCOLORSTATIC && message != WM_CANCELMODE && message != 0x0118) for(WinMsg *m = sWinMsg; m->ID; m++) if(m->ID == message) { RLOG(m->name << ' ' << UPP::Name(w) << Sprintf(", wParam = %d (0x%x), lParam = %d (0x%x)", wParam, wParam, lParam, lParam)); VppLog() << LOG_BEGIN; logblk = true; break; } #endif LRESULT l = 0; if(w) { #if defined(_DEBUG) && LOGTIMING int ticks = msecs(); String wname = w->Name(); #endif Ptr<Ctrl> pw = w; l = w->WindowProc(message, wParam, lParam); if(pw) pw->SyncMoves(); #if defined(_DEBUG) && LOGTIMING String msgname; for(WinMsg *m = sWinMsg; m->ID; m++) if(m->ID == message) { msgname = m->name; break; } if(IsNull(msgname)) msgname = NFormat("0x%04x", (int)message); LLOG(NFormat("T+%d %s 0x%08x 0x%08x -> %s", msecs(ticks), msgname, (int)wParam, (int)lParam, wname)); #endif } else l = DefWindowProc(hWnd, message, wParam, lParam); #if LOGMESSAGES if(logblk) VppLog() << LOG_END; #endif return l; }
int new_dsa_control (Attr_Sequence as, struct DSError *error, DN dn) { struct dsa_control * item ; char * tmp_ptr ; DN dn2; Entry theentry; extern Entry database_root; SFD attempt_restart(); /* Return some silly error to distinguish it from the other dsa_control */ if ( ! manager(dn) ) { error->dse_type = DSE_SECURITYERROR ; error->ERR_SECURITY.DSE_sc_problem = DSE_SC_PROTECTIONREQUIRED ; return (DS_ERROR_REMOTE) ; } item = (struct dsa_control *) as->attr_value->avseq_av.av_struct ; switch (item->dsa_control_option) { case (CONTROL_CHANGETAILOR) : { /* -tailor <string> */ tmp_ptr = qb2str(item->un.changeTailor) ; if (dsa_tai_string (tmp_ptr) == OK) { isodexport (NULLCP); return (DS_OK); } break; } case(CONTROL_STOPDSA): { /* -abort */ LLOG(log_dsap,LLOG_FATAL,("*** abort signal ***")) ; stop_listeners() ; exit(0) ; } case (CONTROL_REFRESH): { /* -refresh <entry> */ if (item->un.refresh->offset == DN_PRESENT) if (refresh_from_disk (item->un.refresh->un.selectedDN) == OK) return (DS_OK); break; } case(CONTROL_RESYNCH): { /* -resync <entry> */ if (item->un.resynch->offset == DN_PRESENT) dn2 = item->un.resynch->un.selectedDN ; else break ; if ((theentry = local_find_entry (dn2, FALSE)) != NULLENTRY) #ifdef TURBO_DISK { Entry akid = (Entry) avl_getone(theentry->e_children); if (turbo_writeall (akid) == OK) return (DS_OK); } #else { Entry akid = (Entry) avl_getone(theentry->e_children); if (journal (akid) == OK) return (DS_OK); } #endif break; } case (CONTROL_LOCKDSA): { /* -lock <entry> */ if (item->un.resynch->offset == DN_PRESENT) dn2 = item->un.resynch->un.selectedDN ; else break ; if ((theentry = local_find_entry (dn2,FALSE)) != NULLENTRY) { theentry->e_lock = TRUE; return (DS_OK); } break; } case (CONTROL_UNLOCK): { /* -unlock <entry> */ if (item->un.resynch->offset == DN_PRESENT) dn2 = item->un.resynch->un.selectedDN ; else break ; if ((theentry = local_find_entry (dn2,FALSE)) != NULLENTRY) { theentry->e_lock = FALSE; return (DS_OK); } break; } case (CONTROL_SETLOGLEVEL): { /* Set the Logging Level */ tmp_ptr = qb2str(item->un.setLogLevel) ; /* What kind of stuff is needed here?!! */ return (DS_OK); break; } case (CONTROL_UPDATESLAVEEDBS): { /* -slave */ /* * When we go async return of OK will mean that a getedb * operation has been scheduled, NOT that it has succeeded. */ tmp_ptr = qb2str(item->un.updateSlaveEDBs) ; if (lexequ (tmp_ptr, "all") == 0) { slave_update(); return DS_OK; } if (lexequ (tmp_ptr, "shadow") == 0) { shadow_update(); return DS_OK; } if (lexequ (tmp_ptr, "root") == 0) { dn2 = NULLDN; } else { if ((dn2 = str2dn (tmp_ptr)) == NULLDN) break; } if (update_aux (dn2, dn2 == NULLDN) == OK) return DS_OK; break; } default: break; } error->dse_type = DSE_SERVICEERROR; error->ERR_SERVICE.DSE_sv_problem = DSE_SV_UNWILLINGTOPERFORM; return (DS_ERROR_REMOTE); }
void InvalidateFileTimeCache(const String& path) { LLOG("InvalidateFileTimeCache " << path); sPathFileTime.UnlinkKey(path); }
void Ctrl::InitWin32(HINSTANCE hInstance) { GuiLock __; LLOG("InitWin32"); InstallPanicMessageBox(&Win32PanicMessageBox); // RLOGBLOCK("Ctrl::InitWin32"); sMainThreadId = GetCurrentThreadId(); #define ILOG(x) // RLOG(x) Ctrl::hInstance = hInstance; ILOG("RegisterClassW"); #ifndef PLATFORM_WINCE if(IsWinNT()) #endif { WNDCLASSW wc; Zero(wc); wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL; wc.lpszClassName = L"UPP-CLASS-W"; RegisterClassW(&wc); wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L"UPP-CLASS-DS-W"; RegisterClassW(&wc); wc.style = CS_SAVEBITS|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L"UPP-CLASS-SB-W"; RegisterClassW(&wc); wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS; wc.lpszClassName = L"UPP-CLASS-SB-DS-W"; RegisterClassW(&wc); } ILOG("RegisterClassA"); WNDCLASS wc; Zero(wc); wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL; wc.lpszClassName = L_("UPP-CLASS-A"); RegisterClass(&wc); if(IsWinXP()) { wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L_("UPP-CLASS-DS-A"); RegisterClass(&wc); } wc.style = CS_SAVEBITS|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L_("UPP-CLASS-SB-A"); RegisterClass(&wc); if(IsWinXP()) { wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS; wc.lpszClassName = L_("UPP-CLASS-SB-DS-A"); RegisterClass(&wc); } wc.style = 0; wc.lpszClassName = L_("UPP-TIMER"); wc.hCursor = NULL; wc.lpfnWndProc = &Ctrl::UtilityProc; RegisterClass(&wc); ILOG("InitTimer"); InitTimer(); ILOG("SetTimer"); utilityHWND = CreateWindow(L_("UPP-TIMER"), L_(""), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); SetTimer(utilityHWND, 1, 10, NULL); ILOG("Windows"); Windows(); //?? TRC: what's the use of this? ReSkin(); OleInitialize(NULL); /* TRC 05/11/14: moved to GuiSleep to avoid thread creation in OCX DllMain DWORD dummy; OverwatchThread = CreateThread(NULL, 0x100000, Win32OverwatchThread, NULL, 0, &dummy); ExitLoopEvent().Wait(); */ // TRC 05/11/18: pSetLayeredWindowAttributes moved to GLOBAL_VAR (see below) to make OCX initialization simpler Csizeinit(); #undef ILOG if(IsWin7()) GlobalBackPaint(); }
void TopWindow::SerializePlacement(Stream& s, bool reminimize) { GuiLock __; #ifndef PLATFORM_WINCE int version = 1; s / version; Rect rect = GetRect(); s % overlapped % rect; bool mn = state == MINIMIZED; bool mx = state == MAXIMIZED; bool fs = fullscreen; // 12-05-23 Tom added fullscreen serialization if(version >= 1) s.Pack(mn, mx, fs); // 12-05-23 Tom changed from: s.Pack(mn, mx); else s.Pack(mn, mx); LLOG("TopWindow::SerializePlacement / " << (s.IsStoring() ? "write" : "read")); LLOG("minimized = " << mn << ", maximized = " << mx << ", fullscreen = " << fs); // 12-05-23 Tom extended with fullscreen LLOG("rect = " << rect << ", overlapped = " << overlapped); if(s.IsLoading()) { rect = overlapped; Rect limit = GetVirtualWorkArea(); Rect outer = rect; ::AdjustWindowRect(outer, WS_OVERLAPPEDWINDOW, FALSE); limit.left += rect.left - outer.left; limit.top += rect.top - outer.top; limit.right += rect.right - outer.right; limit.bottom += rect.bottom - outer.bottom; Size sz = min(rect.Size(), limit.Size()); rect = RectC( minmax(rect.left, limit.left, limit.right - sz.cx), minmax(rect.top, limit.top, limit.bottom - sz.cy), sz.cx, sz.cy); Overlap(); SetRect(rect); if(mn && reminimize){ state = MINIMIZED; //Minimize(); // 12-05-23 Tom removed } if(mx){ state = MAXIMIZED; //Maximize(); // 12-05-23 Tom removed } if(IsOpen()) { switch(state) { case MINIMIZED: Minimize(); break; case MAXIMIZED: Maximize(); break; } /* WINDOWPLACEMENT wp; memset(&wp,0,sizeof(WINDOWPLACEMENT)); wp.length=sizeof(WINDOWPLACEMENT); wp.showCmd = state==MINIMIZED ? SW_MINIMIZE : state==MAXIMIZED ? SW_MAXIMIZE : SW_RESTORE; wp.rcNormalPosition.left=rect.left; wp.rcNormalPosition.top=rect.top; wp.rcNormalPosition.right=rect.right; wp.rcNormalPosition.bottom=rect.bottom; ::SetWindowPlacement(GetHWND(),&wp); */ if(fs) { Overlap(); // Needed to restore normal position before fullscreen mode FullScreen(fs); // 12-05-23 Tom added for fullscreen serialization } } else // 12-05-23 Tom added for fullscreen serialization fullscreen=fs; // 12-05-23 Tom added for fullscreen serialization } #endif }
String XAtomName(Atom atom) { GuiLock __; LLOG("GetAtomName"); return XGetAtomName(Xdisplay, atom); }
void TopWindow::SyncCaption() { GuiLock __; LLOG("TopWindow::SyncCaption " << UPP::Name(this)); if(fullscreen) return; HWND hwnd = GetHWND(); if(hwnd) { style = ::GetWindowLong(hwnd, GWL_STYLE); exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE); } style &= ~(WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU|WS_POPUP|WS_DLGFRAME); exstyle &= ~(WS_EX_TOOLWINDOW|WS_EX_DLGMODALFRAME); style |= WS_CAPTION; if(hasdhctrl) style |= WS_CLIPSIBLINGS|WS_CLIPCHILDREN; if(minimizebox) style |= WS_MINIMIZEBOX; if(maximizebox) style |= WS_MAXIMIZEBOX; if(sizeable) style |= WS_THICKFRAME; #ifndef PLATFORM_WINCE if(frameless) style = (style & ~WS_CAPTION) | WS_POPUP; else if(IsNull(icon) && !maximizebox && !minimizebox || noclosebox) { style |= WS_POPUPWINDOW|WS_DLGFRAME; exstyle |= WS_EX_DLGMODALFRAME; if(noclosebox) style &= ~WS_SYSMENU; } else #endif style |= WS_SYSMENU; if(tool) exstyle |= WS_EX_TOOLWINDOW; if(fullscreen) style = WS_POPUP; if(hwnd) { ::SetWindowLong(hwnd, GWL_STYLE, style); ::SetWindowLong(hwnd, GWL_EXSTYLE, exstyle); SyncTitle(); if(urgent) { if(IsForeground()) urgent = false; FLASHWINFO fi; memset(&fi, 0, sizeof(fi)); fi.cbSize = sizeof(fi); fi.hwnd = hwnd; fi.dwFlags = urgent ? FLASHW_TIMER|FLASHW_ALL : FLASHW_STOP; FlashWindowEx(&fi); } } DeleteIco(); #ifndef PLATFORM_WINCE //TODO!!! if(hwnd) { ::SendMessage(hwnd, WM_SETICON, false, (LPARAM)(ico = SystemDraw::IconWin32(icon))); ::SendMessage(hwnd, WM_SETICON, true, (LPARAM)(lico = SystemDraw::IconWin32(largeicon))); } #endif }