Changeset 8e6ec6e in mainline


Ignore:
Timestamp:
2012-11-20T00:20:28Z (11 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7dba813
Parents:
03f0b02
Message:

Resolved Ticket #483 (Focus switching is sloppy).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/compositor/compositor.c

    r03f0b02 r8e6ec6e  
    11801180        pointer_t *pointer = input_pointer(input);
    11811181
     1182        fibril_mutex_lock(&window_list_mtx);
     1183        window_t *win = NULL;
     1184        sysarg_t point_x = 0;
     1185        sysarg_t point_y = 0;
     1186        sysarg_t width, height;
     1187        bool within_client = false;
     1188
     1189        /* Determine the window which the mouse click belongs to. */
     1190        list_foreach(window_list, link) {
     1191                win = list_get_instance(link, window_t, link);
     1192                if (win->surface) {
     1193                        surface_get_resolution(win->surface, &width, &height);
     1194                        within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
     1195                            win->transform, width, height, &point_x, &point_y);
     1196                }
     1197                if (within_client) {
     1198                        break;
     1199                }
     1200        }
     1201
     1202        /* Check whether the window is top-level window. */
     1203        window_t *top = (window_t *) list_first(&window_list);
     1204        if (!win || !top) {
     1205                fibril_mutex_unlock(&window_list_mtx);
     1206                return EOK;
     1207        }
     1208
     1209        window_event_t *event = NULL;
     1210        sysarg_t dmg_x, dmg_y;
     1211        sysarg_t dmg_width = 0;
     1212        sysarg_t dmg_height = 0;
     1213
    11821214        if (bpress) {
    11831215                pointer->btn_pos = pointer->pos;
     
    11851217                pointer->pressed = true;
    11861218
    1187                 /* Check whether mouse press belongs to the top-level window. */
    1188                 fibril_mutex_lock(&window_list_mtx);
    1189                 window_t *win = (window_t *) list_first(&window_list);
    1190                 if (!win || !win->surface) {
    1191                         fibril_mutex_unlock(&window_list_mtx);
    1192                         return EOK;
    1193                 }
    1194                 sysarg_t x, y, width, height;
    1195                 surface_get_resolution(win->surface, &width, &height);
    1196                 bool within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
    1197                     win->transform, width, height, &x, &y);
    1198                 fibril_mutex_unlock(&window_list_mtx);
    1199 
    1200                 /* Send mouse press to the top-level window. */
     1219                /* Bring the window to the foreground. */
     1220                if ((win != top) && within_client && (bnum == 1)) {
     1221                        list_remove(&win->link);
     1222                        list_prepend(&win->link, &window_list);
     1223                        comp_coord_bounding_rect(0, 0, width, height, win->transform,
     1224                            &dmg_x, &dmg_y, &dmg_width, &dmg_height);
     1225                }
     1226
     1227                /* Notify top-level window about mouse press. */
    12011228                if (within_client) {
    1202                         window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
     1229                        event = (window_event_t *) malloc(sizeof(window_event_t));
    12031230                        if (event) {
    12041231                                link_initialize(&event->link);
     
    12071234                                event->data.pos.type = POS_PRESS;
    12081235                                event->data.pos.btn_num = bnum;
    1209                                 event->data.pos.hpos = x;
    1210                                 event->data.pos.vpos = y;
    1211                                 comp_post_event(event);
    1212                         } else {
    1213                                 return ENOMEM;
    1214                         }
    1215                 }
     1236                                event->data.pos.hpos = point_x;
     1237                                event->data.pos.vpos = point_y;
     1238                        }
     1239                        pointer->grab_flags = GF_EMPTY;
     1240                }
     1241
    12161242        } else if (pointer->pressed && pointer->btn_num == (unsigned)bnum) {
    12171243                pointer->pressed = false;
    1218 
    1219                 fibril_mutex_lock(&window_list_mtx);
    1220                 window_t *win = NULL;
    1221                 sysarg_t point_x = 0;
    1222                 sysarg_t point_y = 0;
    1223                 sysarg_t width, height;
    1224                 bool within_client = false;
    1225 
    1226                 /* Determine the window which the mouse release belongs to. */
    1227                 list_foreach(window_list, link) {
    1228                         win = list_get_instance(link, window_t, link);
    1229                         if (win->surface) {
    1230                                 surface_get_resolution(win->surface, &width, &height);
    1231                                 within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
    1232                                     win->transform, width, height, &point_x, &point_y);
    1233                         }
    1234                         if (within_client) {
    1235                                 break;
    1236                         }
    1237                 }
    1238 
    1239                 /* Check whether the window is top-level window. */
    1240                 window_t *top = (window_t *) list_first(&window_list);
    1241                 if (!win || !top) {
    1242                         pointer->grab_flags = GF_EMPTY;
    1243                         fibril_mutex_unlock(&window_list_mtx);
    1244                         return EOK;
    1245                 }
    1246 
    1247                 window_event_t *event = NULL;
    1248                 sysarg_t dmg_x, dmg_y;
    1249                 sysarg_t dmg_width = 0;
    1250                 sysarg_t dmg_height = 0;
    12511244
    12521245                sysarg_t pre_x = 0;
     
    13131306                        pointer->grab_flags = GF_EMPTY;
    13141307                       
    1315                 } else if (within_client && (pointer->grab_flags == GF_EMPTY) && (bnum == 1)) {
    1316 
    1317                         /* Bring the window to the foreground. */
    1318                         list_remove(&win->link);
    1319                         list_prepend(&win->link, &window_list);
    1320                         comp_coord_bounding_rect(0, 0, width, height, win->transform,
    1321                             &dmg_x, &dmg_y, &dmg_width, &dmg_height);
    1322                        
    13231308                } else {
    13241309                        pointer->grab_flags = GF_EMPTY;
    13251310                }
    13261311
    1327                 fibril_mutex_unlock(&window_list_mtx);
    1328 
    1329                 if (dmg_width > 0 && dmg_height > 0) {
    1330                         comp_damage(dmg_x, dmg_y, dmg_width, dmg_height);
    1331                 }
    1332 
    1333                 if (event) {
    1334                         comp_post_event(event);
    1335                 }
     1312        }
     1313
     1314        fibril_mutex_unlock(&window_list_mtx);
     1315
     1316        if (dmg_width > 0 && dmg_height > 0) {
     1317                comp_damage(dmg_x, dmg_y, dmg_width, dmg_height);
     1318        }
     1319
     1320        if (event) {
     1321                comp_post_event(event);
    13361322        }
    13371323
Note: See TracChangeset for help on using the changeset viewer.