void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) { Q_Q(QWidget); bool wasCreated = q->testAttribute(Qt::WA_WState_Created); if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); #ifndef QT_NO_CURSOR QCursor oldcurs; bool setcurs=q->testAttribute(Qt::WA_SetCursor); if (setcurs) { oldcurs = q->cursor(); q->unsetCursor(); } #endif WId old_winid = data.winid; if ((q->windowType() == Qt::Desktop)) old_winid = 0; if (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_WState_Created)) hide_sys(); setWinId(0); if (parent != newparent) { QWidget *oldparent = q->parentWidget(); QObjectPrivate::setParent_helper(newparent); if (oldparent) { // oldparent->d_func()->setChildrenAllocatedDirty(); // oldparent->data->paintable_region_dirty = true; } if (newparent) { // newparent->d_func()->setChildrenAllocatedDirty(); // newparent->data->paintable_region_dirty = true; //@@@@@@@ } } Qt::FocusPolicy fp = q->focusPolicy(); QSize s = q->size(); //QBrush bgc = background(); // save colors bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); data.window_flags = f; q->setAttribute(Qt::WA_WState_Created, false); q->setAttribute(Qt::WA_WState_Visible, false); q->setAttribute(Qt::WA_WState_Hidden, false); adjustFlags(data.window_flags, q); // keep compatibility with previous versions, we need to preserve the created state // (but we recreate the winId for the widget being reparented, again for compatibility) if (wasCreated || (!q->isWindow() && newparent->testAttribute(Qt::WA_WState_Created))) createWinId(); if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) q->setAttribute(Qt::WA_WState_Hidden); q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); if (q->isWindow()) { QRect fs = frameStrut(); data.crect = QRect(fs.left(), fs.top(), s.width(), s.height()); if ((data.window_flags & Qt::FramelessWindowHint) && extra && extra->topextra) extra->topextra->frameStrut.setCoords(0, 0, 0, 0); } else { data.crect = QRect(0, 0, s.width(), s.height()); } q->setFocusPolicy(fp); if (extra && !extra->mask.isEmpty()) { QRegion r = extra->mask; extra->mask = QRegion(); q->setMask(r); } if ((int)old_winid > 0) { QWidget::qwsDisplay()->destroyRegion(old_winid); extra->topextra->backingStore->windowSurface->setGeometry(QRect()); } #ifndef QT_NO_CURSOR if (setcurs) { q->setCursor(oldcurs); } #endif }
static byte doCP_HL(Z80Context * ctx) { byte val = read8(ctx, WR.HL); byte result = doArithmetic(ctx, val, 0, 1); adjustFlags(ctx, val); return result; }
/* Adjust flags after AND, OR, XOR */ static void adjustLogicFlag (Z80Context* ctx, int flagH) { VALFLAG(F_S, (BR.A & 0x80) != 0); VALFLAG(F_Z, (BR.A == 0)); VALFLAG(F_H, flagH); VALFLAG(F_N, 0); VALFLAG(F_C, 0); VALFLAG(F_PV, parityBit[BR.A]); adjustFlags(ctx, BR.A); }
static byte doSL (Z80Context* ctx, byte val, int isArith) { VALFLAG(F_C, (val & 0x80) != 0); val <<= 1; if (!isArith) val |= 1; adjustFlags(ctx, val); RESFLAG(F_H | F_N); adjustFlagSZP(ctx, val); return val; }
static byte doRRC (Z80Context* ctx, int adjFlags, byte val) { VALFLAG(F_C, (val & 0x01) != 0); val >>= 1; val |= ((byte)GETFLAG(F_C) << 7); adjustFlags(ctx, val); RESFLAG(F_H | F_N); if (adjFlags) adjustFlagSZP(ctx, val); return val; }
static byte doRR (Z80Context* ctx, int adjFlags, byte val) { int CY = GETFLAG(F_C); VALFLAG(F_C, (val & 0x01)); val >>= 1; val |= (CY << 7); adjustFlags(ctx, val); RESFLAG(F_H | F_N); if (adjFlags) adjustFlagSZP(ctx, val); return val; }
static byte doRL (Z80Context* ctx, int adjFlags, byte val) { int CY = GETFLAG(F_C); VALFLAG(F_C, (val & 0x80) != 0); val <<= 1; val |= (byte)CY; adjustFlags(ctx, val); RESFLAG(F_H | F_N); if (adjFlags) adjustFlagSZP(ctx, val); return val; }
static HMODULE WINAPI MyLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) { HMODULE hModule = LoadLibraryExW(lpLibFileName, hFile, adjustFlags(dwFlags)); if (VERBOSITY >= 2) { debugPrintf("inject: intercepting %s(L\"%S\", 0x%p, 0x%lx) = 0x%p\n", __FUNCTION__ + 2, lpLibFileName, hFile, dwFlags, hModule); } // Hook all new modules (and not just this one, to pick up any dependencies) patchAllModules(); return hModule; }
static byte doSR (Z80Context* ctx, byte val, int isArith) { int b = val & 0x80; VALFLAG(F_C, (val & 0x01) != 0); val >>= 1; if (isArith) val |= b; adjustFlags(ctx, val); RESFLAG(F_H | F_N); adjustFlagSZP(ctx, val); return val; }
static void doDAA(Z80Context * ctx) { int correction_factor = 0x00; int carry = 0; if(BR.A > 0x99 || GETFLAG(F_C)) { correction_factor |= 0x60; carry = 1; } if((BR.A & 0x0f) > 9 || GETFLAG(F_H)) correction_factor |= 0x06; int a_before = BR.A; if(GETFLAG(F_N)) BR.A -= correction_factor; else BR.A += correction_factor; VALFLAG(F_H, (a_before ^ BR.A) & 0x10); VALFLAG(F_C, carry); VALFLAG(F_S, (BR.A & 0x80) != 0); VALFLAG(F_Z, (BR.A == 0)); VALFLAG(F_PV, parityBit[BR.A]); adjustFlags(ctx, BR.A); }
static byte doIncDec (Z80Context* ctx, byte val, int isDec) { if (isDec) { VALFLAG(F_PV, (val & 0x80) && !((val - 1) & 0x80)); val--; VALFLAG(F_H, (val & 0x0F) == 0x0F); } else { VALFLAG(F_PV, !(val & 0x80) && ((val + 1) & 0x80)); val++; VALFLAG(F_H, !(val & 0x0F)); } VALFLAG(F_S, ((val & 0x80) != 0)); VALFLAG(F_Z, (val == 0)); VALFLAG(F_N, isDec); adjustFlags(ctx, val); return val; }
/** Do an arithmetic operation (ADD, SUB, ADC, SBC y CP) */ static byte doArithmetic (Z80Context* ctx, byte value, int withCarry, int isSub) { ushort res; /* To detect carry */ if (isSub) { SETFLAG(F_N); VALFLAG(F_H, (((BR.A & 0x0F) - (value & 0x0F)) & 0x10) != 0); res = BR.A - value; if (withCarry && GETFLAG(F_C)) res--; } else { RESFLAG(F_N); VALFLAG(F_H, (((BR.A & 0x0F) + (value & 0x0F)) & 0x10) != 0); res = BR.A + value; if (withCarry && GETFLAG(F_C)) res++; } VALFLAG(F_S, ((res & 0x80) != 0)); VALFLAG(F_C, ((res & 0x100) != 0)); VALFLAG(F_Z, ((res & 0xff) == 0)); int minuend_sign = BR.A & 0x80; int subtrahend_sign = value & 0x80; int result_sign = res & 0x80; int overflow; if(isSub) overflow = minuend_sign != subtrahend_sign && result_sign != minuend_sign; else overflow = minuend_sign == subtrahend_sign && result_sign != minuend_sign; VALFLAG(F_PV, overflow); adjustFlags(ctx, res); return (byte)(res & 0xFF); }
void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) { Q_Q(QWidget); Qt::WindowFlags oldFlags = data.window_flags; bool wasCreated = q->testAttribute(Qt::WA_WState_Created); int targetScreen = -1; // Handle a request to move the widget to a particular screen if (newparent && newparent->windowType() == Qt::Desktop) { // make sure the widget is created on the same screen as the // programmer specified desktop widget // get the desktop's screen number targetScreen = newparent->window()->d_func()->topData()->screenIndex; newparent = 0; } setWinId(0); if (parent != newparent) { QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? if (q->windowHandle()) { q->windowHandle()->setFlags(f); QWidget *parentWithWindow = newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0; if (parentWithWindow) { if (f & Qt::Window) { q->windowHandle()->setTransientParent(parentWithWindow->windowHandle()); q->windowHandle()->setParent(0); } else { q->windowHandle()->setTransientParent(0); q->windowHandle()->setParent(parentWithWindow->windowHandle()); } } else { q->windowHandle()->setTransientParent(0); q->windowHandle()->setParent(0); } } } if (!newparent) { f |= Qt::Window; if (targetScreen == -1) { if (parent) targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex; } } bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); // Reparenting toplevel to child if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) q->destroy(); adjustFlags(f, q); data.window_flags = f; q->setAttribute(Qt::WA_WState_Created, false); q->setAttribute(Qt::WA_WState_Visible, false); q->setAttribute(Qt::WA_WState_Hidden, false); if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window))) q->createWinId(); if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) q->setAttribute(Qt::WA_WState_Hidden); q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); // move the window to the selected screen if (!newparent && targetScreen != -1) { if (maybeTopData()) maybeTopData()->screenIndex = targetScreen; // only if it is already created if (q->testAttribute(Qt::WA_WState_Created)) { q->windowHandle()->setScreen(QGuiApplication::screens().value(targetScreen, 0)); } } }