~ubuntu-branches/ubuntu/oneiric/thunderbird/oneiric-updates

« back to all changes in this revision

Viewing changes to debian/globalmenu/components/src/uGlobalMenuBar.cpp

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2011-09-06 00:19:41 UTC
  • mfrom: (1.6.13 upstream)
  • Revision ID: package-import@ubuntu.com-20110906001941-ie80kcviw3yfmfv1
Tags: 7.0~b2+build2+nobinonly-0ubuntu1
* New upstream release from the beta channel (THUNDERBIRD_7_0b2_BUILD2)
  - LP: #837557 and LP: #838322

* Update globalmenu-extension to 2.0
  - Only update a menu in realtime if it's parent is opening. For all other
    times, just invalidate the menu. Avoids spamming dbus everytime
    something changes in the menu
  - When removing a menuitem from its parent, check that the index is
    in-bounds. Should fix a frequent crash on startup, although it doesn't
    explain how it gets in to that state in the first place
  - Add the ability to turn on debugging without building Firefox with
    debugging on
* Add upstream patch to only add ENABLE_JIT=1 to CXXFLAGS if any of trace/
  method/yarr jit is enabled. Fixes a build failure on PPC
  - add debian/patches/only-add-ENABLE_JIT-to-CXXFLAGS-if-jit-is-enabled.patch
  - update debian/patches/series
* Add upstream patch to fix build failure with ENABLE_YARR_JIT=0
  - add debian/patches/build-fix-for-no-ENABLE_YARR_JIT.patch
  - update debian/patches/series
* Add upstream patch to work around a linker bug
  - add debian/patches/compile-pldhash-as-C++.patch
  - update debian/patches/series
* Don't pass an empty --mozilla-repo= argument to client.py when creating
  the source tarball without a local cache, as it totally breaks. This is
  why we've got rid of all this in nightly and aurora, so we can avoid
  such bandaids in the first place
  - update debian/mozclient/thunderbird.conf
* Messagingmenu fixes:
  - Use the libunity5 ABI (LP: #839154)
  - Don't use QueryInterface on objects where we can't guarantee they
    implement a particular interface (LP: #826447)
* Make sure that thunderbird-gnome-support actually depends on libunity5
  - update debian/rules
* Update eds extension to r84 from 0.3 branch
  - fixes a shutdown crash
* Use the latest eds libs for the contacts integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include <nsIXULWindow.h>
45
45
#include <nsIInterfaceRequestorUtils.h>
46
46
#include <nsIDocShell.h>
47
 
#include <nsIDOMNSEvent.h>
 
47
#if 1
 
48
# include <nsIDOMNSEvent.h>
 
49
#endif
48
50
#include <nsIPrefBranch.h>
49
51
#include <nsIPrefService.h>
50
52
#include <nsIDOMKeyEvent.h>
62
64
#include "uIGlobalMenuService.h"
63
65
#include "uWidgetAtoms.h"
64
66
 
 
67
#include "uDebug.h"
 
68
 
65
69
#define MODIFIER_SHIFT    1
66
70
#define MODIFIER_CONTROL  2
67
71
#define MODIFIER_ALT      4
68
72
#define MODIFIER_META     8
69
73
 
70
 
NS_IMPL_ADDREF(uGlobalMenuBarListener)
71
 
NS_IMPL_RELEASE(uGlobalMenuBarListener)
72
 
NS_INTERFACE_MAP_BEGIN(uGlobalMenuBarListener)
73
 
  NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
74
 
  NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
75
 
  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener,nsIDOMKeyListener)
76
 
NS_INTERFACE_MAP_END
77
 
 
78
 
NS_IMETHODIMP
79
 
uGlobalMenuBarListener::KeyPress(nsIDOMEvent *aKeyEvent)
80
 
{
81
 
  return mMenuBar->KeyPress(aKeyEvent);
82
 
}
83
 
 
84
 
NS_IMETHODIMP
85
 
uGlobalMenuBarListener::KeyUp(nsIDOMEvent *aKeyEvent)
86
 
{
87
 
  return mMenuBar->KeyUp(aKeyEvent);
88
 
}
89
 
 
90
 
NS_IMETHODIMP
91
 
uGlobalMenuBarListener::KeyDown(nsIDOMEvent *aKeyEvent)
92
 
{
93
 
  return mMenuBar->KeyDown(aKeyEvent);
94
 
}
95
 
 
96
 
NS_IMETHODIMP
97
 
uGlobalMenuBarListener::Blur(nsIDOMEvent *aEvent)
98
 
{
99
 
  if (mMenuBar) {
 
74
NS_IMPL_ISUPPORTS1(uGlobalMenuBarListener, nsIDOMEventListener)
 
75
 
 
76
NS_IMETHODIMP
 
77
uGlobalMenuBarListener::HandleEvent(nsIDOMEvent *aEvent)
 
78
{
 
79
  nsAutoString type;
 
80
  nsresult rv = aEvent->GetType(type);
 
81
  NS_ENSURE_SUCCESS(rv, rv);
 
82
 
 
83
  if (type.EqualsLiteral("focus")) {
 
84
    mMenuBar->Focus();
 
85
  } else if (type.EqualsLiteral("blur")) {
100
86
    mMenuBar->Blur();
 
87
  } else if (type.EqualsLiteral("keypress")) {
 
88
    rv = mMenuBar->KeyPress(aEvent);
 
89
  } else if (type.EqualsLiteral("keydown")) {
 
90
    rv = mMenuBar->KeyDown(aEvent);
 
91
  } else if (type.EqualsLiteral("keyup")) {
 
92
    rv = mMenuBar->KeyUp(aEvent);
101
93
  }
102
 
  return NS_OK;
103
 
}
104
94
 
105
 
NS_IMETHODIMP
106
 
uGlobalMenuBarListener::Focus(nsIDOMEvent *aEvent)
107
 
{
108
 
  if (mMenuBar) {
109
 
    mMenuBar->Focus();
110
 
  }
111
 
  return NS_OK;
 
95
  return rv;
112
96
}
113
97
 
114
98
GtkWidget*
149
133
PRBool
150
134
uGlobalMenuBar::RemoveMenuObjectAt(PRUint32 index)
151
135
{
 
136
  NS_ASSERTION(index < mMenuObjects.Length(), "Invalid index");
 
137
  if (index >= mMenuObjects.Length()) {
 
138
    return PR_FALSE;
 
139
  }
 
140
 
152
141
  gboolean res = dbusmenu_menuitem_child_delete(mDbusMenuItem,
153
142
                                       mMenuObjects[index]->GetDbusMenuItem());
154
143
  mMenuObjects.RemoveElementAt(index);
187
176
  NS_ENSURE_ARG(aWindow);
188
177
  NS_ENSURE_ARG(aMenuBar);
189
178
 
 
179
  // We create this early so that IsRegistered() works
 
180
  mCancellable = uGlobalMenuRequestAutoCanceller::Create();
 
181
 
190
182
  mContent = aMenuBar;
191
183
 
192
184
  mTopLevel = WidgetToGTKWindow(aWindow);
226
218
  mEventListener = new uGlobalMenuBarListener(this);
227
219
  NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY);
228
220
 
229
 
  // Find the top-level DOM window from our nsIWidget, so we
230
 
  // can register the menubar as a focus event listener, in order
231
 
  // for it to cancel menus when it the window gets focus
232
 
  void *clientData;
233
 
  aWindow->GetClientData(clientData);
234
 
  nsISupports *data = static_cast<nsISupports *>(clientData);
235
 
  nsCOMPtr<nsIXULWindow> xulWindow = do_QueryInterface(data);
236
 
  NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE);
237
 
 
238
 
  nsCOMPtr<nsIDocShell> docShell;
239
 
  xulWindow->GetDocShell(getter_AddRefs(docShell));
240
 
  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
241
 
 
242
 
  nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(docShell);
243
 
  mDOMWinTarget = do_QueryInterface(domWindow);
244
 
 
245
 
  mDOMWinTarget->AddEventListener(NS_LITERAL_STRING("focus"),
246
 
                                  (nsIDOMFocusListener *)mEventListener,
247
 
                                  PR_TRUE);
248
 
  mDOMWinTarget->AddEventListener(NS_LITERAL_STRING("blur"),
249
 
                                  (nsIDOMFocusListener *)mEventListener,
250
 
                                  PR_FALSE);
251
 
 
252
221
  mDocTarget = do_QueryInterface(mContent->GetCurrentDoc());
253
222
 
 
223
  mDocTarget->AddEventListener(NS_LITERAL_STRING("focus"),
 
224
                               mEventListener,
 
225
                               PR_TRUE);
 
226
  mDocTarget->AddEventListener(NS_LITERAL_STRING("blur"),
 
227
                               mEventListener,
 
228
                               PR_TRUE);
254
229
  mDocTarget->AddEventListener(NS_LITERAL_STRING("keypress"),
255
 
                               (nsIDOMKeyListener *)mEventListener,
 
230
                               mEventListener,
256
231
                               PR_FALSE);
257
232
  mDocTarget->AddEventListener(NS_LITERAL_STRING("keydown"),
258
 
                               (nsIDOMKeyListener *)mEventListener,
 
233
                               mEventListener,
259
234
                               PR_FALSE);
260
235
  mDocTarget->AddEventListener(NS_LITERAL_STRING("keyup"),
261
 
                               (nsIDOMKeyListener *)mEventListener,
 
236
                               mEventListener,
262
237
                               PR_FALSE);
263
238
 
264
239
  nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
284
259
    do_GetService("@canonical.com/globalmenu-service;1");
285
260
  NS_ENSURE_TRUE(service, NS_ERROR_FAILURE);
286
261
 
287
 
  mCancellable = uGlobalMenuRequestAutoCanceller::Create();
288
262
  service->RegisterGlobalMenuBar(this, mCancellable);
289
263
 
290
264
  return NS_OK;
424
398
{
425
399
  SetXULMenuBarHidden(PR_FALSE);
426
400
 
427
 
  if (mDOMWinTarget) {
428
 
    mDOMWinTarget->RemoveEventListener(NS_LITERAL_STRING("focus"),
429
 
                                       (nsIDOMFocusListener *)mEventListener,
430
 
                                       PR_TRUE);
431
 
    mDOMWinTarget->RemoveEventListener(NS_LITERAL_STRING("blur"),
432
 
                                       (nsIDOMFocusListener *)mEventListener,
433
 
                                       PR_FALSE);
434
 
  }
435
 
 
436
401
  if (mDocTarget) {
 
402
    mDocTarget->RemoveEventListener(NS_LITERAL_STRING("focus"),
 
403
                                    mEventListener,
 
404
                                    PR_TRUE);
 
405
    mDocTarget->RemoveEventListener(NS_LITERAL_STRING("blur"),
 
406
                                    mEventListener,
 
407
                                    PR_TRUE);
437
408
    mDocTarget->RemoveEventListener(NS_LITERAL_STRING("keypress"),
438
 
                                    (nsIDOMKeyListener *)mEventListener,
 
409
                                    mEventListener,
439
410
                                    PR_FALSE);
440
411
    mDocTarget->RemoveEventListener(NS_LITERAL_STRING("keydown"),
441
 
                                    (nsIDOMKeyListener *)mEventListener,
 
412
                                    mEventListener,
442
413
                                    PR_FALSE);
443
414
    mDocTarget->RemoveEventListener(NS_LITERAL_STRING("keyup"),
444
 
                                    (nsIDOMKeyListener *)mEventListener,
 
415
                                    mEventListener,
445
416
                                    PR_FALSE);
446
417
  }
447
418
 
495
466
PRBool
496
467
uGlobalMenuBar::ShouldHandleKeyEvent(nsIDOMEvent *aKeyEvent)
497
468
{
 
469
#if 0
 
470
# define nsEvent aKeyEvent
 
471
#else
498
472
  nsCOMPtr<nsIDOMNSEvent> nsEvent = do_QueryInterface(aKeyEvent);
499
473
  if (!nsEvent) {
500
474
    return PR_FALSE;
501
475
  }
 
476
#endif
502
477
 
503
478
  PRBool handled, trusted;
504
479
  nsEvent->GetPreventDefault(&handled);
505
480
  nsEvent->GetIsTrusted(&trusted);
506
481
 
 
482
#if 0
 
483
# undef nsEvent
 
484
#endif
 
485
 
507
486
  if (handled || !trusted) {
508
487
    return PR_FALSE;
509
488
  }