Changeset 1f83244 in mainline


Ignore:
Timestamp:
2006-06-16T20:00:29Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b34fab6
Parents:
d552ab9
Message:

Added console switching using mouse.

Location:
console
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • console/console.c

    rd552ab9 r1f83244  
    229229                curs_visibility(0);
    230230
     231                async_serialize_start();
    231232                if (kernel_pixmap == -1) {
    232233                        /* store/restore unsupported */
     
    238239                        kernel_pixmap = -1;
    239240                }
     241                async_serialize_end();
    240242
    241243                __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
     
    243245        }
    244246       
     247        async_serialize_start();
     248
    245249        if (console_pixmap != -1) {
    246250                kernel_pixmap = switch_screens(console_pixmap);
     
    281285        curs_goto(conn->screenbuffer.position_y, conn->screenbuffer.position_x);
    282286        curs_visibility(conn->screenbuffer.is_cursor_visible);
     287
     288        async_serialize_end();
    283289}
    284290
     
    291297        int c;
    292298        connection_t *conn;
     299        int newcon;
    293300       
    294301        /* Ignore parameters, the connection is alread opened */
     
    299306                        /* TODO: Handle hangup */
    300307                        return;
     308                case KBD_MS_LEFT:
     309                        newcon = gcons_mouse_btn(IPC_GET_ARG1(call));
     310                        if (newcon != -1)
     311                                change_console(newcon);
     312                        break;
    301313                case KBD_MS_MOVE:
    302314                        gcons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
     
    312324//                      if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
    313325                        if ((c >= 0x101) && (c < 0x101 + CONSOLE_COUNT)) {
    314                                 async_serialize_start();
    315326                                if (c == 0x112)
    316327                                        change_console(KERNEL_CONSOLE);
    317328                                else
    318329                                        change_console(c - 0x101);
    319                                 async_serialize_end();
    320330                                break;
    321331                        }
  • console/gcons.c

    rd552ab9 r1f83244  
    241241}
    242242
     243int mouse_x, mouse_y;
     244int btn_pressed, btn_x, btn_y;
     245
     246/** Handle mouse move
     247 *
     248 * @param dx Delta X of mouse move
     249 * @param dy Delta Y of mouse move
     250 */
    243251void gcons_mouse_move(int dx, int dy)
    244252{
    245         static int x = 0;
    246         static int y = 0;
    247 
    248         x = limit(x+dx, 0, xres);
    249         y = limit(y+dy, 0, yres);
    250 
    251         async_msg_2(fbphone, FB_POINTER_MOVE, x, y);
     253        mouse_x = limit(mouse_x+dx, 0, xres);
     254        mouse_y = limit(mouse_y+dy, 0, yres);
     255
     256        async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
     257}
     258
     259static int gcons_find_conbut(int x, int y)
     260{
     261        int status_start = STATUS_START + (xres-800) / 2;;
     262
     263        if (y < STATUS_TOP || y >= STATUS_TOP+STATUS_HEIGHT)
     264                return -1;
     265       
     266        if (x < status_start)
     267                return -1;
     268       
     269        if (x >= status_start + (STATUS_WIDTH+STATUS_SPACE)*CONSOLE_COUNT)
     270                return -1;
     271        if (((x - status_start) % (STATUS_WIDTH+STATUS_SPACE)) >= STATUS_WIDTH)
     272                return -1;
     273       
     274        return (x-status_start) / (STATUS_WIDTH+STATUS_SPACE);
     275}
     276
     277/** Handle mouse click
     278 *
     279 * @param state New state (1-pressed, 0-depressed)
     280 */
     281int gcons_mouse_btn(int state)
     282{
     283        int conbut;
     284
     285        if (state) {
     286                conbut = gcons_find_conbut(mouse_x, mouse_y);
     287                if (conbut != -1) {
     288                        btn_pressed = 1;
     289                        btn_x = mouse_x;
     290                        btn_y = mouse_y;
     291                }
     292                return -1;
     293        }
     294        if (!state && !btn_pressed)
     295                return -1;
     296        btn_pressed = 0;
     297
     298        conbut = gcons_find_conbut(mouse_x, mouse_y);
     299        if (conbut == gcons_find_conbut(btn_x, btn_y))
     300                return conbut;
     301        return -1;
    252302}
    253303
  • console/gcons.h

    rd552ab9 r1f83244  
    4343void gcons_notify_disconnect(int consnum);
    4444void gcons_mouse_move(int dx, int dy);
     45int gcons_mouse_btn(int state);
    4546
    4647#endif
Note: See TracChangeset for help on using the changeset viewer.