Ticket #554: mbitter.tryagain.patch

File mbitter.tryagain.patch, 4.1 KB (added by tryagain.myopenid.com, 9 years ago)

Diff to current graphics_win32.c with patches applied as described above, mbitter.EzCreateFont?.patch and mbitter.fullscreen.patch are not applied.

  • graphics/win32/graphics_win32.c

     
    245245    hdc = GetDC( gr->wnd_handle );
    246246    // Creates memory DC
    247247    gr->hMemDC = CreateCompatibleDC(hdc);
    248     dbg(0, "resize memDC to: %d %d \n", gr->width, gr->height );
     248    dbg(1, "resize memDC to: %d %d \n", gr->width, gr->height );
    249249
    250250
    251251#ifndef  FAST_TRANSPARENCY
     
    381381            gra_priv->width = LOWORD( lParam );
    382382            gra_priv->height  = HIWORD( lParam );
    383383            create_memory_dc(gra_priv);
    384             dbg(0, "resize gfx to: %d %d \n", gra_priv->width, gra_priv->height );
     384            dbg(1, "resize gfx to: %d %d \n", gra_priv->width, gra_priv->height );
    385385            callback_list_call_attr_2(gra_priv->cbl, attr_resize, (void *)gra_priv->width, (void *)gra_priv->height);
    386386        }
    387387        break;
     
    601601    if ( win_priv && !win_priv->hBackLight )
    602602    {
    603603        win_priv->hBackLight = SetPowerRequirement(TEXT("BKL1:"), 0, 0x01, NULL, 0);
    604         event_win32_add_timeout(29000, 1, callback_new(SystemIdleTimerReset, 0, NULL));
     604        event_win32_add_timeout(9000, 1, callback_new(SystemIdleTimerReset, 0, NULL));
    605605    }
    606606
    607607    SystemIdleTimerReset();
     
    10051005        angle += 360;
    10061006
    10071007    SetTextAlign (gr->hMemDC, TA_BASELINE) ;
    1008     SetViewportOrgEx (gr->hMemDC, p->x, p->y, NULL) ;
    10091008    font->lf.lfEscapement = font->lf.lfOrientation = ( angle * 10 ) ;
    10101009    DeleteObject (font->hfont) ;
    10111010
    10121011    font->hfont = CreateFontIndirect (&font->lf);
    10131012    hOldFont = SelectObject(gr->hMemDC, font->hfont );
    10141013
     1014    TEXTMETRIC tm;
     1015    GetTextMetrics(gr->hMemDC, &tm);
     1016    SetViewportOrgEx (gr->hMemDC, p->x, p->y - tm.tmDescent , NULL) ;
     1017
    10151018    {
    10161019        wchar_t utf16[1024];
    10171020        const UTF8 *utf8 = (UTF8 *)text;
     
    10291032
    10301033    SelectObject(gr->hMemDC, hOldFont);
    10311034    DeleteObject (font->hfont) ;
     1035    font->hfont = NULL;
    10321036
    10331037    SetBkMode( gr->hMemDC, prevBkMode );
    10341038
     
    10401044    if ( font->hfont )
    10411045    {
    10421046        DeleteObject(font->hfont);
     1047        font->hfont = NULL;
    10431048    }
    10441049    g_free(font);
    10451050}
     
    14381443
    14391444    dbg(2, "Get bbox for %s\n", text);
    14401445
     1446    if ( NULL == font->hfont )
     1447    {
     1448#ifdef WIN_USE_SYSFONT
     1449        font->hfont = (HFONT) GetStockObject (SYSTEM_FONT);
     1450        GetObject (font->hfont, sizeof (LOGFONT), &font->lf);
     1451#else
     1452        font->hfont = EzCreateFont (gr->hMemDC, TEXT ("Arial"), font->size/2, 0, 0, TRUE);
     1453        GetObject ( font->hfont, sizeof (LOGFONT), &font->lf) ;
     1454#endif
     1455    }
     1456
     1457    HFONT hOldFont = SelectObject(gr->hMemDC, font->hfont );
     1458
     1459    {
     1460        wchar_t utf16[1024];
     1461        const UTF8 *utf8 = (UTF8 *)text;
     1462        UTF16 *utf16p = (UTF16 *) utf16;
     1463        if (ConvertUTF8toUTF16(&utf8, utf8+strlen(text),
     1464                               &utf16p, utf16p+sizeof(utf16),
     1465                               lenientConversion) == conversionOK)
     1466        {
     1467            SIZE size;
     1468            if (GetTextExtentPointW(gr->hMemDC, utf16, (wchar_t*) utf16p - utf16, &size)) {
     1469                yMax = size.cy;
     1470                xMax = size.cx;
     1471            }
     1472        }
     1473    }
     1474
     1475    SelectObject(gr->hMemDC, hOldFont);
     1476
     1477    DeleteObject(font->hfont);
     1478    font->hfont = NULL;
     1479   
    14411480    ret[0].x = xMin;
    14421481    ret[0].y = -yMin;
    14431482    ret[1].x = xMin;
     
    15451584{
    15461585    MSG msg;
    15471586
    1548     dbg(0,"enter\n");
     1587    dbg(1,"enter\n");
    15491588    while (GetMessage(&msg, 0, 0, 0))
    15501589    {
    15511590        TranslateMessage(&msg);       /*  Keyboard input.      */
     
    15611600    HWND hwndSip;
    15621601#endif
    15631602
    1564     dbg(0,"enter\n");
     1603    dbg(1,"enter\n");
    15651604
    15661605#ifdef HAVE_API_WIN32_CE
    15671606    hwndTaskbar = FindWindow(L"HHTaskBar", NULL);
     
    15771616static struct event_watch *
    15781617            event_win32_add_watch(void *h, enum event_watch_cond cond, struct callback *cb)
    15791618{
    1580     dbg(0,"enter\n");
     1619    dbg(1,"enter\n");
    15811620    return NULL;
    15821621}
    15831622
    15841623static void
    15851624event_win32_remove_watch(struct event_watch *ev)
    15861625{
    1587     dbg(0,"enter\n");
     1626    dbg(1,"enter\n");
    15881627}
    15891628
    15901629static GList *timers;