~canonical-dx-team/ubuntu/maverick/gtk+2.0/menuproxy

« back to all changes in this revision

Viewing changes to gdk/directfb/gdkwindow-directfb.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-09-23 09:50:04 UTC
  • mfrom: (1.5.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: james.westby@ubuntu.com-20090923095004-e9xauadn4bjs5n7m
Tags: upstream-2.18.0
ImportĀ upstreamĀ versionĀ 2.18.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
351
351
}
352
352
 
353
353
 
 
354
GdkWindow *
 
355
gdk_directfb_window_new (GdkWindow              *parent,
 
356
                         GdkWindowAttr          *attributes,
 
357
                         gint                    attributes_mask,
 
358
                         DFBWindowCapabilities   window_caps,
 
359
                         DFBWindowOptions        window_options,
 
360
                         DFBSurfaceCapabilities  surface_caps)
 
361
{
 
362
  GdkWindow             *window;
 
363
  GdkWindowObject       *private;
 
364
  GdkWindowObject       *parent_private;
 
365
  GdkWindowImplDirectFB *impl;
 
366
  GdkWindowImplDirectFB *parent_impl;
 
367
  GdkVisual             *visual;
 
368
  DFBWindowDescription   desc;
 
369
  gint x, y;
 
370
 
 
371
  g_return_val_if_fail (attributes != NULL, NULL);
 
372
 
 
373
  D_DEBUG_AT( GDKDFB_Window, "%s( %p )\n", __FUNCTION__, parent );
 
374
 
 
375
  if (!parent || attributes->window_type != GDK_WINDOW_CHILD)
 
376
    parent = _gdk_parent_root;
 
377
 
 
378
  window = g_object_new (GDK_TYPE_WINDOW, NULL);
 
379
  private = GDK_WINDOW_OBJECT (window);
 
380
  private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
 
381
 
 
382
  parent_private = GDK_WINDOW_OBJECT (parent);
 
383
  parent_impl = GDK_WINDOW_IMPL_DIRECTFB (parent_private->impl);
 
384
  private->parent = parent_private;
 
385
 
 
386
  x = (attributes_mask & GDK_WA_X) ? attributes->x : 0;
 
387
  y = (attributes_mask & GDK_WA_Y) ? attributes->y : 0;
 
388
 
 
389
  gdk_window_set_events (window, attributes->event_mask | GDK_STRUCTURE_MASK);
 
390
 
 
391
  impl = GDK_WINDOW_IMPL_DIRECTFB (private->impl);
 
392
  impl->drawable.wrapper = GDK_DRAWABLE (window);
 
393
  impl->gdkWindow      = window;
 
394
 
 
395
  private->x = x;
 
396
  private->y = y;
 
397
 
 
398
  _gdk_directfb_calc_abs (window);
 
399
 
 
400
  impl->drawable.width  = MAX (1, attributes->width);
 
401
  impl->drawable.height = MAX (1, attributes->height);
 
402
 
 
403
  private->window_type = attributes->window_type;
 
404
 
 
405
  desc.flags = 0;
 
406
 
 
407
  if (attributes_mask & GDK_WA_VISUAL)
 
408
    visual = attributes->visual;
 
409
  else
 
410
    visual = gdk_drawable_get_visual (parent);
 
411
 
 
412
  switch (attributes->wclass)
 
413
    {
 
414
    case GDK_INPUT_OUTPUT:
 
415
      private->input_only = FALSE;
 
416
 
 
417
      desc.flags |= DWDESC_PIXELFORMAT;
 
418
      desc.pixelformat = ((GdkVisualDirectFB *) visual)->format;
 
419
 
 
420
      if (DFB_PIXELFORMAT_HAS_ALPHA (desc.pixelformat))
 
421
        {
 
422
          desc.flags |= DWDESC_CAPS;
 
423
          desc.caps = DWCAPS_ALPHACHANNEL;
 
424
        }
 
425
      break;
 
426
 
 
427
    case GDK_INPUT_ONLY:
 
428
      private->input_only = TRUE;
 
429
      desc.flags |= DWDESC_CAPS;
 
430
      desc.caps = DWCAPS_INPUTONLY;
 
431
      break;
 
432
 
 
433
    default:
 
434
      g_warning ("gdk_window_new: unsupported window class\n");
 
435
      _gdk_window_destroy (window, FALSE);
 
436
      return NULL;
 
437
    }
 
438
 
 
439
  switch (private->window_type)
 
440
    {
 
441
    case GDK_WINDOW_TOPLEVEL:
 
442
    case GDK_WINDOW_DIALOG:
 
443
    case GDK_WINDOW_TEMP:
 
444
      desc.flags |= ( DWDESC_WIDTH | DWDESC_HEIGHT |
 
445
                      DWDESC_POSX  | DWDESC_POSY );
 
446
      desc.posx   = x;
 
447
      desc.posy   = y;
 
448
      desc.width  = impl->drawable.width;
 
449
      desc.height = impl->drawable.height;
 
450
 
 
451
#if 0
 
452
      if (window_caps)
 
453
        {
 
454
          if (! (desc.flags & DWDESC_CAPS))
 
455
            {
 
456
              desc.flags |= DWDESC_CAPS;
 
457
              desc.caps   = DWCAPS_NONE;
 
458
            }
 
459
 
 
460
          desc.caps |= window_caps;
 
461
        }
 
462
 
 
463
      if (surface_caps)
 
464
        {
 
465
          desc.flags |= DWDESC_SURFACE_CAPS;
 
466
          desc.surface_caps = surface_caps;
 
467
        }
 
468
#endif
 
469
 
 
470
      if (!create_directfb_window (impl, &desc, window_options))
 
471
        {
 
472
          g_assert(0);
 
473
          _gdk_window_destroy (window, FALSE);
 
474
 
 
475
          return NULL;
 
476
        }
 
477
 
 
478
      if (desc.caps != DWCAPS_INPUTONLY)
 
479
        {
 
480
          impl->window->SetOpacity(impl->window, 0x00 );
 
481
        }
 
482
 
 
483
      break;
 
484
 
 
485
    case GDK_WINDOW_CHILD:
 
486
      impl->window=NULL;
 
487
 
 
488
      if (!private->input_only && parent_impl->drawable.surface)
 
489
        {
 
490
 
 
491
          DFBRectangle rect =
 
492
          { x, y, impl->drawable.width, impl->drawable.height };
 
493
          parent_impl->drawable.surface->GetSubSurface (parent_impl->drawable.surface,
 
494
                                                        &rect,
 
495
                                                        &impl->drawable.surface);
 
496
        }
 
497
 
 
498
      break;
 
499
 
 
500
    default:
 
501
      g_warning ("gdk_window_new: unsupported window type: %d",
 
502
                 private->window_type);
 
503
      _gdk_window_destroy (window, FALSE);
 
504
 
 
505
      return NULL;
 
506
    }
 
507
 
 
508
  if (impl->drawable.surface)
 
509
    {
 
510
      GdkColormap *colormap;
 
511
 
 
512
      impl->drawable.surface->GetPixelFormat (impl->drawable.surface,
 
513
                                              &impl->drawable.format);
 
514
 
 
515
      private->depth = DFB_BITS_PER_PIXEL(impl->drawable.format);
 
516
 
 
517
      if ((attributes_mask & GDK_WA_COLORMAP) && attributes->colormap)
 
518
        {
 
519
          colormap = attributes->colormap;
 
520
        }
 
521
      else
 
522
        {
 
523
          if (gdk_visual_get_system () == visual)
 
524
            colormap = gdk_colormap_get_system ();
 
525
          else
 
526
            colormap =gdk_drawable_get_colormap (parent);
 
527
        }
 
528
 
 
529
      gdk_drawable_set_colormap (GDK_DRAWABLE (window), colormap);
 
530
    }
 
531
  else
 
532
    {
 
533
      impl->drawable.format = ((GdkVisualDirectFB *)visual)->format;
 
534
      private->depth = visual->depth;
 
535
    }
 
536
 
 
537
  gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
 
538
                                  (attributes->cursor) : NULL));
 
539
 
 
540
  if (parent_private)
 
541
    parent_private->children = g_list_prepend (parent_private->children,
 
542
                                               window);
 
543
 
 
544
  /* we hold a reference count on ourselves */
 
545
  g_object_ref (window);
 
546
 
 
547
  if (impl->window)
 
548
    {
 
549
      impl->window->GetID (impl->window, &impl->dfb_id);
 
550
      gdk_directfb_window_id_table_insert (impl->dfb_id, window);
 
551
      gdk_directfb_event_windows_add (window);
 
552
    }
 
553
 
 
554
  if (attributes_mask & GDK_WA_TYPE_HINT)
 
555
    gdk_window_set_type_hint (window, attributes->type_hint);
 
556
 
 
557
  return window;
 
558
}
 
559
 
 
560
 
354
561
void
355
562
_gdk_window_impl_new (GdkWindow     *window,
356
563
                      GdkWindow     *real_parent,