ipc/glue/WindowsMessageLoop.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=2 et :
     3  */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #ifndef IPC_GLUE_WINDOWSMESSAGELOOP_H
     9 #define IPC_GLUE_WINDOWSMESSAGELOOP_H
    11 // This file is only meant to compile on windows
    12 #include <windows.h>
    14 #include "base/basictypes.h"
    15 #include "nsISupportsImpl.h"
    17 namespace mozilla {
    18 namespace ipc {
    19 namespace windows {
    21 void InitUIThread();
    23 class DeferredMessage
    24 {
    25 public:
    26   DeferredMessage()
    27   {
    28     MOZ_COUNT_CTOR(DeferredMessage);
    29   }
    31   virtual ~DeferredMessage()
    32   {
    33     MOZ_COUNT_DTOR(DeferredMessage);
    34   }
    36   virtual void Run() = 0;
    37 };
    39 // Uses CallWndProc to deliver a message at a later time. Messages faked with
    40 // this class must not have pointers in their wParam or lParam members as they
    41 // may be invalid by the time the message actually runs.
    42 class DeferredSendMessage : public DeferredMessage
    43 {
    44 public:
    45   DeferredSendMessage(HWND aHWnd,
    46                       UINT aMessage,
    47                       WPARAM aWParam,
    48                       LPARAM aLParam)
    49     : hWnd(aHWnd),
    50       message(aMessage),
    51       wParam(aWParam),
    52       lParam(aLParam)
    53   { }
    55   virtual void Run();
    57 protected:
    58     HWND hWnd;
    59     UINT message;
    60     WPARAM wParam;
    61     LPARAM lParam;
    62 };
    64 // Uses RedrawWindow to fake several painting-related messages. Flags passed
    65 // to the constructor go directly to RedrawWindow.
    66 class DeferredRedrawMessage : public DeferredMessage
    67 {
    68 public:
    69   DeferredRedrawMessage(HWND aHWnd,
    70                         UINT aFlags)
    71     : hWnd(aHWnd),
    72       flags(aFlags)
    73   { }
    75   virtual void Run();
    77 private:
    78   HWND hWnd;
    79   UINT flags;
    80 };
    82 // Uses UpdateWindow to generate a WM_PAINT message if needed.
    83 class DeferredUpdateMessage : public DeferredMessage
    84 {
    85 public:
    86   DeferredUpdateMessage(HWND aHWnd);
    88   virtual void Run();
    90 private:
    91   HWND mWnd;
    92   RECT mUpdateRect;
    93 };
    95 // This class duplicates a string that may exist in the lParam member of the
    96 // message.
    97 class DeferredSettingChangeMessage : public DeferredSendMessage
    98 {
    99 public:
   100   DeferredSettingChangeMessage(HWND aHWnd,
   101                                UINT aMessage,
   102                                WPARAM aWParam,
   103                                LPARAM aLParam);
   105   ~DeferredSettingChangeMessage();
   106 private:
   107   wchar_t* lParamString;
   108 };
   110 // This class uses SetWindowPos to fake various size-related messages. Flags
   111 // passed to the constructor go straight through to SetWindowPos.
   112 class DeferredWindowPosMessage : public DeferredMessage
   113 {
   114 public:
   115   DeferredWindowPosMessage(HWND aHWnd,
   116                            LPARAM aLParam,
   117                            bool aForCalcSize = false,
   118                            WPARAM aWParam = 0);
   120   virtual void Run();
   122 private:
   123   WINDOWPOS windowPos;
   124 };
   126 // This class duplicates a data buffer for a WM_COPYDATA message.
   127 class DeferredCopyDataMessage : public DeferredSendMessage
   128 {
   129 public:
   130   DeferredCopyDataMessage(HWND aHWnd,
   131                           UINT aMessage,
   132                           WPARAM aWParam,
   133                           LPARAM aLParam);
   135   ~DeferredCopyDataMessage();
   136 private:
   137   COPYDATASTRUCT copyData;
   138 };
   140 class DeferredStyleChangeMessage : public DeferredMessage
   141 {
   142 public:
   143   DeferredStyleChangeMessage(HWND aHWnd,
   144                              WPARAM aWParam,
   145                              LPARAM aLParam);
   147   virtual void Run();
   149 private:
   150   HWND hWnd;
   151   int index;
   152   LONG_PTR style;
   153 };
   155 class DeferredSetIconMessage : public DeferredSendMessage
   156 {
   157 public:
   158   DeferredSetIconMessage(HWND aHWnd,
   159                          UINT aMessage,
   160                          WPARAM aWParam,
   161                          LPARAM aLParam);
   163   virtual void Run();
   164 };
   166 } /* namespace windows */
   167 } /* namespace ipc */
   168 } /* namespace mozilla */
   170 #endif /* IPC_GLUE_WINDOWSMESSAGELOOP_H */

mercurial