File: display.c

package info (click to toggle)
libforms 1.0.93sp1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 11,548 kB
  • ctags: 9,107
  • sloc: ansic: 97,227; sh: 9,236; makefile: 858
file content (91 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 *  This file is part of the XForms library package.
 *
 *  XForms 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.1, or
 *  (at your option) any later version.
 *
 *  XForms 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 License
 *  along with XForms.  If not, see <http://www.gnu.org/licenses/>.
 */


/**
 * \file display.c
 *
 * We need this so files that reference fl_display don't
 * have to in pull other files.
 */


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "include/forms.h"
#include "flinternal.h"
#include <X11/Xlib.h>


Display *fl_display;


/***************************************
 * given a mask for RGB, find the shifts and number of bits
 ***************************************/

void
fli_rgbmask_to_shifts( unsigned long   mask,
                       unsigned int  * shift,
                       unsigned int  * bits )
{
    unsigned int val;

    if ( mask == 0 )
    {
        *shift = *bits = 0;
        return;
    }

    *shift = 0;
    while ( ! ( ( 1 << *shift ) & mask ) )
        ( *shift )++;

    val = mask >> *shift;

    *bits = 0;
    while ( ( 1 << *bits ) & val )
        ( *bits )++;
}


/***************************************
 ***************************************/

void
fli_xvisual2flstate( FL_State    * s,
                     XVisualInfo * xvinfo )
{
    s->rgb_bits = xvinfo->bits_per_rgb;
    s->rmask = xvinfo->red_mask;
    s->gmask = xvinfo->green_mask;
    s->bmask = xvinfo->blue_mask;

    fli_rgbmask_to_shifts( s->rmask, &s->rshift, &s->rbits );
    fli_rgbmask_to_shifts( s->gmask, &s->gshift, &s->gbits );
    fli_rgbmask_to_shifts( s->bmask, &s->bshift, &s->bbits );
}


/*
 * Local variables:
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */