Changeset 39069
- Timestamp:
- 11/13/11 17:21:20 (19 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/objective-cplusplus/i3/trunk/tmp/dwmedit/BlurEditController.cc
r39068 r39069 3 3 #include <stdio.h> 4 4 #include <usp10.h> 5 #include <utility> 5 6 6 7 #include "ApiHook.h" … … 21 22 extern BlurEditController self; 22 23 struct BlurEditController { 23 LONG cancel_count; // thread guard24 LONG ext_text_out_count; // thread guard24 LONG paint_enable; // thread guard 25 bool auto_paint_ignored; // raw 25 26 DWORD thread_id; // raw 26 int ignored; // raw27 27 28 28 WNDPROC DefaultWindowProceduer; … … 33 33 BP_PAINTPARAMS bp_paintparams; 34 34 35 class Ignore { 36 LONG cancel; 35 class PaintEnable { 36 const LONG saved_paint_enable; 37 PaintEnable& operator=(const PaintEnable& that); 37 38 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); 43 43 } 44 44 }; 45 45 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()) { 49 49 return true; 50 50 } 51 self.ignored = 1;52 51 return false; 53 52 } … … 65 64 static HRESULT WINAPI DrawThemeBackground(HTHEME a, HDC b, int c, int d, 66 65 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; 70 70 return S_OK; 71 71 } … … 79 79 LPCTSTR lpString, UINT cbCount, CONST INT *lpDx) { 80 80 81 if ( self.thread_id != GetCurrentThreadId()) {81 if (isPaintEnable()) { 82 82 return self.o.ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, cbCount, lpDx); 83 83 } 84 84 85 static int x_ = 0; 85 // ����PI�Ăяo�����E�N���b�N���j���[�`�����߂̂����� 86 // TODO ���Ə����� static int x_ = 0; 86 87 static int y_ = 0; 87 88 static UINT fuOptions_ = 0; … … 94 95 95 96 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; 101 104 } 102 105 }; … … 106 109 capture = false; 107 110 focus = false; 111 paint_enable = 0; 112 auto_paint_ignored = false; 108 113 109 114 black_brush = (HBRUSH)GetStockObject(BLACK_BRUSH); … … 142 147 } 143 148 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"))); 145 151 ReplaceIATEntryInOneMod("kernel32.dll", o.GetProcAddress, H::GetProcAddress, GetModuleHandle(_T("comctl32.dll"))); 146 152 } … … 155 161 } 156 162 163 /** 164 * �����ςȐݒ��`�悳�����܂����߁A������������ 165 * �ŁA���ꂪ�������ꂽ�ꍇ�ɐ������ݒ��ĕ`�悷�� */ 157 166 static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { 167 (void)static_cast<WNDPROC>(WndProc); 168 158 169 bool redraw = false; 159 WNDPROC wp = WndProc;160 (void)wp;161 170 162 171 if (message == WM_PAINT) { … … 175 184 HPAINTBUFFER paint_buffer1 = dll.BeginBufferedPaint(hdc, &ps.rcPaint, BPBF_TOPDOWNDIB, NULL, &mem_dc1); 176 185 if (paint_buffer1 == 0) { 186 // fatal error 177 187 EndPaint(hWnd, &ps); 178 188 return CallWindowProc(self.DefaultWindowProceduer, hWnd, message, wParam, lParam); … … 182 192 // �s�����̏ꍇ 183 193 { 184 Ignore ignore;194 PaintEnable paintEnable; 185 195 CallWindowProc(self.DefaultWindowProceduer, hWnd, WM_PRINTCLIENT, (WPARAM)mem_dc1, PRF_CLIENT); 186 196 } … … 192 202 HPAINTBUFFER paint_buffer2 = dll.BeginBufferedPaint(mem_dc1, &ps.rcPaint, BPBF_TOPDOWNDIB, &self.bp_paintparams, &mem_dc2); 193 203 if (paint_buffer2 == 0) { 204 // fatal error 194 205 dll.EndBufferedPaint(paint_buffer1, FALSE); 195 206 EndPaint(hWnd, &ps); … … 198 209 199 210 { 200 Ignore ignore;211 PaintEnable paintEnable; 201 212 CallWindowProc(self.DefaultWindowProceduer, hWnd, WM_PRINTCLIENT, (WPARAM)mem_dc2, PRF_CLIENT); 202 213 } … … 263 274 264 275 { 265 InterlockedExchangeAdd(&self.cancel_count, 1);266 276 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; 271 280 InvalidateRect(hWnd, NULL, FALSE); 272 // WndProc(hWnd, WM_PAINT, 0, 0);281 // WndProc(hWnd, WM_PAINT, 0, 0); 273 282 } 274 283
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)