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

Side by Side Diff: ui/base/x/x11_util.cc

Issue 10919135: Move ash specific cursor code to CursorManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 3 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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 memcpy(image->pixels, 446 memcpy(image->pixels,
447 bitmap->getPixels(), 447 bitmap->getPixels(),
448 bitmap->width() * bitmap->height() * 4); 448 bitmap->width() * bitmap->height() * 4);
449 bitmap->unlockPixels(); 449 bitmap->unlockPixels();
450 } 450 }
451 451
452 return image; 452 return image;
453 } 453 }
454 #endif 454 #endif
455 455
456 void HideHostCursor() {
457 XDefineCursor(ui::GetXDisplay(), DefaultRootWindow(ui::GetXDisplay()),
458 GetInvisibleCursor());
459 }
460
461 ::Cursor GetInvisibleCursor() {
462 Display* xdisplay = ui::GetXDisplay();
463 CR_DEFINE_STATIC_LOCAL(XScopedCursor, invisible_cursor, (0U, xdisplay));
464 if (invisible_cursor.get())
465 return invisible_cursor.get();
466
467 // Initialize invisible cursor.
468 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
469 XColor black;
470 black.red = black.green = black.blue = 0;
471 Pixmap blank = XCreateBitmapFromData(xdisplay, DefaultRootWindow(xdisplay),
472 nodata, 8, 8);
473 invisible_cursor.reset(XCreatePixmapCursor(xdisplay, blank, blank,
474 &black, &black, 0, 0));
475 XFreePixmap(xdisplay, blank);
476 return invisible_cursor.get();
477 }
478
456 XID GetX11RootWindow() { 479 XID GetX11RootWindow() {
457 return DefaultRootWindow(GetXDisplay()); 480 return DefaultRootWindow(GetXDisplay());
458 } 481 }
459 482
460 bool GetCurrentDesktop(int* desktop) { 483 bool GetCurrentDesktop(int* desktop) {
461 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); 484 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop);
462 } 485 }
463 486
464 #if defined(TOOLKIT_GTK) 487 #if defined(TOOLKIT_GTK)
465 XID GetX11WindowFromGtkWidget(GtkWidget* widget) { 488 XID GetX11WindowFromGtkWidget(GtkWidget* widget) {
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 key_event.keycode = XKeyEventKeyCode(key_code, flags, display); 1352 key_event.keycode = XKeyEventKeyCode(key_code, flags, display);
1330 key_event.same_screen = 1; 1353 key_event.same_screen = 1;
1331 event->type = key_event.type; 1354 event->type = key_event.type;
1332 event->xkey = key_event; 1355 event->xkey = key_event;
1333 } 1356 }
1334 1357
1335 XScopedString::~XScopedString() { 1358 XScopedString::~XScopedString() {
1336 XFree(string_); 1359 XFree(string_);
1337 } 1360 }
1338 1361
1362 XScopedCursor::XScopedCursor(::Cursor cursor, Display* display)
1363 : cursor_(cursor),
1364 display_(display) {
1365 }
1366
1367 XScopedCursor::~XScopedCursor() {
1368 reset(0U);
1369 }
1370
1371 ::Cursor XScopedCursor::get() const {
1372 return cursor_;
1373 }
1374
1375 void XScopedCursor::reset(::Cursor cursor) {
1376 if (cursor_)
1377 XFreeCursor(display_, cursor_);
1378 cursor_ = cursor;
1379 }
1380
1339 // ---------------------------------------------------------------------------- 1381 // ----------------------------------------------------------------------------
1340 // These functions are declared in x11_util_internal.h because they require 1382 // These functions are declared in x11_util_internal.h because they require
1341 // XLib.h to be included, and it conflicts with many other headers. 1383 // XLib.h to be included, and it conflicts with many other headers.
1342 XRenderPictFormat* GetRenderARGB32Format(Display* dpy) { 1384 XRenderPictFormat* GetRenderARGB32Format(Display* dpy) {
1343 static XRenderPictFormat* pictformat = NULL; 1385 static XRenderPictFormat* pictformat = NULL;
1344 if (pictformat) 1386 if (pictformat)
1345 return pictformat; 1387 return pictformat;
1346 1388
1347 // First look for a 32-bit format which ignores the alpha value 1389 // First look for a 32-bit format which ignores the alpha value
1348 XRenderPictFormat templ; 1390 XRenderPictFormat templ;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1501 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1460 << "minor_code " << static_cast<int>(error_event.minor_code) 1502 << "minor_code " << static_cast<int>(error_event.minor_code)
1461 << " (" << request_str << ")"; 1503 << " (" << request_str << ")";
1462 } 1504 }
1463 1505
1464 // ---------------------------------------------------------------------------- 1506 // ----------------------------------------------------------------------------
1465 // End of x11_util_internal.h 1507 // End of x11_util_internal.h
1466 1508
1467 1509
1468 } // namespace ui 1510 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698