Changeset 39069

Show
Ignore:
Timestamp:
11/13/11 17:21:20 (19 months ago)
Author:
saturday06
Message:

matomoni-ugoita

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-cplusplus/i3/trunk/tmp/dwmedit/BlurEditController.cc

    r39068 r39069  
    33#include <stdio.h> 
    44#include <usp10.h> 
     5#include <utility> 
    56 
    67#include "ApiHook.h" 
     
    2122extern BlurEditController self; 
    2223struct BlurEditController { 
    23     LONG cancel_count; // thread guard 
    24     LONG ext_text_out_count; // thread guard 
     24    LONG paint_enable; // thread guard 
     25    bool auto_paint_ignored; // raw 
    2526    DWORD thread_id; // raw 
    26     int ignored; // raw 
    2727 
    2828    WNDPROC DefaultWindowProceduer; 
     
    3333    BP_PAINTPARAMS bp_paintparams; 
    3434 
    35     class Ignore { 
    36         LONG cancel; 
     35    class PaintEnable { 
     36        const LONG saved_paint_enable; 
     37        PaintEnable& operator=(const PaintEnable& that); 
    3738    public: 
    38         Ignore() { 
    39             cancel = InterlockedExchange(&self.cancel_count, 0); 
    40         } 
    41         ~Ignore() { 
    42             InterlockedExchange(&self.cancel_count, cancel); 
     39        PaintEnable() : saved_paint_enable(InterlockedExchange(&self.paint_enable, 1)) { 
     40        } 
     41        ~PaintEnable() { 
     42            InterlockedExchange(&self.paint_enable, saved_paint_enable); 
    4343        } 
    4444    }; 
    4545 
    46     static bool select() { 
    47         LONG cancel = InterlockedExchangeAdd(&self.cancel_count, 0); 
    48         if (!cancel || self.thread_id != GetCurrentThreadId()) { 
     46    static bool isPaintEnable() { 
     47        LONG paint_enable = InterlockedExchangeAdd(&self.paint_enable, 0); 
     48        if (paint_enable || self.thread_id != GetCurrentThreadId()) { 
    4949            return true; 
    5050        } 
    51         self.ignored = 1; 
    5251        return false; 
    5352    } 
     
    6564        static HRESULT WINAPI DrawThemeBackground(HTHEME a, HDC b, int c, int d, 
    6665            const RECT * e, const RECT * f) { 
    67             if (select()) { 
    68                 self.o.DrawThemeBackground(a, b, c, d, e, f); 
    69             } 
     66            if (isPaintEnable()) { 
     67                return self.o.DrawThemeBackground(a, b, c, d, e, f); 
     68            } 
     69            self.auto_paint_ignored = true; 
    7070            return  S_OK; 
    7171        } 
     
    7979            LPCTSTR lpString, UINT cbCount, CONST INT *lpDx) { 
    8080 
    81             if (self.thread_id != GetCurrentThreadId()) { 
     81            if (isPaintEnable()) { 
    8282                return self.o.ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, cbCount, lpDx);  
    8383            } 
    8484 
    85             static int x_ = 0; 
     85            // ����PI�Ăяo�����E�N���b�N���j���[�`�����߂̂����𔻕� 
     86            // TODO ���Ə�����            static int x_ = 0; 
    8687            static int y_ = 0; 
    8788            static UINT fuOptions_ = 0; 
     
    9495 
    9596            DWORD objectType = GetObjectType(hdc); 
    96             if (objectType == OBJ_DC && match) { 
    97                 return TRUE; 
    98             } 
    99  
    100             return self.o.ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, cbCount, lpDx); 
     97            if (objectType != OBJ_DC || !match) { 
     98                // �E�N���b�N���j���[�̕`���ꍇ 
     99                return self.o.ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, cbCount, lpDx); 
     100            } 
     101 
     102            self.auto_paint_ignored = true; 
     103            return TRUE; 
    101104        } 
    102105    }; 
     
    106109        capture = false; 
    107110        focus = false; 
     111        paint_enable = 0; 
     112        auto_paint_ignored = false; 
    108113 
    109114        black_brush = (HBRUSH)GetStockObject(BLACK_BRUSH); 
     
    142147        } 
    143148 
    144         ReplaceIATEntryInAllMods("gdi32.dll", o.ExtTextOutW, H::ExtTextOutW); 
     149        //ReplaceIATEntryInAllMods("gdi32.dll", o.ExtTextOutW, H::ExtTextOutW); 
     150        ReplaceIATEntryInOneMod("gdi32.dll", o.ExtTextOutW, H::ExtTextOutW, GetModuleHandle(_T("usp10.dll"))); 
    145151        ReplaceIATEntryInOneMod("kernel32.dll", o.GetProcAddress, H::GetProcAddress, GetModuleHandle(_T("comctl32.dll"))); 
    146152    } 
     
    155161    } 
    156162 
     163    /** 
     164     * �����ςȐݒ��`�悳�����܂����߁A������������ 
     165     * �ŁA���ꂪ�������ꂽ�ꍇ�ɐ������ݒ��ĕ`�悷��     */ 
    157166    static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { 
     167        (void)static_cast<WNDPROC>(WndProc); 
     168 
    158169        bool redraw = false; 
    159         WNDPROC wp = WndProc; 
    160         (void)wp; 
    161170 
    162171        if (message == WM_PAINT) { 
     
    175184            HPAINTBUFFER paint_buffer1 = dll.BeginBufferedPaint(hdc, &ps.rcPaint, BPBF_TOPDOWNDIB, NULL, &mem_dc1); 
    176185            if (paint_buffer1 == 0) { 
     186                // fatal error 
    177187                EndPaint(hWnd, &ps); 
    178188                return CallWindowProc(self.DefaultWindowProceduer, hWnd, message, wParam, lParam); 
     
    182192                // �s�����̏ꍇ 
    183193                { 
    184                     Ignore ignore; 
     194                    PaintEnable paintEnable; 
    185195                    CallWindowProc(self.DefaultWindowProceduer, hWnd, WM_PRINTCLIENT, (WPARAM)mem_dc1, PRF_CLIENT); 
    186196                } 
     
    192202                HPAINTBUFFER paint_buffer2 = dll.BeginBufferedPaint(mem_dc1, &ps.rcPaint, BPBF_TOPDOWNDIB, &self.bp_paintparams, &mem_dc2); 
    193203                if (paint_buffer2 == 0) { 
     204                    // fatal error 
    194205                    dll.EndBufferedPaint(paint_buffer1, FALSE); 
    195206                    EndPaint(hWnd, &ps); 
     
    198209 
    199210                { 
    200                     Ignore ignore; 
     211                    PaintEnable paintEnable; 
    201212                    CallWindowProc(self.DefaultWindowProceduer, hWnd, WM_PRINTCLIENT, (WPARAM)mem_dc2, PRF_CLIENT); 
    202213                } 
     
    263274 
    264275        { 
    265             InterlockedExchangeAdd(&self.cancel_count, 1); 
    266276            LRESULT l = CallWindowProc(self.DefaultWindowProceduer, hWnd, message, wParam, lParam); 
    267             InterlockedExchangeAdd(&self.cancel_count, -1); 
    268  
    269             if (redraw || self.ignored) { 
    270                 self.ignored = 0; 
     277 
     278            if (redraw || self.auto_paint_ignored) { 
     279                self.auto_paint_ignored = false; 
    271280                InvalidateRect(hWnd, NULL, FALSE); 
    272                 //WndProc(hWnd, WM_PAINT, 0, 0); 
     281                // WndProc(hWnd, WM_PAINT, 0, 0); 
    273282            } 
    274283