~bratsche/gdm/gdm-greeter-gtkrc

« back to all changes in this revision

Viewing changes to daemon/getvt.c

  • Committer: Bazaar Package Importer
  • Date: 2008-11-05 23:50:46 UTC
  • Revision ID: jamesw@ubuntu.com-20081105235046-a1f87qv0x87kkdok
Tags: upstream-ubuntu-2.19.4
ImportĀ upstreamĀ versionĀ 2.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <sys/stat.h>
30
30
#include <sys/types.h>
31
31
 
 
32
#include <X11/Xlib.h>
 
33
#include <X11/Xatom.h>
 
34
 
32
35
#include "gdm.h"
33
36
#include "misc.h"
34
37
#include "getvt.h"
 
38
#include "display.h"
35
39
 
36
40
#include "gdm-common.h"
37
41
#include "gdm-daemon-config.h"
 
42
#include "gdm-log.h"
 
43
 
 
44
/*
 
45
 * Get the VT number associated with the display via the XFree86_VT
 
46
 * Atom.
 
47
 */
 
48
long
 
49
gdm_get_current_vtnum (Display *display)
 
50
{
 
51
        Atom prop;
 
52
        Atom actualtype;
 
53
        int actualformat;
 
54
        unsigned long nitems;
 
55
        unsigned long bytes_after;
 
56
        unsigned char *buf;
 
57
        unsigned long num;
 
58
 
 
59
        prop = XInternAtom (display, "XFree86_VT", False);
 
60
        if (prop == None) {
 
61
                gdm_debug ("no XFree86_VT atom\n");
 
62
                return -1;
 
63
        }
 
64
        if (XGetWindowProperty (display, DefaultRootWindow (display), prop, 0, 1,
 
65
                False, AnyPropertyType, &actualtype, &actualformat,
 
66
                &nitems, &bytes_after, &buf)) {
 
67
                gdm_debug ("no XFree86_VT property\n");
 
68
                return -1;
 
69
        }
 
70
        if (nitems != 1) {
 
71
                gdm_debug ("%lu items in XFree86_VT property!\n", nitems);
 
72
                XFree (buf);
 
73
                return -1;
 
74
        }
 
75
 
 
76
        switch (actualtype) {
 
77
        case XA_CARDINAL:
 
78
        case XA_INTEGER:
 
79
        case XA_WINDOW:
 
80
                switch (actualformat) {
 
81
                case  8:
 
82
                        num = (*(uint8_t  *)(void *)buf);
 
83
                        break;
 
84
                case 16:
 
85
                        num = (*(uint16_t *)(void *)buf);
 
86
                        break;
 
87
                case 32:
 
88
                        num = (*(uint32_t *)(void *)buf);
 
89
                        break;
 
90
                default:
 
91
                        gdm_debug ("format %d in XFree86_VT property!\n", actualformat);
 
92
                        XFree (buf);
 
93
                        return -1;
 
94
                }
 
95
                break;
 
96
        default:
 
97
                gdm_debug ("type %lx in XFree86_VT property!\n", actualtype);
 
98
                XFree (buf);
 
99
                return -1;
 
100
        }
 
101
        XFree (buf);
 
102
        return num;
 
103
}
 
104
 
 
105
gchar *
 
106
gdm_get_vt_device (int vtno)
 
107
{
 
108
   gchar *vtname = NULL;
 
109
 
 
110
#if defined (GDM_USE_SYS_VT)
 
111
#ifdef __sun
 
112
     vtname = g_strdup_printf ("/dev/vt/%d", vtno);
 
113
#else
 
114
     vtname = g_strdup_printf ("/dev/tty%d", vtno);
 
115
#endif
 
116
#elif defined (GDM_USE_CONSIO_VT)
 
117
     vtname = g_strdup_printf ("/dev/ttyv%s", __itovty (vtno - 1));
 
118
#endif
 
119
 
 
120
   return vtname;
 
121
}
38
122
 
39
123
#if defined (GDM_USE_SYS_VT) || defined (GDM_USE_CONSIO_VT)
40
124
 
70
154
        char *vtname = NULL;
71
155
        int fd = -1;
72
156
 
73
 
#if defined (GDM_USE_SYS_VT)
74
 
#ifdef __sun
75
 
        vtname = g_strdup_printf ("/dev/vt/%d", vtno);
76
 
#else
77
 
        vtname = g_strdup_printf ("/dev/tty%d", vtno);
78
 
#endif
79
 
#elif defined (GDM_USE_CONSIO_VT)
80
 
        vtname = g_strdup_printf ("/dev/ttyv%s", __itovty (vtno - 1));
81
 
#endif
 
157
        vtname = gdm_get_vt_device (vtno);
 
158
 
82
159
        do {
83
160
                errno = 0;
84
161
                fd = open (vtname, O_RDWR
253
330
}
254
331
 
255
332
int
256
 
gdm_get_cur_vt (void)
 
333
gdm_get_current_vt (void)
257
334
{
258
335
#if defined (GDM_USE_SYS_VT)
259
336
        struct vt_stat s;
321
398
}
322
399
 
323
400
int
324
 
gdm_get_cur_vt (void)
 
401
gdm_get_current_vt (void)
325
402
{
326
403
        return -1;
327
404
}