Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: ui/views/widget/desktop_aura/x11_desktop_handler.cc

Issue 397223002: Enable copying long text to Chrome and pasting long text from Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" 5 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/window_event_dispatcher.h" 12 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/base/x/x11_foreign_window_manager.h"
13 #include "ui/base/x/x11_menu_list.h" 14 #include "ui/base/x/x11_menu_list.h"
14 #include "ui/base/x/x11_util.h" 15 #include "ui/base/x/x11_util.h"
15 #include "ui/events/platform/platform_event_source.h" 16 #include "ui/events/platform/platform_event_source.h"
16 #include "ui/gfx/x/x11_error_tracker.h" 17 #include "ui/gfx/x/x11_error_tracker.h"
17 #include "ui/views/ime/input_method.h" 18 #include "ui/views/ime/input_method.h"
18 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 19 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
19 20
20 namespace { 21 namespace {
21 22
22 const char* kAtomsToCache[] = { 23 const char* kAtomsToCache[] = {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (event->xproperty.atom == active_window_atom) { 161 if (event->xproperty.atom == active_window_atom) {
161 ::Window window; 162 ::Window window;
162 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && 163 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) &&
163 window) { 164 window) {
164 OnActiveWindowChanged(window, ACTIVE); 165 OnActiveWindowChanged(window, ACTIVE);
165 } 166 }
166 } 167 }
167 break; 168 break;
168 } 169 }
169 170
170 // Menus created by Chrome can be drag and drop targets. Since they are 171 case CreateNotify:
171 // direct children of the screen root window and have override_redirect 172 OnWindowCreatedOrDestroyed(event->type, event->xcreatewindow.window);
172 // we cannot use regular _NET_CLIENT_LIST_STACKING property to find them
173 // and use a separate cache to keep track of them.
174 // TODO(varkha): Implement caching of all top level X windows and their
175 // coordinates and stacking order to eliminate repeated calls to X server
176 // during mouse movement, drag and shaping events.
177 case CreateNotify: {
178 // The window might be destroyed if the message pump haven't gotten a
179 // chance to run but we can safely ignore the X error.
180 gfx::X11ErrorTracker error_tracker;
181 XCreateWindowEvent *xcwe = &event->xcreatewindow;
182 ui::XMenuList::GetInstance()->MaybeRegisterMenu(xcwe->window);
183 break; 173 break;
184 } 174 case DestroyNotify:
185 case DestroyNotify: { 175 OnWindowCreatedOrDestroyed(event->type, event->xdestroywindow.window);
186 XDestroyWindowEvent *xdwe = &event->xdestroywindow;
187 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(xdwe->window);
188 break; 176 break;
189 }
190 default: 177 default:
191 NOTREACHED(); 178 NOTREACHED();
192 } 179 }
193 180
194 return ui::POST_DISPATCH_NONE; 181 return ui::POST_DISPATCH_NONE;
195 } 182 }
196 183
197 void X11DesktopHandler::OnWindowInitialized(aura::Window* window) { 184 void X11DesktopHandler::OnWindowInitialized(aura::Window* window) {
198 } 185 }
199 186
(...skipping 19 matching lines...) Expand all
219 current_window_active_state_ = active_state; 206 current_window_active_state_ = active_state;
220 207
221 if (active_state == ACTIVE) { 208 if (active_state == ACTIVE) {
222 DesktopWindowTreeHostX11* new_host = 209 DesktopWindowTreeHostX11* new_host =
223 views::DesktopWindowTreeHostX11::GetHostForXID(xid); 210 views::DesktopWindowTreeHostX11::GetHostForXID(xid);
224 if (new_host) 211 if (new_host)
225 new_host->HandleNativeWidgetActivationChanged(true); 212 new_host->HandleNativeWidgetActivationChanged(true);
226 } 213 }
227 } 214 }
228 215
216 void X11DesktopHandler::OnWindowCreatedOrDestroyed(int event_type,
217 XID window) {
218 // Menus created by Chrome can be drag and drop targets. Since they are
219 // direct children of the screen root window and have override_redirect
220 // we cannot use regular _NET_CLIENT_LIST_STACKING property to find them
221 // and use a separate cache to keep track of them.
222 // TODO(varkha): Implement caching of all top level X windows and their
223 // coordinates and stacking order to eliminate repeated calls to the X server
224 // during mouse movement, drag and shaping events.
225 if (event_type == CreateNotify) {
226 // The window might be destroyed if the message pump did not get a chance to
227 // run but we can safely ignore the X error.
228 gfx::X11ErrorTracker error_tracker;
229 ui::XMenuList::GetInstance()->MaybeRegisterMenu(window);
230 } else {
231 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window);
232 }
233
234 if (event_type == DestroyNotify) {
235 // Notify the XForeignWindowManager that |window| has been destroyed.
236 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window);
237 }
238 }
239
229 } // namespace views 240 } // namespace views
OLDNEW
« ui/base/x/x11_foreign_window_manager.cc ('K') | « ui/views/widget/desktop_aura/x11_desktop_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698