2005-11-22 10:03:32 +00:00
|
|
|
/* gdkvisual-quartz.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Imendio AB
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-11-22 10:03:32 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-12-17 16:05:53 +00:00
|
|
|
#include "gdkvisualprivate.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
#include "gdkquartzvisual.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
#include "gdkprivate-quartz.h"
|
|
|
|
|
2010-12-22 13:42:25 +00:00
|
|
|
|
|
|
|
struct _GdkQuartzVisual
|
|
|
|
{
|
|
|
|
GdkVisual visual;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GdkQuartzVisualClass
|
|
|
|
{
|
|
|
|
GdkVisualClass visual_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
static GdkVisual *system_visual;
|
|
|
|
static GdkVisual *rgba_visual;
|
2010-06-25 20:40:27 +00:00
|
|
|
static GdkVisual *gray_visual;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
static GdkVisual *
|
2010-12-17 16:05:53 +00:00
|
|
|
create_standard_visual (GdkScreen *screen,
|
|
|
|
gint depth)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-12-22 13:42:25 +00:00
|
|
|
GdkVisual *visual = g_object_new (GDK_TYPE_QUARTZ_VISUAL, NULL);
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-12-17 16:05:53 +00:00
|
|
|
visual->screen = screen;
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
visual->depth = depth;
|
|
|
|
visual->byte_order = GDK_MSB_FIRST; /* FIXME: Should this be different on intel macs? */
|
|
|
|
visual->colormap_size = 0;
|
2010-12-17 16:05:53 +00:00
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
visual->type = GDK_VISUAL_TRUE_COLOR;
|
|
|
|
|
|
|
|
visual->red_mask = 0xff0000;
|
|
|
|
visual->green_mask = 0xff00;
|
|
|
|
visual->blue_mask = 0xff;
|
|
|
|
|
|
|
|
return visual;
|
|
|
|
}
|
|
|
|
|
2010-06-25 20:40:27 +00:00
|
|
|
static GdkVisual *
|
2010-12-17 16:05:53 +00:00
|
|
|
create_gray_visual (GdkScreen *screen)
|
2010-06-25 20:40:27 +00:00
|
|
|
{
|
2010-12-22 13:42:25 +00:00
|
|
|
GdkVisual *visual = g_object_new (GDK_TYPE_QUARTZ_VISUAL, NULL);
|
2010-06-25 20:40:27 +00:00
|
|
|
|
2010-12-17 16:05:53 +00:00
|
|
|
visual->screen = screen;
|
|
|
|
|
2010-06-25 20:40:27 +00:00
|
|
|
visual->depth = 1;
|
|
|
|
visual->byte_order = GDK_MSB_FIRST;
|
|
|
|
visual->colormap_size = 0;
|
|
|
|
|
|
|
|
visual->type = GDK_VISUAL_STATIC_GRAY;
|
|
|
|
|
|
|
|
return visual;
|
|
|
|
}
|
|
|
|
|
2010-12-22 13:42:25 +00:00
|
|
|
|
2010-12-23 12:44:44 +00:00
|
|
|
G_DEFINE_TYPE (GdkQuartzVisual, gdk_quartz_visual, GDK_TYPE_VISUAL)
|
2010-12-22 13:42:25 +00:00
|
|
|
|
|
|
|
static void
|
2010-12-23 12:44:44 +00:00
|
|
|
gdk_quartz_visual_init (GdkQuartzVisual *quartz_visual)
|
2010-12-22 13:42:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-23 12:44:44 +00:00
|
|
|
gdk_quartz_visual_class_init (GdkQuartzVisualClass *class)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-25 20:40:27 +00:00
|
|
|
/* We prefer the system visual for now ... */
|
2005-11-22 10:03:32 +00:00
|
|
|
gint
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_visual_get_best_depth (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return system_visual->depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisualType
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_visual_get_best_type (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return system_visual->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual *
|
2010-12-17 14:50:21 +00:00
|
|
|
_gdk_quartz_screen_get_rgba_visual (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return rgba_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_get_system_visual (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return system_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_visual_get_best (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
return system_visual;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_visual_get_best_with_depth (GdkScreen *screen,
|
|
|
|
gint depth)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-06-25 20:40:27 +00:00
|
|
|
GdkVisual *visual = NULL;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-06-25 20:40:27 +00:00
|
|
|
switch (depth)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
visual = rgba_visual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
visual = system_visual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
visual = gray_visual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
visual = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return visual;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_visual_get_best_with_type (GdkScreen *screen,
|
|
|
|
GdkVisualType visual_type)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-06-25 20:40:27 +00:00
|
|
|
if (system_visual->type == visual_type)
|
|
|
|
return system_visual;
|
|
|
|
else if (gray_visual->type == visual_type)
|
|
|
|
return gray_visual;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-06-25 20:40:27 +00:00
|
|
|
return NULL;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GdkVisual*
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_visual_get_best_with_both (GdkScreen *screen,
|
|
|
|
gint depth,
|
|
|
|
GdkVisualType visual_type)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-06-25 20:40:27 +00:00
|
|
|
if (system_visual->depth == depth
|
|
|
|
&& system_visual->type == visual_type)
|
|
|
|
return system_visual;
|
|
|
|
else if (rgba_visual->depth == depth
|
|
|
|
&& rgba_visual->type == visual_type)
|
|
|
|
return rgba_visual;
|
|
|
|
else if (gray_visual->depth == depth
|
|
|
|
&& gray_visual->type == visual_type)
|
|
|
|
return gray_visual;
|
|
|
|
|
|
|
|
return NULL;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-06-25 20:40:27 +00:00
|
|
|
/* For these, we also prefer the system visual */
|
2005-11-22 10:03:32 +00:00
|
|
|
void
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_query_depths (GdkScreen *screen,
|
|
|
|
gint **depths,
|
|
|
|
gint *count)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
*count = 1;
|
|
|
|
*depths = &system_visual->depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_query_visual_types (GdkScreen *screen,
|
|
|
|
GdkVisualType **visual_types,
|
|
|
|
gint *count)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
*count = 1;
|
|
|
|
*visual_types = &system_visual->type;
|
|
|
|
}
|
|
|
|
|
2010-12-22 13:42:25 +00:00
|
|
|
void
|
|
|
|
_gdk_quartz_screen_init_visuals (GdkScreen *screen)
|
|
|
|
{
|
|
|
|
system_visual = create_standard_visual (screen, 24);
|
|
|
|
rgba_visual = create_standard_visual (screen, 32);
|
|
|
|
gray_visual = create_gray_visual (screen);
|
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
GList*
|
2010-12-17 15:17:04 +00:00
|
|
|
_gdk_quartz_screen_list_visuals (GdkScreen *screen)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-06-25 20:40:27 +00:00
|
|
|
GList *visuals = NULL;
|
|
|
|
|
|
|
|
visuals = g_list_append (visuals, system_visual);
|
|
|
|
visuals = g_list_append (visuals, rgba_visual);
|
|
|
|
visuals = g_list_append (visuals, gray_visual);
|
|
|
|
|
|
|
|
return visuals;
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|